3 Los petroglifos del norte del territorio
3.5 Categor´ıas de an´alisis
Introduction
If an action, procedure or a module is deleted in a script editor, the code and corresponding file are deleted in the project directory.
Be careful only to delete procedures which are no longer used in other procedures or actions. If an action attempts to call in a procedure which no longer exists, the action is stopped in runtime at the fault point. A non-existing reference in the code is not detected by the syntax check.
Note:
Procedures can only be deleted within a module by deleting the code, not in the editor's navigation window.
Procedure
Procedure
1 Open Global Script.
2 Select the action or module to be deleted in the navigation window.
3 Select the "Delete" command from the context menu.
4 To delete a procedure, open the relevant module and delete the corresponding code in the editor window.
8 Creating and Editing Procedures
Introduction
Projects and standard procedures can be programmed in WinCC using VBS:
• Project procedures can only be called in the current project. Since procedures are stored in the project directory, they are automatically copied when a project is copied.
• Standard procedures can be called in by all computers linked to a project.
When a project is copied onto another computer, the standard procedures must be copied into the corresponding directory on the target computer manually.
The copied procedures are directly available for use in runtime. This becomes visible in the editor when the view is updated.
Apart from the procedures programmed by yourself, general VBS functions can also be used (e.g. Abs, Array,... Year). These general VBS functions can be invoked in the code using the "Function List" command from the context menu.
In addition, WinCC provides the most popular instructions as code templates (e.g.
If...Then, When...While). The code templates can be moved from the navigation window's Code Templates tab control directly into your code via drag&drop.
If you insert a code template into your code, it is important to note that, for example, conditions in the templates are identified by "_XYZ_". You must replace these placeholders with the appropriate information.
Using Procedures
Procedures are used for the central creation and maintenance of codes which are to be implemented at several point in the configuration. Codes are written and saved in a procedure and the procedure is called in with the current parameters in actions or other procedures instead of repeatedly entering the same code.
Procedures are created for repeated functionalities, e.g.
• Calculations with different starting values (procedure with return value)
• Checking tag values (procedure with return value)
• Executing tasks (procedure with return value) This is linked to the following advantages:
• The code is only programmed once.
• Modifications are only made at one point, namely in the procedure, not in each action.
• The action code is shorter and, thus, remains clearer.
Related procedures should be stored in modules in WinCC.
Procedures are loaded in runtime when the calling action is executed.
If a procedure (module) used in a picture is modified, the modification is applied the next time the picture is loaded. This means that a picture currently displayed only works with the modified procedure after the picture has been reloaded.
Note:
Procedures can be used in actions in Global Script and Graphics Designer.
In order to use a global tag defined in Global Script in an action in Graphics Designer, observe the following:
In order that access can be made to the tag, it is necessary to call in the procedure in which the tag is defined.
In order to use a global tag in picture-independent actions in Global Script, observe the following:
In order that access can be made to the tag, at least one procedure in the module containing the tag must be called in at least one global action.
Procedure - Action Restrictions
Global procedures valid for the entire project can only be created in Global Script.
Graphics Designer can only be used to create picture-specific procedures and call in global procedures in actions. Picture-specific procedures in Graphics Designer are defined in the declaration area of an action.
A procedure is not executed without an action.
File Name and Procedure Name
The procedure name is entered in the first line of the procedure code. The procedure is displayed in the navigation window and called in actions under this name. Procedures do not have a file name of their own but are stored in a module.
Module names are assigned in the editor's navigation window. Use the "Save As"
command to save a module under another name in the project directory.
Since procedures in Global Script are valid for the entire project, procedure names must always be unique. Module names can be used more than once within a project, e.g. in different subdirectories or stored separately in the standard and project directories.
Displaying Procedures and Modules
If a module is saved which contains at least one syntactically incorrect procedure, it is displayed in the navigation window with the adjacent symbol.
Caution
If a module contains a syntactically incorrect procedure, the module can no longer be loaded. Procedures can no longer be called from the module.
If a module is saved which only contains syntactically correct procedures, it is displayed in the navigation window with the adjacent symbol.
Procedures and Modules
Procedures are classified as standard or project procedures according to their assignment to standard or project modules. Standard and project modules are located on the corresponding tab controls in the Global Script navigation window.
Use the modules in order to compile procedures to practical function groups.
Observe the following when structuring the modules and procedures:
• The more modules which must be loaded when a picture is called in, the worse the performance in runtime.
• The larger a module, the more procedures are contained and, thus, the longer the loading time for the module.
Organize the modules sensibly, e.g. a module with procedures for a specific system part/picture.