Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent
damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert
symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are
graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
indicates that minor personal injury can result if proper precautions are not taken.
NOTICE
indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will be
used.
A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property
damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific
task in accordance with the relevant documentation, in particular its warning notices and safety instructions. Qualified
personnel are those who, based on their training and experience, are capable of identifying risks and avoiding
potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation.
If products and components from other manufacturers are used, these must be recommended or
approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and
maintenance are required to ensure that the products operate safely and without any problems. The permissible
ambient conditions must be complied with. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication
may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software described.
Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in
this publication is reviewed regularly and any necessary corrections are included in subsequent editions.
Siemens AG
Division Digital Factory
Postfach 48 48
90026 NÜRNBERG
GERMANY
A5E37536061-AA
Ⓟ 03/2016 Subject to change
Copyright © Siemens AG 2016.
All rights reserved
Table of contents
1 VBS for Creating Procedures and Actions.................................................................................................11
1.1 VBS for creating procedures and actions...............................................................................11
1.2 Using Visual Basic Script in WinCC.......................................................................................12
1.3 Modules and Procedures.......................................................................................................15
1.4 Actions...................................................................................................................................18
1.5 Multiple Use of Procedures and Actions................................................................................20
1.6 Use of CrossReference..........................................................................................................22
1.7 Using Global Tags in VBS......................................................................................................24
1.8 VBScript Editors.....................................................................................................................26
1.8.1 VBScript Editors.....................................................................................................................26
1.8.2 Global Script Editor................................................................................................................27
1.8.3 Working in an Editing Window...............................................................................................30
1.8.4 Working with the Toolbars......................................................................................................33
1.8.5 Deleting Actions or Procedures..............................................................................................35
1.9 Creating and Editing Procedures...........................................................................................36
1.9.1 Creating and Editing Procedures...........................................................................................36
1.9.2 Creating a New Procedure.....................................................................................................39
1.9.3 How to Write Procedure Codes..............................................................................................41
1.9.4 Using Standard and Project Procedures................................................................................44
1.9.5 How to add module-related information.................................................................................45
1.9.6 Protecting a Module with a Password....................................................................................47
1.9.7 Saving a Procedure................................................................................................................48
1.9.8 Renaming a Procedure or Module.........................................................................................50
1.10 Creating and Editing Actions..................................................................................................52
1.10.1 Creating and Editing Actions..................................................................................................52
1.10.2 Creating a New Action...........................................................................................................56
1.10.3 How to Edit Actions................................................................................................................57
1.10.4 How to add action-related information...................................................................................60
1.10.5 Protecting an Action with a Password....................................................................................62
1.10.6 Saving Actions.......................................................................................................................63
1.10.7 Triggers..................................................................................................................................64
1.10.7.1 Triggers..................................................................................................................................64
1.10.7.2 Animation trigger....................................................................................................................68
1.10.7.3 How to add a trigger of the type "Timer"................................................................................70
1.10.7.4 How to add a trigger of the type "Tag"...................................................................................72
1.10.7.5 How to change a trigger.........................................................................................................74
1.10.7.6 How to delete a trigger...........................................................................................................75
1.10.8 How to Rename an Action.....................................................................................................76
1.11 How to activate global actions in Runtime.............................................................................78
1.12 Diagnostics.............................................................................................................................80
WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 02/2016, A5E37536061-AA 3
1.12.1 Diagnostics.............................................................................................................................80
1.12.2 GSC Diagnostics....................................................................................................................81
1.12.2.1 GSC Diagnostics....................................................................................................................81
1.12.2.2 Inserting the GSC Diagnostics Window into a Picture...........................................................82
1.12.2.3 GSC Diagnostics Attributes....................................................................................................82
1.12.2.4 GSC Diagnostics Toolbar.......................................................................................................83
1.12.3 GSC Runtime.........................................................................................................................84
1.12.3.1 GSC Runtime.........................................................................................................................84
1.12.3.2 How to insert the GSC Runtime Window into a Picture.........................................................85
1.12.3.3 GSC Runtime Attributes.........................................................................................................86
1.12.4 Testing with the Debugger.....................................................................................................87
1.12.4.1 Testing with the Debugger.....................................................................................................87
1.12.4.2 How to Activate the Debugger...............................................................................................89
1.12.4.3 Principles of Debugging.........................................................................................................90
1.12.4.4 Structure of VBScript Files.....................................................................................................92
1.12.4.5 Action and Procedure Names in the Debugger......................................................................94
1.12.4.6 Selecting a Script for Editing..................................................................................................96
1.12.4.7 Processing Scripts Step-by-Step...........................................................................................97
1.12.4.8 Setting Breakpoints................................................................................................................98
1.12.4.9 Deleting Breakpoints..............................................................................................................99
1.12.4.10 How to Set Bookmarks in Scripts.........................................................................................100
1.12.4.11 How to Determine and Modify Tag and Property Values.....................................................101
1.12.4.12 Executing Script Commands................................................................................................102
1.13 Printing VBScripts................................................................................................................104
1.14 VBS Reference....................................................................................................................105
1.14.1 VBS Reference....................................................................................................................105
1.14.2 Objects and Lists..................................................................................................................107
1.14.2.1 Objects and Lists..................................................................................................................107
1.14.2.2 Alarm object.........................................................................................................................110
1.14.2.3 Alarms object (list)................................................................................................................110
1.14.2.4 AlarmLogs Object.................................................................................................................112
1.14.2.5 DataItem Object...................................................................................................................113
1.14.2.6 DataLogs Object..................................................................................................................114
1.14.2.7 DataSet Object (List)............................................................................................................116
1.14.2.8 HMIRuntime Object..............................................................................................................118
1.14.2.9 Item Object...........................................................................................................................119
1.14.2.10 Layer Object.........................................................................................................................120
1.14.2.11 Layers Object (Listing).........................................................................................................121
1.14.2.12 Logging Object.....................................................................................................................122
1.14.2.13 ProcessValue Object............................................................................................................123
1.14.2.14 ProcessValues Object (List).................................................................................................124
1.14.2.15 Project Object.......................................................................................................................124
1.14.2.16 ScreenItem Object...............................................................................................................125
1.14.2.17 ScreenItems Object (List).....................................................................................................129
1.14.2.18 Screen Object......................................................................................................................131
1.14.2.19 Screens Object (List)............................................................................................................134
1.14.2.20 SmartTags Object................................................................................................................136
1.14.2.21 Tag Object............................................................................................................................137
1.14.2.22 Tags Object (List).................................................................................................................140
1.14.2.23 TagSet Object (List).............................................................................................................141
1.14.3 Object types of the ScreenItem object.................................................................................143
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
4 System Manual, 02/2016, A5E37536061-AA
1.14.3.1 Object types of the ScreenItem object.................................................................................143
1.14.3.2 Standard objects..................................................................................................................144
1.14.3.3 Smart objects.......................................................................................................................169
1.14.3.4 Windows objects..................................................................................................................201
1.14.3.5 Tube objects.........................................................................................................................215
1.14.3.6 Controls................................................................................................................................218
1.14.3.7 Customized Object...............................................................................................................298
1.14.3.8 Group...................................................................................................................................300
1.14.4 Properties.............................................................................................................................301
1.14.4.1 Properties.............................................................................................................................301
1.14.4.2 A...........................................................................................................................................302
1.14.4.3 B...........................................................................................................................................321
1.14.4.4 C...........................................................................................................................................362
1.14.4.5 D...........................................................................................................................................397
1.14.4.6 E...........................................................................................................................................407
1.14.4.7 F...........................................................................................................................................416
1.14.4.8 G..........................................................................................................................................438
1.14.4.9 H...........................................................................................................................................442
1.14.4.10 I............................................................................................................................................451
1.14.4.11 L...........................................................................................................................................457
1.14.4.12 M..........................................................................................................................................488
1.14.4.13 N...........................................................................................................................................509
1.14.4.14 O..........................................................................................................................................512
1.14.4.15 P...........................................................................................................................................528
1.14.4.16 Q..........................................................................................................................................546
1.14.4.17 R...........................................................................................................................................547
1.14.4.18 S...........................................................................................................................................557
1.14.4.19 T...........................................................................................................................................595
1.14.4.20 U...........................................................................................................................................671
1.14.4.21 V...........................................................................................................................................680
1.14.4.22 W..........................................................................................................................................697
1.14.4.23 X - Z.....................................................................................................................................702
1.14.5 Methods...............................................................................................................................710
1.14.5.1 Methods...............................................................................................................................710
1.14.5.2 Methods A to E.....................................................................................................................712
1.14.5.3 Get methods.........................................................................................................................720
1.14.5.4 Methods H to M....................................................................................................................769
1.14.5.5 Methods N to R....................................................................................................................779
1.14.5.6 Methods S to T.....................................................................................................................797
1.14.5.7 Methods U to Z.....................................................................................................................812
1.14.6 Appendix..............................................................................................................................820
1.14.6.1 Error Messages from Database Area...................................................................................820
1.15 Examples of VBScript..........................................................................................................823
1.15.1 Examples of VBScript..........................................................................................................823
1.15.2 Examples in WinCC.............................................................................................................823
1.15.2.1 Examples in WinCC.............................................................................................................823
1.15.2.2 Example: Accessing objects in Graphics Designer..............................................................824
1.15.2.3 Example: Defining the color of objects.................................................................................825
1.15.2.4 Example: How to Configure Language Changes.................................................................825
1.15.2.5 Example: Deactivating Runtime...........................................................................................826
1.15.2.6 Example: Configuring change picture globally.....................................................................826
1.15.2.7 Example: Configuring Change Picture Via Property............................................................827
Table of contents
WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 02/2016, A5E37536061-AA 5
- 1
- 2
- 3
- 4
- 5
- 6
前往页