• No results found

Renaming a Procedure or Module

In document Using Visual Basic Script in WinCC (Page 44-48)

Introduction

Procedures and modules are renamed in the following cases:

• When a standard name (procedure# or Modul#), which was automatically assigned when the new module/new procedure was created, is changed to a self-explanatory name.

• When a module or procedure is copied in order, for example, to create a new module with similar content from an existing one. Please note that procedure names must be unique within a project. Procedure names which exist twice are issued as errors during the syntax check. Contrary to procedure names, the same name can be applied to modules when the modules are stored in different directories.

Note:

The module name is always identical to the file name in the WinCC file system. If a module name is changed, e.g. in Windows Explorer, the new module name is taken over from Global Script in the navigation window.

Procedure

Renaming Procedures Procedure

1 Open the procedure to be renamed.

2 Enter the new name in the header of the procedure.

3 Save the procedure so that the name is transferred to the navigation window. Procedure names are always unique and may not be used more than once.

Renaming Modules Procedure

1 Close the module to be renamed.

2 Select the module in the navigation window and choose the "Rename"

option from the context menu.

3 Enter the new name in the navigation window. Module names are always unique at directory level and may not be used more than once.

9 Creating and Editing Actions

Introduction

When using VBS in WinCC, there is no differentiation between local (valid for entire project) and global (valid on all computers) actions. A configured action is always valid globally.

A copied action is available for use in runtime following a restart or opening and saving the action. This becomes visible in the editor wen the view is updated.

VBS actions can be used to make graphic objects and object properties dynamic in runtime or to execute picture-independent actions.

Note:

Please note that the object name length of objects made dynamic in Graphics Designer is limited to approx. 200 characters, and each special character used in an object name is converted to five characters in the script files. The special characters are represented by a four-place hexadecimal code behind the preceding X. If the name of an object made dynamic is too long, a corresponding error message appears. Further information is available in this help under

"Structure of VBScript Files".

Caution

If you make an object property dynamic with a VBS action via the return value of a script, the value of the object property is written only if it has changed in relation to the last script run. It is not considered if the value had been changed from another location.

Therefore it is illegal to change properties which have been made dynamic by VBS action via the return value from another location (e.g., other C scripts or VBS scripts).

If you do not observe this, wrong values can be the results.

Using the Actions

Actions can be used as follows:

On graphic objects in Graphics Designer

Making properties dynamic (action with return value), e.g.:

Function BackColor_Trigger(ByVal Item) 'VBS143

BackColor_Trigger = RGB(125,0,0) End Function

Triggered by an event on an object (action without return value), e.g.:

Sub OnClick(ByVal Item) 'VBS144

Item.BackColor = RGB(255,0,0) End Sub

Picture-independent in Global Script

As a cyclic action, e.g. incrementing a tag:

Set objTag1 = HMIRuntime.Tags("Tag1") lngValue = objTag1.Read

objTag1.Write lngValue + 1 action = CLng(objTag1.value) End Function

Executing Actions

An action can be assigned several triggers. The action is always executed when one of the triggering events occurs. Observe the following:

• Actions in Global Script cannot be executed simultaneously. The action triggered last is held in a queue until the action currently being performed is completed.

• When using Graphics Designer, cyclically and tag-driven actions cannot be triggered simultaneously. If the execution of a tag-driven action hinders the execution of a cyclic action, the cyclic action is executed when the tag-driven action has finished. The cyclic action is held in a queue during the non- execution phase. When the current action is completed, the cyclic action is executed with the normal cycle.

• In Graphics Designer, event-driven actions cannot be executed simultaneously.

The action types mentioned do not prevent each other from being executed: The execution of actions in Global Script has no influence on actions in Graphics Designer. In the same way, in Graphics Designer, the execution of cyclically or tag- driven actions has no effect on the execution of event-driven actions.

Note:

Actions in pictures which are still running one minute after the picture has been deselected are terminated by the system. This is recorded in a logfile entry.

Action Details

All the actions used in a picture can be displayed by means of the picture properties. To do this mark the picture in WinCC Explorer and select the

"Properties" context menu command. After double clicking on an entry, detailed information on the type of dynamics appears.

It is also possible to display all the tags and pictures used in actions by means of the WinCC CrossReference. CrossReference can also be used for the to link tag connections of Graphics Designer actions easily.

Note:

For pictures and tags addresses in your code, always use the standard formulations

HMIRuntime.BaseScreenName = "Screenname" and HMIRuntime.Tags ("Tagname") to ensure that pictures and tags are detected by CrossReference.

Procedure - Action Restrictions

Actions can be used to program instructions and call procedures. Codes are programmed within procedures for use at several points in a configuration. Actions always have a trigger.

Creating and Editing Actions

Actions can be configured in Global Script and Graphics Designer. Use Global Script to configure global actions which can be executed independently of the picture currently open. Graphics Designer is used to configure actions related to graphic objects which should be executed when the picture is opened in runtime or when the configured trigger occurs.

The script editors in WinCC provide the option of checking that scripts have a correct syntax without executing them. Errors in the script are displayed in the output window under the editor window. Double click on the corresponding error line to access the related point in the code.

Note:

The syntax check can only check objects known to the system at the moment of execution. Therefore, the tags and objects addressed in the scripts must be created in WinCC.

Only syntactically correct actions are executed in runtime.

Note:

The automation objects "PDLRuntime" and "WinCC Runtime Project" cannot be used in VBS actions.

Representation of Actions

If a syntactically incorrect action is stored, it is displayed in the Global Script navigation window with the adjacent symbol.

If a syntactically correct action without a trigger is stored, it is displayed in the Global Script navigation window with the adjacent symbol.

If a syntactically correct action with a trigger is stored, it is displayed in the Global Script navigation window with the adjacent symbol.

Note:

Actions can only be saved in the Graphics Designer if they have the correct syntax. If an action with errors should still be retained and exited, however, enter the comments.

In document Using Visual Basic Script in WinCC (Page 44-48)

Related documents