About PDF FormatsPortable Document Format (PDF) is a specific document file format. A PDF file is often a combination of vector graphics, text, and bitmap graphics. A PDF document can also support links (inside document or web page), forms, JavaScript, and many other types of embedded content. File sizes can vary drastically due to image resolution, embedded fonts, and text stored as graphics.
Trang 1Contents
1 Using Visual Basic Script in WinCC 1
2 Modules and Procedures 5
3 Actions 9
4 Multiple Use of Procedures and Actions 11
5 Use of CrossReference 13
6 Using Global Tags in VBS 15
7 VBScript Editors 17
7.1 The Global Script Editor 19
7.2 Working in an Editor Window 22
7.3 Working with the toolbars 25
7.4 Deleting Actions or Procedures 28
8 Creating and Editing Procedures 29
8.1 Creating a New Procedure 32
8.2 Writing Procedure Codes 34
8.3 Using Standard and Project Procedures 37
8.4 Adding Module-Related Information 38
8.5 Protecting a Module with a Password 40
8.6 Saving a Procedure 41
8.7 Renaming a Procedure or Module 43
9 Creating and Editing Actions 45
9.1 Creating a New Action 49
9.2 Editing Actions 50
9.3 Adding Action-related Information 53
9.4 Protecting an Action with a Password 55
9.5 Saving Actions 56
9.6 Triggers 58
9.6.1 Adding a "Timer" Type Trigger 62
9.6.2 Adding Tag Type Trigger 64
9.6.3 Modifying a Trigger 67
9.6.4 Deleting a Trigger 68
9.7 Renaming an Action 70
10 Activating Global Actions in Runtime 71
11 Diagnostics 73
11.1 GSC Diagnostics 74
11.1.1 Inserting the GSC Diagnostics Window in a Picture 75
11.1.2 GSC Diagnostics Attributes 76
11.1.3 GSC Diagnostics Toolbar 77
11.2 GSC Runtime 78
Creating Procedures and Actions with VBS
Trang 211.2.1 Inserting the GSC Runtime Window in a Picture 80
11.2.2 GSC Runtime Attributes 81
11.3 Testing with the Debugger 82
11.3.1 Activating the Debugger 83
11.3.2 Principles of Debugging 85
11.3.3 Components of the Microsoft Script Debuggers 87
11.3.4 Structure of VBScript Files 88
11.3.5 Action and Procedure Names in the Debugger 90
11.3.6 Selecting a Script for Editing 92
11.3.7 Processing Scripts Step-by-Step 93
11.3.8 Setting Breakpoints 94
11.3.9 Deleting Breakpoints 95
11.3.10 Setting Bookmarks in Scripts 96
11.3.11 Determining and Modifying Tag and Property Values 97
11.3.12 Executing Script Commands 98
12 Printing VBScripts 99
13 VBS Reference 101
13.1 Objects and Lists 102
13.1.1 ActiveScreen Object 104
13.1.2 ActiveScreenItem Object 105
13.1.3 HMIRuntime Object 106
13.1.4 Item Object 107
13.1.5 Layer Object 108
13.1.6 Layers Object (List) 109
13.1.7 Parent Object 110
13.1.8 ScreenItem Object 112
13.1.9 ScreenItems Object (List) 115
13.1.10 Screen Object 117
13.1.11 Screens Object (List) 119
13.1.12 Tag Object 121
13.1.13 Tags Object (List) 123
13.2 Object Type of the ScreenItem Object 125
13.2.1 Standard objects 126
13.2.1.1 Ellipse 126
13.2.1.2 Ellipse Arc 127
13.2.1.3 Ellipse Segment 128
13.2.1.4 Circle 129
13.2.1.5 Circular Arc 130
13.2.1.6 Pie Segment 131
13.2.1.7 Line 132
13.2.1.8 Polygon 133
13.2.1.9 Polyline 134
13.2.1.10 Rectangle 135
13.2.1.11 Rounded Rectangle 137
13.2.1.12 Static Text 139
13.2.1.13 Connector 140
13.2.2 Smart Objects 141
13.2.2.1 3D-Bar 141
13.2.2.2 Application Window 143
13.2.2.3 Bar 144
13.2.2.4 Picture Window 146
13.2.2.5 Control 147
13.2.2.6 I/O Field 149
Creating Procedures and Actions with VBS
Trang 313.2.2.7 Graphic Object 150
13.2.2.8 OLE Object 151
13.2.2.9 Group Display 153
13.2.2.10 Text List 154
13.2.2.11 Status Display 155
13.2.3 Windows Objects 156
13.2.3.1 Button 156
13.2.3.2 Check Box 158
13.2.3.3 Option Group 159
13.2.3.4 Round Button 160
13.2.3.5 Slider 161
13.2.4 Controls 163
13.2.4.1 WinCC Alarm Control 165
13.2.4.2 WinCC Digital Analog Clock 166
13.2.4.3 WinCC DXF Control 167
13.2.4.4 WinCC Function Trend Control 168
13.2.4.5 WinCC Gauge Control 169
13.2.4.6 WinCC Online Table Control 170
13.2.4.7 WinCC Online Trend Control 171
13.2.4.8 WinCC Push Button Control 172
13.2.4.9 WinCC Slider Control 174
13.2.4.10 HMI Symbol Library 1.3 176
13.2.5 Customized object 177
13.2.6 Group object 178
13.3 Characteristics 179
13.3.1 A 180
13.3.1.1 AccessPath Property 180
13.3.1.2 Activate Property 181
13.3.1.3 ActiveScreen Property 182
13.3.1.4 ActiveScreenItem Property 183
13.3.1.5 Actualize Property 184
13.3.1.6 ActualPointLeft Property 185
13.3.1.7 ActualPointTop Property 186
13.3.1.8 AdaptBorder Property 187
13.3.1.9 AdaptPicture Property 188
13.3.1.10 AdaptSize Property 189
13.3.1.11 AlarmHigh Property 190
13.3.1.12 AlarmLow Property 191
13.3.1.13 Alignment Property 192
13.3.1.14 AlignmentLeft Property 193
13.3.1.15 AlignmentTop Property 194
13.3.1.16 AllowPersistence Property 195
13.3.1.17 AllServer Property 196
13.3.1.18 Analog Property 197
13.3.1.19 AngleAlpha Property 198
13.3.1.20 AngleBeta Property 199
13.3.1.21 AngleMax Property 200
13.3.1.22 AngleMin Property 201
13.3.1.23 Application Property 202
13.3.1.24 Archive Property 203
13.3.1.25 Assignments Property 204
13.3.1.26 AssumeOnExit Property 205
13.3.1.27 AssumeOnFull Property 206
13.3.1.28 Autorange Property 207
13.3.1.29 AutorangeX Property 208
Creating Procedures and Actions with VBS
Trang 413.3.1.30 AutorangeY Property 209
13.3.1.31 AutoScroll Property 210
13.3.1.32 AutoSize Property 211
13.3.1.33 Average Property 212
13.3.1.34 Axe Property 213
13.3.1.35 AxisSection Property 214
13.3.2 B 215
13.3.2.1 BackBorderWidth Property 215
13.3.2.2 BackColor Property 216
13.3.2.3 BackColor2 Property 217
13.3.2.4 BackColor3 Property 218
13.3.2.5 BackColorBottom Property 219
13.3.2.6 BackColorTop Property 220
13.3.2.7 BackFlashColorOff Property 221
13.3.2.8 BackFlashColorOn Property 222
13.3.2.9 Background Property 223
13.3.2.10 BackgroundPicture Property 224
13.3.2.11 BackStyle Property 225
13.3.2.12 BarBackColor Property 226
13.3.2.13 BarDepth Property 227
13.3.2.14 BarFillColor Property 228
13.3.2.15 BarHeight Property 229
13.3.2.16 BarWidth Property 230
13.3.2.17 BasePicReferenced Property 231
13.3.2.18 BasePicTransColor Property 232
13.3.2.19 BasePicture Property 233
13.3.2.20 BasePicUseTransColor Property 234
13.3.2.21 BaseScreenName Property 235
13.3.2.22 BaseY Property 236
13.3.2.23 BaseX Property 237
13.3.2.24 BeginTime Property 238
13.3.2.25 BeginValue Property 239
13.3.2.26 BeginX Property 240
13.3.2.27 BeginY Property 241
13.3.2.28 BevelColorDown Property 242
13.3.2.29 BevelColorUp Property 243
13.3.2.30 BevelInner Property 244
13.3.2.31 BevelOuter Property 245
13.3.2.32 BevelWidth Property 246
13.3.2.33 BitNumber Property 247
13.3.2.34 BlinkColor Property 248
13.3.2.35 BlinkMode Property 249
13.3.2.36 BlinkSpeed Property 250
13.3.2.37 BorderBackColor Property 251
13.3.2.38 BorderColor Property 252
13.3.2.39 BorderColorBottom Property 253
13.3.2.40 BorderColorTop Property 254
13.3.2.41 BorderEndStyle Property 255
13.3.2.42 BorderFlashColorOff Property 256
13.3.2.43 BorderFlashColorOn Property 257
13.3.2.44 BorderStyle Property 258
13.3.2.45 BorderWidth Property 259
13.3.2.46 BottomConnectedConnectionPointIndex Property 260
13.3.2.47 BottomConnectedObjectName Property 261
13.3.2.48 BoxAlignment Property 262
Creating Procedures and Actions with VBS
Trang 513.3.2.49 BoxCount Property 263
13.3.2.50 BoxType Property 264
13.3.2.51 ButtonColor Property 265
13.3.2.52 ButtonCommand Property 266
13.3.2.53 Button1Width Property 267
13.3.2.54 Button2Width Property 268
13.3.2.55 Button3Width Property 269
13.3.2.56 Button4Width Property 270
13.3.3 C 271
13.3.3.1 Caption Property 271
13.3.3.2 CaptionColor Property 272
13.3.3.3 CaptionFont Property 273
13.3.3.4 CaptionOffset Property 274
13.3.3.5 CaptionText Property 275
13.3.3.6 CellCut Property 276
13.3.3.7 CenterColor Property 277
13.3.3.8 CenterScale Property 278
13.3.3.9 CheckAlarmHigh Property 279
13.3.3.10 CheckAlarmLow Property 280
13.3.3.11 CheckLimitHigh4 Property 281
13.3.3.12 CheckLimitHigh5 Property 282
13.3.3.13 CheckLimitLow4 Property 283
13.3.3.14 CheckLimitLow5 Property 284
13.3.3.15 CheckToleranceHigh Property 285
13.3.3.16 CheckToleranceLow Property 286
13.3.3.17 CheckWarningHigh Property 287
13.3.3.18 CheckWarningLow Property 288
13.3.3.19 ClearOnError Property 289
13.3.3.20 ClearOnNew Property 290
13.3.3.21 Closeable Property 291
13.3.3.22 CloseButton Property 292
13.3.3.23 CoarseGrid Property 293
13.3.3.24 CoarseGridX Property 294
13.3.3.25 CoarseGridY Property 295
13.3.3.26 CoarseGridValue Property 296
13.3.3.27 CoarseGridValueX Property 297
13.3.3.28 CoarseGridValueY Property 298
13.3.3.29 CollectValue Property 299
13.3.3.30 ColMove Property 300
13.3.3.31 Color Property 301
13.3.3.32 ColorAlarmHigh Property 302
13.3.3.33 ColorAlarmLow Property 303
13.3.3.34 ColorBottom Property 304
13.3.3.35 ColorChangeType Property 305
13.3.3.36 ColorLimitHigh4 Property 306
13.3.3.37 ColorLimitHigh5 Property 307
13.3.3.38 ColorLimitLow4 Property 308
13.3.3.39 ColorLimitLow5 Property 309
13.3.3.40 ColorToleranceHigh Property 310
13.3.3.41 ColorToleranceLow Property 311
13.3.3.42 ColorTop Property 312
13.3.3.43 ColorWarningHigh Property 313
13.3.3.44 ColorWarningLow Property 314
13.3.3.45 ColTitle Property 315
13.3.3.46 Command Property 316
Creating Procedures and Actions with VBS
Trang 613.3.3.47 ColWidth Property 317
13.3.3.48 CommonTime Property 318
13.3.3.49 CommonX Property 319
13.3.3.50 CommonY Property 320
13.3.3.51 ContinousChange Property 321
13.3.3.52 CurrentContext Property 322
13.3.3.53 Cursor Property 323
13.3.3.54 CursorControl Property 324
13.3.3.55 CurveForm Property 325
13.3.4 D 326
13.3.4.1 DangerColor Property 326
13.3.4.2 Danger Property 327
13.3.4.3 DataFormat Property 328
13.3.4.4 DataIndex Property 329
13.3.4.5 DataX Property 330
13.3.4.6 DataXY Property 331
13.3.4.7 DataY Property 332
13.3.4.8 DeleteData Property 333
13.3.4.9 Delta Property 334
13.3.4.10 DesiredCurveColor Property 335
13.3.4.11 DesiredCurveCurveForm Property 336
13.3.4.12 DesiredCurveSourceNumberOfUAValues Property 337
13.3.4.13 DesiredCurveSourceUAArchive Property 338
13.3.4.14 DesiredCurveSourceUAArchiveStartID Property 339
13.3.4.15 DesiredCurveSourceUAColumnX Property 340
13.3.4.16 DesiredCurveSourceUAColumnY Property 341
13.3.4.17 DesiredCurveVisible Property 342
13.3.4.18 Direction Property 343
13.3.4.19 DXFFilename Property 344
13.3.5 E 345
13.3.5.1 Edit Property 345
13.3.5.2 Editable Property 346
13.3.5.3 EditAtOnce Property 347
13.3.5.4 Enabled Property 348
13.3.5.5 EndAngle Property 349
13.3.5.6 EndTime Property 350
13.3.5.7 EndValue Property 351
13.3.5.8 EndX Property 352
13.3.5.9 EndY Property 353
13.3.5.10 ErrorDescription Property 354
13.3.5.11 Exponent Property 355
13.3.5.12 ExtendedOperation Property 356
13.3.6 F 357
13.3.6.1 FillColor Property 357
13.3.6.2 Filling Property 358
13.3.6.3 FillingIndex Property 359
13.3.6.4 FillStyle Property 360
13.3.6.5 FillStyle2 Property 361
13.3.6.6 FineGrid Property 362
13.3.6.7 FineGridValue Property 363
13.3.6.8 FineGridValueX Property 364
13.3.6.9 FineGridValueY Property 365
13.3.6.10 FineGridX Property 366
13.3.6.11 FineGridY Property 367
13.3.6.12 FlashBackColor Property 368
Creating Procedures and Actions with VBS
Trang 713.3.6.13 FlashBorderColor Property 369
13.3.6.14 FlashFlashPicture Property 370
13.3.6.15 FlashForeColor Property 371
13.3.6.16 FlashPicReferenced Property 372
13.3.6.17 FlashPicTransColor Property 373
13.3.6.18 FlashPicture Property 374
13.3.6.19 FlashPicUseTransColor Property 375
13.3.6.20 FlashRate Property 376
13.3.6.21 FlashRateBackColor Property 377
13.3.6.22 FlashRateBorderColor Property 378
13.3.6.23 FlashRateFlashPic Property 379
13.3.6.24 FlashRateForeColor Property 380
13.3.6.25 Flip Property 381
13.3.6.26 FocusColor Property 382
13.3.6.27 FocusRect Property 383
13.3.6.28 FocusWidth Property 384
13.3.6.29 Font Property 385
13.3.6.30 FontBold Property 386
13.3.6.31 FontItalic Property 387
13.3.6.32 FontName Property 388
13.3.6.33 FontPosition Property 389
13.3.6.34 FontSize Property 390
13.3.6.35 FontStrikeThru Property 391
13.3.6.36 FontUnderline Property 392
13.3.6.37 ForeColor Property 393
13.3.6.38 ForeFlashColorOff Property 394
13.3.6.39 ForeFlashColorOn Property 395
13.3.6.40 FrameColor Property 396
13.3.6.41 FrameColorDown Property 397
13.3.6.42 FrameColorUp Property 398
13.3.6.43 FramePicture Property 399
13.3.6.44 FrameScale Property 400
13.3.6.45 FrameWidth Property 401
13.3.6.46 FreezeProviderConnections Property 402
13.3.7 G 403
13.3.7.1 GraphDirection Property 403
13.3.7.2 GridLineHorz Property 404
13.3.7.3 GridLines Property 405
13.3.7.4 GridLineValue Property 406
13.3.7.5 GridlinesValueX Property 407
13.3.7.6 GridlinesValueY Property 408
13.3.7.7 GridLineVert Property 409
13.3.7.8 GridlinesX Property 410
13.3.7.9 GridlinesY Property 411
13.3.8 H 412
13.3.8.1 HandFillColor Property 412
13.3.8.2 Handtype Property 413
13.3.8.3 Height Property 414
13.3.8.4 HiddenInput Property 415
13.3.8.5 Hotkey Property 416
13.3.8.6 HourNeedleHeight Property 417
13.3.8.7 HourNeedleWidth Property 418
13.3.8.8 Hysteresis Property 419
13.3.8.9 HysteresisRange Property 420
13.3.9 I 421
Creating Procedures and Actions with VBS
Trang 813.3.9.1 Index Property 421
13.3.9.2 InnerBevelOffset Property 422
13.3.9.3 InnerBevelStyle Property 423
13.3.9.4 InnerBevelWidth Property 424
13.3.9.5 InsertData Property 425
13.3.9.6 ItemBorderBackColor Property 426
13.3.9.7 ItemBorderColor Property 427
13.3.9.8 ItemBorderStyle Property 428
13.3.9.9 ItemBorderWidth Property 429
13.3.9.10 ItemVisible Property 430
13.3.10 L 431
13.3.10.1 Label Property 431
13.3.10.2 LabelColor Property 432
13.3.10.3 LabelX Property 433
13.3.10.4 LabelY Property 434
13.3.10.5 LanguageSwitch Property 435
13.3.10.6 Language Property 436
13.3.10.7 LastError Property 437
13.3.10.8 Layer Property 438
13.3.10.9 Layer00Checked Property 439
13.3.10.10 Layer01Checked Property 440
13.3.10.11 Layer02Checked Property 441
13.3.10.12 Layer03Checked Property 442
13.3.10.13 Layer04Checked Property 443
13.3.10.14 Layer05Checked Property 444
13.3.10.15 Layer06Checked Property 445
13.3.10.16 Layer07Checked Property 446
13.3.10.17 Layer08Checked Property 447
13.3.10.18 Layer09Checked Property 448
13.3.10.19 Layer10Checked Property 449
13.3.10.20 Layer00Color Property 450
13.3.10.21 Layer01Color Property 451
13.3.10.22 Layer02Color Property 452
13.3.10.23 Layer03Color Property 453
13.3.10.24 Layer04Color Property 454
13.3.10.25 Layer05Color Property 455
13.3.10.26 Layer06Color Property 456
13.3.10.27 Layer07Color Property 457
13.3.10.28 Layer08Color Property 458
13.3.10.29 Layer09Color Property 459
13.3.10.30 Layer10Color Property 460
13.3.10.31 Layer00Value Property 461
13.3.10.32 Layer01Value Property 462
13.3.10.33 Layer02Value Property 463
13.3.10.34 Layer03Value Property 464
13.3.10.35 Layer04Value Property 465
13.3.10.36 Layer05Value Property 466
13.3.10.37 Layer06Value Property 467
13.3.10.38 Layer07Value Property 468
13.3.10.39 Layer08Value Property 469
13.3.10.40 Layer09Value Property 470
13.3.10.41 Layer10Value Property 471
13.3.10.42 Left Property 472
13.3.10.43 LeftComma Property 473
13.3.10.44 LightEffect Property 474
Creating Procedures and Actions with VBS
Trang 913.3.10.45 LimitHigh4 Property 475
13.3.10.46 LimitHigh5 Property 476
13.3.10.47 LimitLow4 Property 477
13.3.10.48 LimitLow5 Property 478
13.3.10.49 LimitMax Property 479
13.3.10.50 LimitMin Property 480
13.3.10.51 LineFont Property 481
13.3.10.52 LineHeight Property 482
13.3.10.53 LineTitle Property 483
13.3.10.54 ListType Property 484
13.3.10.55 LoadDataImmediately Property 485
13.3.10.56 LocaleID Property 486
13.3.10.57 LockBackColor Property 487
13.3.10.58 LockStatus Property 488
13.3.10.59 LockText Property 489
13.3.10.60 LockTextColor Property 490
13.3.10.61 LongStrokesBold Property 491
13.3.10.62 LongStrokesOnly Property 492
13.3.10.63 LongStrokesSize Property 493
13.3.10.64 LongStrokesTextEach Property 494
13.3.10.65 LowerLimit Property 495
13.3.10.66 LowerLimitColor Property 496
13.3.10.67 LowerLimitValue Property 497
13.3.11 M 498
13.3.11.1 Marker Property 498
13.3.11.2 Max Property 499
13.3.11.3 MaximizeButton Property 500
13.3.11.4 MCGUBackColorOff Property 501
13.3.11.5 MCGUBackColorOn Property 502
13.3.11.6 MCGUBackFlash Property 503
13.3.11.7 MCGUTextColorOff Property 504
13.3.11.8 MCGUTextColorOn Property 505
13.3.11.9 MCGUTextFlash Property 506
13.3.11.10 MCKOBackColorOff Property 507
13.3.11.11 MCKOBackColorOn Property 508
13.3.11.12 MCKOBackFlash Property 509
13.3.11.13 MCKOTextColorOff Property 510
13.3.11.14 MCKOTextColorOn Property 511
13.3.11.15 MCKOTextFlash Property 512
13.3.11.16 MCKQBackColorOff Property 513
13.3.11.17 MCKQBackColorOn Property 514
13.3.11.18 MCKQBackFlash Property 515
13.3.11.19 MCKQTextColorOff Property 516
13.3.11.20 MCKQTextColorOn Property 517
13.3.11.21 MCKQTextFlash Property 518
13.3.11.22 MCText Property 519
13.3.11.23 MeasurePoints Property 520
13.3.11.24 MessageClass Property 521
13.3.11.25 Min Property 522
13.3.11.26 MinuteNeedleHeight Property 523
13.3.11.27 MinuteNeedleWidth Property 524
13.3.11.28 Moveable Property 525
13.3.11.29 MsgCtrlFlags Property 526
13.3.11.30 MsgFilterSQL Property 527
13.3.12 N 528
Creating Procedures and Actions with VBS
Trang 1013.3.13 Name Property 528
13.3.13.1 NeedleColor Property 529
13.3.13.2 NormalColor Property 530
13.3.13.3 NumberLines Property 531
13.3.13.4 NumItems Property 532
13.3.14 O 533
13.3.14.1 Object Property 533
13.3.14.2 ObjectName Property 534
13.3.14.3 OffsetLeft Property 535
13.3.14.4 OffsetTop Property 536
13.3.14.5 Online Property 537
13.3.14.6 OnTop Property 538
13.3.14.7 OperationMessage Property 539
13.3.14.8 OperationReport Property 540
13.3.14.9 Orientation Property 541
13.3.14.10 OuterBevelStyle Property 542
13.3.14.11 OuterBevelWidth Property 543
13.3.14.12 Outline Property 544
13.3.14.13 OutputFormat Property 545
13.3.14.14 OutputValue Property 546
13.3.15 P-Q 547
13.3.15.1 Parent Property 547
13.3.15.2 PasswordLevel Property 548
13.3.15.3 PersistentRT Property 549
13.3.15.4 PersistentRTCS Property 550
13.3.15.5 PersistentRTCSPermission Property 551
13.3.15.6 PersistentRTPermission Property 552
13.3.15.7 PicDeactReferenced Property 553
13.3.15.8 PicDeactTransparent Property 554
13.3.15.9 PicDeactUseTransColor Property 555
13.3.15.10 PicDownReferenced Property 556
13.3.15.11 PicDownTransparent Property 557
13.3.15.12 PicDownUseTransColor Property 558
13.3.15.13 PicReferenced Property 559
13.3.15.14 PicTransColor Property 560
13.3.15.15 Picture Property 561
13.3.15.16 PictureBack Property 562
13.3.15.17 PictureDeactivated Property 563
13.3.15.18 PictureDown Property 564
13.3.15.19 PictureUp Property 565
13.3.15.20 PictureName Property 566
13.3.15.21 PictureSelected Property 567
13.3.15.22 PictureThumb Property 568
13.3.15.23 PictureUnselected Property 569
13.3.15.24 PicUpReferenced Property 570
13.3.15.25 PicUpTransparent Property 571
13.3.15.26 PicUpUseTransColor Property 572
13.3.15.27 PicUseTransColor Property 573
13.3.15.28 Position Property 574
13.3.15.29 Precisions Property 575
13.3.15.30 PrecisionX Property 576
13.3.15.31 PrecisionY Property 577
13.3.15.32 PredefinedAngles Property 578
13.3.15.33 Pressed Property 579
13.3.15.34 PrintJob Property 580
Creating Procedures and Actions with VBS
Trang 1113.3.15.35 Process Property 581
13.3.15.36 ProjectPath Property 582
13.3.15.37 ProviderClsid Property 583
13.3.15.38 ProviderType Property 584
13.3.15.39 PointCount Property 585
13.3.15.40 QualityCode Property 586
13.3.16 R 587
13.3.16.1 Radius Property 587
13.3.16.2 RadiusHeight Property 588
13.3.16.3 RadiusWidth Property 589
13.3.16.4 RangeMax Property 590
13.3.16.5 RangeMin Property 591
13.3.16.6 Rectangular Property 592
13.3.16.7 ReferenceRotationLeft Property 593
13.3.16.8 ReferenceRotationTop Property 594
13.3.16.9 RelayCurves Property 595
13.3.16.10 Relevant Property 596
13.3.16.11 Replacement Property 597
13.3.16.12 ReplacementColor Property 598
13.3.16.13 RightComma Property 599
13.3.16.14 Rotation Property 600
13.3.16.15 RotationAngle Property 601
13.3.16.16 RoundCornerHeight Property 602
13.3.16.17 RoundCornerWidth Property 603
13.3.16.18 RulerPrecisions Property 604
13.3.16.19 RulerPrecisionX Property 605
13.3.16.20 RulerPrecisionY Property 606
13.3.17 S 607
13.3.17.1 SameSize Property 607
13.3.17.2 ScaleColor Property 608
13.3.17.3 ScaleTicks Property 609
13.3.17.4 Scaling Property 610
13.3.17.5 ScalingType Property 611
13.3.17.6 ScalingTypeX Property 612
13.3.17.7 ScalingTypeY Property 613
13.3.17.8 Screen Property 614
13.3.17.9 ScreenName Property 615
13.3.17.10 Screens Property 616
13.3.17.11 ScreenItems Property 617
13.3.17.12 Scrollable Property 618
13.3.17.13 ScrollBars Property 619
13.3.17.14 SecondNeedleHeight Property 620
13.3.17.15 SecondNeedleWidth Property 621
13.3.17.16 SelBGColor Property 622
13.3.17.17 SelectionMode Property 623
13.3.17.18 SelTextColor Property 624
13.3.17.19 ServerData Property 625
13.3.17.20 ServerPrefix Property 626
13.3.17.21 ServerNames Property 627
13.3.17.22 ShowBar Property 628
13.3.17.23 ShowDanger Property 629
13.3.17.24 ShowDecimalPoint Property 630
13.3.17.25 ShowNormal Property 631
13.3.17.26 ShowPeak Property 632
13.3.17.27 ShowPosition Property 633
Creating Procedures and Actions with VBS
Trang 1213.3.17.28 ShowRulerImmediately Property 634
13.3.17.29 ShowThumb Property 635
13.3.17.30 ShowValuesExponentialX Property 636
13.3.17.31 ShowValuesExponentialY Property 637
13.3.17.32 ShowWarning Property 638
13.3.17.33 SignificantMask Property 639
13.3.17.34 Sizeable Property 640
13.3.17.35 SmallChange Property 641
13.3.17.36 SourceBeginTime Property 642
13.3.17.37 SourceEndTime Property 643
13.3.17.38 SourceNumberOfUAValues Property 644
13.3.17.39 SourceNumberOfValues Property 645
13.3.17.40 SourceTagNameX Property 646
13.3.17.41 SourceTagNameY Property 647
13.3.17.42 SourceTagProviderDataX Property 648
13.3.17.43 SourceTagProviderDataY Property 649
13.3.17.44 SourceTimeRange Property 650
13.3.17.45 SourceUAArchive Property 651
13.3.17.46 SourceUAArchiveStartID Property 652
13.3.17.47 SourceUAColumnX Property 653
13.3.17.48 SourceUAColumnY Property 654
13.3.17.49 SquareExtent Property 655
13.3.17.50 StartAngle Property 656
13.3.17.51 Statusbar Property 657
13.3.17.52 StatusbarPanes Property 658
13.3.17.53 Stretch Property 659
13.3.18 T 660
13.3.18.1 TagName Property 660
13.3.18.2 TagPrefix Property 661
13.3.18.3 Tags Property 662
13.3.18.4 TagProviderClsid Property 663
13.3.18.5 Template Property 664
13.3.18.6 Text Property 665
13.3.18.7 ThumbBackColor Property 666
13.3.18.8 TicColor Property 667
13.3.18.9 TicFont Property 668
13.3.18.10 TicOffset Property 669
13.3.18.11 TicTextColor Property 670
13.3.18.12 TicTextOffset Property 671
13.3.18.13 TicWidth Property 672
13.3.18.14 Ticks Property 673
13.3.18.15 TicksColor Property 674
13.3.18.16 TickStyle Property 675
13.3.18.17 TimeAxis Property 676
13.3.18.18 TimeAxisFormat Property 677
13.3.18.19 TimeAxisX Property 678
13.3.18.20 TimeColumnAlignment Property 679
13.3.18.21 TimeFormat Property 680
13.3.18.22 TimeJump Property 681
13.3.18.23 TimeJumpColor Property 682
13.3.18.24 TimeOverlap Property 683
13.3.18.25 TimeOverlapColor Property 684
13.3.18.26 TimeRange Property 685
13.3.18.27 TimeRangeBase Property 686
13.3.18.28 TimeRangeFactor Property 687
Creating Procedures and Actions with VBS
Trang 1313.3.18.29 TimeStamp Property 688
13.3.18.30 TimeZone Property 689
13.3.18.31 TitleCut Property 690
13.3.18.32 Titleline Property 691
13.3.18.33 Toggle Property 692
13.3.18.34 ToleranceHigh Property 693
13.3.18.35 ToleranceLow Property 694
13.3.18.36 ToolbarAlignment Property 695
13.3.18.37 ToolbarButtons Property 696
13.3.18.38 Toolbar Property 697
13.3.18.39 ToolbarHotKeys Property 698
13.3.18.40 ToolTipText Property 699
13.3.18.41 Top Property 700
13.3.18.42 TopConnectedConnectionPointIndex Property 701
13.3.18.43 TopConnectedObjectName Property 702
13.3.18.44 Transparent Property 703
13.3.18.45 Trend Property 704
13.3.18.46 TrendColor Property 705
13.3.18.47 Type Property 706
13.3.18.48 TypeAlarmHigh Property 708
13.3.18.49 TypeAlarmLow Property 709
13.3.18.50 TypeLimitHigh4 Property 710
13.3.18.51 TypeLimitHigh5 Property 711
13.3.18.52 TypeLimitLow4 Property 712
13.3.18.53 TypeLimitLow5 Property 713
13.3.18.54 TypeToleranceHigh Property 714
13.3.18.55 TypeToleranceLow Property 715
13.3.18.56 TypeWarningHigh Property 716
13.3.18.57 TypeWarningLow Property 717
13.3.19 U 718
13.3.19.1 UnitColor Property 718
13.3.19.2 UnitFont Property 719
13.3.19.3 UnitOffset Property 720
13.3.19.4 UnitText Property 721
13.3.19.5 UnselBGColor Property 722
13.3.19.6 UnselTextColor Property 723
13.3.19.7 UserValue1 Property 724
13.3.19.8 UserValue2 Property 725
13.3.19.9 UserValue3 Property 726
13.3.19.10 UserValue4 Property 727
13.3.19.11 UpdateCycle Property 728
13.3.19.12 UpperLimit Property 729
13.3.19.13 UpperLimitColor Property 730
13.3.19.14 UpperLimitValue Property 731
13.3.20 V-Z 732
13.3.20.1 ValueColumnAlignment Property 732
13.3.20.2 Value Property 733
13.3.20.3 ValueMax Property 734
13.3.20.4 ValueMin Property 735
13.3.20.5 Variable Property 736
13.3.20.6 Visible Property 737
13.3.20.7 Warning Property 738
13.3.20.8 WarningColor Property 739
13.3.20.9 WarningHigh Property 740
13.3.20.10 WarningLow Property 741
Creating Procedures and Actions with VBS
Trang 14Contents 03.04
13.3.20.11 Width Property 742
13.3.20.12 WindowBorder Property 743
13.3.20.13 WindowsStyle Property 744
13.3.20.14 WindowType Property 745
13.3.20.15 WithAxes Property 746
13.3.20.16 WithLabels Property 747
13.3.20.17 ZeroPoint Property 748
13.3.20.18 ZeroPointValue Property 749
13.3.20.19 Zoom Property 750
13.3.20.20 Zoomable Property 751
13.4 Methods 752
13.4.1 Activate Method 752
13.4.2 Item Method 753
13.4.3 Read Method 754
13.4.4 Refresh Method 757
13.4.5 Stop Method 758
13.4.6 Trace Method 759
13.4.7 Write Method 760
14 Examples of VBScript 763
14.1 Examples in WinCC 764
14.1.1 Example: Accessing objects in Graphics Designer 764
14.1.2 Example: Defining the color of objects 765
14.1.3 Example: Configuring language changes 766
14.1.4 Example: Deactivating runtime 767
14.1.5 Example: Configuring change picture globally 768
14.1.6 Example: Configuring Change Picture Via Property 769
14.1.7 Example: Configuring diagnostic output via Trace 770
14.1.8 Example: Writing tag values 771
14.1.9 Example: Reading tag values 773
14.1.10 Example: Writing Object Properties 775
14.2 General examples for VBScript 777
14.2.1 Example: Configuring a database connection with VBS 778
14.2.2 Example: CCalling Methods of an ActiveX Control 781
14.2.3 Example: Using the MS Automation interface 783
14.2.4 Example: Starting an external application 785
15 Basic Principles of VBScript 787
Trang 151 Using Visual Basic Script in WinCC
Introduction
In addition to the C script, WinCC also provides the VBScript program language as a programming interface in order to make the WinCC runtime environment dynamic
Target Group of the Documentation
This documentation is aimed at project engineers having experience with Visual Basic or WinCC Scriptings (C)
• Picture-independent Actions: Picture-independent actions can be triggered cyclically or according to tag values, e.g for the daily transfer of values into an Excel table
VBS can be used at the following points in WinCC:
• In the Global Script Editor: This is used to configure picture-independent actions and procedures The procedures can be used in picture-dependent and picture-independent actions Several procedures are compiled in a topic- related module
• In Graphics Designer: Picture-dependent actions can be configured with which the properties of graphic objects can be made dynamic or caused to respond to events in runtime
Application Scenarios
VBS can be used in runtime, for example:
• to configure setpoint value specification for tags for the operation of a graphic object in order to define a value for the PLC by clicking a mouse
• to configure switching the runtime language for the operation of a graphic object
• to configure the change of color, e.g cyclically (flashing) or to display statuses (motor on)
Apart from the specific WinCC applications, the general functionality of VBS can also be used to customize the Windows environment, e.g.:
• to transfer data to another application (e.g Excel)
• to start external applications from WinCC
• to create files and folders
The automation objects in your environment are available with which to customize the Windows environment
Trang 16• VBScripts and C-scripts can be configured within a picture and project
• C-scripts cannot be invoked in VBScripts and vice versa
• VBS provides internal interfaces to tags and picture objects while the C
environment enables access to other WinCC subsystems (e.g the report system)
VBS and VBA
VBA is used in WinCC Configuration during the configuration in order to adapt Graphics Designer to your individual requirements and to simplify and automate configuration VBA programs only run in the WinCC configuration environment
As opposed to VBA, VB scripts only run in WinCC Runtime and, from there, enable access to graphic objects and tags Objects and pictures can be neither created nor modified on a permanent basis in VBS, as opposed to VBA
The main language-related differences between VBA and VBS are e.g.:
• VBS was developed for use in Internet, VBA for the automation of software applications
• The data type of VBS tags is always VARIANT VBA, on the other hand,
differentiates the individual data types such as INT, DOUBLE, STRING, etc
• Certain language constructed from VBA have been removed from or added to VBS
• Faults are handled differently in VBS as compared to VBA
A complete list of the differences between VBA and VBS is provided in the
Appendix in "Basic Principles of VBScript"
Procedures, Modules and Actions
VBS in WinCC enables the use of procedures, modules and actions to make the Runtime environment dynamic:
• Procedures: A procedure corresponds to a function in C Codes are stored in procedures which are then used at several points in the configuration Call in the code or another procedure in an action by invoking the procedure name
Procedures can be created in WinCC with or without return values Procedures
do not have their own trigger, They are always called in by an action
• Modules: It is advantageous to compile related procedures to units in modules Create modules for procedures, for example, which must be used in a specific picture or belong to a specific topic, such as auxiliary mathematical functions or database access functions
• Actions: Actions are always activated by a trigger, namely a triggering event Actions are configured in graphic object properties, in events which occur on a graphic object, or globally in a project Codes used several times can be called,
in the form of procedures, in actions
Trang 172 Modules and Procedures
Introduction
Procedures are used to make codes, created only once, available at several points
in a project Instead of entering the code several times, simply call in the
corresponding procedure The code is clearer and easier to maintain
Related procedures should be stored in modules When a certain procedure is called in via an action during runtime, the module is loaded which contains that procedure 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
Trang 18Another type of structuring of procedures in modules is the functional structuring, e.g a module containing mathematical functions Use this structure, for example, for modules which should be used globally for projects The following example illustrates a module containing mathematical functions derived from the standard functions:
Procedure Features
The procedures in WinCC have the following properties:
• They are created and modified by the user
• They can be protected against modification and viewing by means of a
password
• They do not have a trigger
• They are stored in a module
WinCC does not provide predefined procedures, but does provide code templates and Intellisense, for example, to simplify programming Procedures differ according
• The have the file extension *.bmo
Modules differ according to the validity of their procedures in:
Trang 19• Standard Modules: Contain procedures which are globally available to the project Standard modules are stored in the WinCC file system under: <WinCC installation directory>\ApLib\ScriptLibStd\<Module name>.bmo
• Project Modules: Contain project-specific procedures Project modules are stored in the WinCC file system under: <Project directory>\ScriptLib\<Module name>.bmo Since the project modules are stored in the project directory, they are copied when the WinCC project is copied
Note:
If WinCC must be reinstalled and the standard procedures and modules need to
be used again, save the module files prior to the reinstallation in a different
directory and copy them in the relevant WinCC directory after the reinstallation has been completed Otherwise, the standard modules in the WinCC installation
directory are deleted during the installation routine
Using Procedures and Modules
Procedures are used in:
• Actions (in Graphics Designer and Global Script)
• Other procedures (in Global Script)
Procedures are structured in modules
3 Actions
Introduction
An action is always started by a trigger An action, for example, is triggered in
runtime when an object is operated by a mouse click, a certain time has occurred
or a tag has been modified
Action Features
Actions are defined once in Global Script and then available independent of the picture Global Script actions are only valid in the project in which they were defined Actions linked to a graphic object are only valid in the picture in which they were defined
Note:
VBS does not currently allow the creation of computer-specific actions
The following applies for clients in a multi-user system: All global actions
configured on a server are also executed on a client when a project is opened The following applies for clients in a distributed system: If actions should be used
on a client computer, copy all the action files in the corresponding project directory
on the client
Actions have the following properties:
• Actions are created and modified by the user
• Action in Global Script can be protected against modification and viewing by means of a password
• Actions have at least one trigger
• Actions in Global Script have the file extension *.bac
• Global Script actions are stored in the WinCC file system under: <Project directory>\ScriptAct\Actionname.bac
Trang 20Action Trigger
Triggers are required to execute actions in Runtime A trigger is linked to an action thus forming the triggering event which calls the action Actions without a trigger are not executed
The following trigger types are available in WinCC:
• Timer: Acyclic or cyclic trigger, e.g for calling a picture or every hour
• Tag: Change of value
• Event: Modification of object properties (e.g change of color) or event on an object (e.g mouse click)
Processing of Actions in Runtime
In Graphics Designer:
Two actions of the same type can be executed simultaneously in runtime In order, for example, that cyclic actions are not hindered by an action executed by a mouse click, event triggered actions and cyclic/tag triggered actions in Graphics Designer are executed independently of each other
Note:
Note that synchronization between the two action types in WinCC can only be achieved by internal WinCC tags As a result of the separate processing, no
common data area exists between event triggered and cyclic/tag triggered actions
If processing cyclic actions in pictures, for example, is prevented by a high system load or another action, the action is started at the next opportunity Cycles which are not executed are not retained in a queue but rejected
After a change of picture, scripts still running are automatically stopped 1 minute after the change of picture
Scripts which are still running when runtime is terminated are stopped after 5 seconds
In Global Script
Picture-independent actions from Global Script are executed in runtime in
succession after being triggered If an action is triggered while another action is in progress, the second action is retained in a queue until it can be executed
Note:
Note that synchronization between actions in Global Script and in Graphics
Designer can only be achieved by means of internal WinCC tags There is no common data area between the actions in Graphics Designer and in Global Script
Using the Actions
Actions can be used as follows:
• In Global Script: The global actions defined here run picture-independent in runtime
• In Graphics Designer: The actions defined here only run in the configured picture An action is configured in Graphics Designer on an object property or
an event on a graphic object
4 Multiple Use of Procedures and Actions
Introduction
An action configured with VBS in WinCC is always valid for the project in which it was defined
Trang 21Procedures have the following areas of application:
• Standard procedures apply globally to projects located on the computer on which they were created
• Project procedures can only be used in the project in which they were created
If a project is copied, the project procedures (modules) are copied together with the project
If actions or procedures/modules are to be used in other projects or on other computers, it is possible either to:
• use the "Save As" function to store the action or module in a different project directory or, for example, on a disk
• to copy the action or module file in Windows Explorer and paste it in the corresponding project or standard directory on the target computer
The properties and triggers configured are retained during copying Copied modules are directly available in runtime Copied actions are executed in runtime after they have been opened and stored once
Note:
Tags used in an action or procedure must also be available on the target
computer If the tag is not available, the action or procedure is not executed Procedures which are called in an action must be available on the target
computer If the procedure is not available, a runtime error occurs during runtime
Storing Procedures
If procedures need to be copied in other project directories in order to be able to use then in other projects or on different computers, observe the storage path of the procedures in the WinCC file system:
• Standard procedures: <WinCC installation
directory>\ApLib\ScriptLibStd\Module name.bmo
• Project procedures: <Project directory>\ScriptLib\Module name.bmo
Note:
Since procedures are always stored in modules, always copy the module (*.bmo)
in which the procedure is contained
The copied procedures/modules are visible after updating the Global Script
navigation window (context menu command "Update") or restarting the editor
Storing Actions
If actions need to be copied in other project directories in order to be able to use then in other projects or on different computers, observe the storage path of the actions in the WinCC file system:
The copied actions are visible after updating the Global Script navigation window (context menu command "Update") or restarting the editor
Trang 225 Use of CrossReference
CrossReference and Tag Trigger
The CrossReference from WinCC can be used to quickly find all the application points of tags, even in VBS actions Tag triggers in actions in Graphics Designer can be "linked" using CrossReference, i.e replaced by other tags at all or selected points
Note:
Tags can also be directly linked in Graphics Designer by marking the graphic object and selecting the "LInking " command from the context menu
Further information on CrossReference is available in the WinCC documentation
Actions and CrossReference
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
Tags and CrossReference
All tags addressed with the standard formulation
Trang 23Pictures and CrossReference
All pictures addressed with the standard formulation
Using Global Tags in Graphics Designer and Global Script
Observe the following conditions when using global tags in Graphics Designer and Global Script:
• In order to use a global tag in an action in Graphics Designer, call in the
procedure in which the tag is defined so that the associated module is loaded
in runtime
• In order to use a global tag in an action in Global Script, at least one procedure must be activated from the module in at least one global action in which the tag
is defined so that the module is loaded in Global Script Runtime This need not
be the procedure in which the tag was defined
This process is necessary because actions from Global Script and Graphics Designer are processed independently of each other in runtime There is no common data area between the two runtime systems
When actions from Global Script and Graphics Designer must be synchronized, use internal WinCC tags
Using Global Tags in Graphics Designer
When using global tags in Graphics Designer, observe the following conditions:
• In order to use a global tag in cyclic or a tag triggered action in Graphics
Designer, call in the procedure in which the tag is defined This also applies when the tag has already been called in an event triggered action
• In order to use a global tag in an event triggered action in Graphics Designer, call in the procedure in which the tag is defined This also applies when the tag has already been called in a cyclic or tag triggered action
Trang 24This process is necessary because the cyclic/tag triggered actions and the event triggered actions in Graphics Designer in Runtime are processed independently of each other There is no common data area between the two types of action When cyclic/tag triggered actions and event triggered actions must be
synchronized, use internal WinCC tags
In the case of Graphics Designer, it is also possible to define global tags in a separate declaration section Since event triggered and cyclic/tag triggered actions are separately processed in runtime, the global tags can only be jointly addressed within the event triggered or cyclic/tag triggered actions
7 VBScript Editors
Introduction
VBScripts can be programmed at two points in WinCC:
• In Global Script: Global Script is the central editor for VBS programming Call it in via WinCC Explorer
Global Script can be used to program global actions, which are independent of the picture and are not linked to a graphic object, and procedures, which can
be activated in other actions or procedures
• In Graphics Designer: Graphics Designer can be used to program actions related to object properties or events related to graphic objects The action editor in Graphics Designer is called in via the context menu in the Properties dialog of a graphic object
Graphics Designer can be used to make object properties dynamic and
trigger actions through events on objects
Trang 25Restrictions, Global Script - Graphics Designer
Graphics Designer can be used to program actions and picture-specific procedures but not global procedures valid for the entire project However, global procedures which were programmed in Global Script can be called in
Note:
This documentation is used primarily to describe Global Script and makes
reference to deviations in the functionality compared to Graphics Designer A detailed description of the Graphics Designer action editor is provided in the WinCC help topic "Dynamization"
Introduction
Global procedures and actions are created and edited in the Global Script Editor Global Script provides a similar range of functions to that of the C script editor in WinCC
Note:
A detailed description of the action editor for the creation of picture-dependent actions and procedures in Graphics Designer is provided under the WinCC help topic "Dynamics"
Calling Global Script
Global Script is started using the context menu "Open" command in the WinCC Explorer project window
Global Script is also automatically called in when a module or action is opened by means of a double click in WinCC Explorer
Design of Global Script
Global Script editor is designed in accordance with the Windows standards The action editor in the Graphics Designer provides a similar range of functions to that of Global Script A description of the Graphics Designer action editor is
provided in the WinCC help topic "Dynamization"
Trang 26Menu bar (1) and toolbars (2)
All the commands required to create procedures and actions are provided in the menu bar and toolbars
The toolbars can be displayed and hidden using the "View" > "Toolbars" command and can be moved to any position within the editor
Navigation window (3)
The navigation window is used to manage the procedures, modules and actions It also contains code templates which can be inserted into an action or procedure per drag&drop
A procedure can be called in another procedure or action by dragging them from the navigation window and dropping them at the relevant point in the code
The display in the navigation window is updated when the edited document is stored When a file is actually being modified, it is indicated by a * behind the file name
The procedures contained in a module are displayed in the navigation window underneath the module file The Actions tab control also displays the trigger and procedures configured for an action, if necessary those directly defined in an action module
The navigation window can still be used to:
• Create subdirectories for structuring the scripts
• Move, copy, paste, delete and rename modules and directories directly
The display in the navigation window can be individually configured with the "View"
> "Workplace" menu commands It is possible to select whether all file types, only script files or only syntactically correct files should be displayed The navigation window can be opened or hidden with the "View" > "Workplace" > "Display" menu commands
Trang 27Editor window (4)
Procedures and actions are written and edited in the Editor window Each
procedure or action is opened in its own editing window Several editing windows can be open at the same time
The user is supported in the Editor window by Highlight Syntax and Intellisense All general editor functions (e.g Undo/Redo, Find/Replace, Copy, Paste, Cut, Font Settings, Printer Settings) remain available
7.2 Working in an Editor Window
Introduction
Procedures and actions are edited in the editor window
Declaration Areas in Actions (Graphics Designer only)
If actions are created in the Graphics Designer action editor, use the button to call in the declaration area of the action in the editor window
The declaration area can also be used to make general settings to be used globally for the current picture, e.g.:
as described under "Structure of VBScript files"
"Option explicit" in Actions
When creating a new action, the "Option explicit" instruction is automatically set and cannot be deleted in the declaration area (Graphics Designer) or entered in the first line of an action (Global Script) The instruction is necessary as it prevents errors caused by the incorrect notation of tags without declaration The instruction
requires that the tags are always specified with the instruction "Dim" in the code
Trang 28Note:
Do not use the "Option explicit" instruction in the code as this can cause runtime
errors
User Support in Editor Window
The following functions are available to support working in the editor window
Color coding and indentation in the editor window
Certain parts of the code have the following default colors:
Functions Next
Trang 29Dark blue Preprocessor statements
Black Other codes
The color coding in the editor window can be customized by means of the editor settings Select the "Extras" > "Options" menu commands and the "Script Editor Options" dialog to define the settings
In order to organize the codes clearly, they can be structured by indentations The
"Script Editor Options" dialog can also be used to define the tabulator distance and Automatic Indent while writing
Intellisense and Highlight Syntax
During text entry, context-sensitive lists appear containing the properties, methods, and objects possible at the current code position If you insert an element from the list, the required syntax is also indicated automatically
Note:
Full intellisense for all objects can only be utilized in the Graphics Designer if the list is accessed using the object name and the result is assigned to a tag
Otherwise, only a list of standard properties is offered
Example of full intellisense:
Highlight Syntax can be activated and deactivated in the "Script Editor Options" dialog The dialog can be called in using the "Extras" > "Options" menu commands
General VBS Functions
Use the "Function List" context menu command in the editor window to display a list of general VBS functions
Listing Objects, Properties and Methods
Using the context menu in the Editor window you can view a list of the possible objects by calling the "Object List" command in the Graphics Designer Global Script only provides the HMIRuntime object in this list because there is no direct access to the objects of Graphics Designer
Use the "Properties/Methods" context menu command to acquire a list of the
possible properties and methods
The same lists can be called in with the key combination <CTRL + Spacebar>, but must be according to the context of the script
Code Templates
In the "Code Templates" tab in the Navigation window of the Editor, you will find a selection of frequently used instructions, e.g for loops and conditional instructions The templates can be inserted in the procedure codes by means of 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
Trang 30• Opens a tag selection dialog and returns the tag name with an associated reference
• Opens a picture/object browser in which a picture/object can be selected whose name is then used for the return value
• Opens a picture selection dialog for pictures and returns the picture name, with a prefix if necessary
Bookmarks
Bookmarks can be set in the code via the icons in the toolbar in order to find
certain parts in the codes more easily
• Set a bookmark in the line in which the cursor is currently located
• Deletes all bookmarks in the active editor window
• Skips one bookmark further in the code
• Skips one bookmark back in the code
7.3 Working with the toolbars
Purpose
In their default position, the toolbars are located below the menu bar, at the top of the VBS editor The buttons arranged on the toolbars enable quick, easy access to the functions provided in Global Script and the action editor in Graphics Designer Global Script/Graphics Designer provide the following toolbars:
only) Saves the content of the active editing window This function
is only available, when an editing window is open After saving, the display in the navigation window is updated
(Global Script only) Cuts the selected text and copies it to the clipboard This function is only available, when text is selected
Copies the selected text to the clipboard This function is only available, when text is selected
Inserts the contents of the clipboard at the cursor position
This function is only available, when the clipboard is not empty
Prints the contents of the active editing window as project documentation This function is only available, when an editing window is open
<CTRL+O>
<CTRL+S>
<CTRL+X>
<CTRL+C> CTRL<+V>
CTRL<+P>
Trang 32Button Function Key
Combination
Marks the lines selected by the mouse as comments If
no lines have been selected by the mouse, the line in which the cursor is located is marked as a comment
Removes the comment marking from the lines selected
by the mouse If no lines have been selected by the mouse, the comment marking in the line in which the cursor is located is removed
Sets a bookmarks in the current line Actuating again removed the bookmark from the current line
Removes all bookmarks from the current code in the editor window
<CTRL+F9>
<CTRL+SHIF T+F9>
Opens the "Find" dialog for text search in the code <CTRL+F> Opens the "Replace" dialog for search and replace in the
Opens the "Script editor options" dialog Undoes the last of a maximum of 30 editor actions This function is only available, when an editor action has been executed
Redoes the last editor action that was undone This function is only available, when an editor action has been undone
<CTRL+Z>
<CTRL+Y>
Content of the "Edit" Toolbar
Trang 33Button Function Key
Opens a picture selection dialog for pictures and returns the picture name, with the server prefix if necessary
Additional Buttons in Graphics Designer
<CTRL+U>
<CTRL+W>
<CTRL+Q>
<CTRL+B>
Trang 34In addition to the buttons provided by Global Script, the action editor in Graphics Designer also has the following buttons:
• Shows the declarations area (<CTRL+E>)
• Hides the declarations area (<CTRL+A>)
7.4 Deleting Actions or Procedures
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
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
Trang 35If 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
Trang 36Note:
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
Trang 378.1 Creating a New Procedure
On creating a new procedure, WinCC automatically assigns a standard name
"procedure#", in which case # represents a continuous number If the procedure is edited in the editor window, assign the procedure a corresponding name that the procedure can be called in an action later The name appears in the navigation window when the procedure is saved
Note:
Procedure names must be unique within a project If a procedure with the same name already exists, the module is identified as syntactically incorrect Module names can be used twice when the modules are stored in different directories Global procedures (valid for the for entire project) can only be programmed Global Scripts Procedures can be called via actions in Graphics Designer and picture- related procedures created in the declaration area of an action Using a global action in Global Script, it is possible to create procedures directly in the code which are then only applicable for this action
An action must be programmed in order to call in a procedure
Procedure
The following procedure describes the creation of a new procedure in Global Script:
Procedure
2 In the navigation window, select the standard modules or project
modules tab control according to whether a standard procedure or project procedure is to be created
3 Open an existing module or create a new module using the menu
commands "File" > "New" > "Project Module" or "File" > "New" >
"Standard Module"
4 After having created a new module, the structure of a procedure without
return value is already entered in the editor window:
Trang 38Procedure
Enter the procedure name directly in the code: Sub "Procedure name"
5 To insert one procedure in an existing module: Select the module in the
navigation window and then select the "Insert New Procedure" context menu item
The "New Procedure" dialog appears:
6 Enter a procedure name and select whether the procedure should have a
return value parameter The definition of a tag for the return value is then entered in the code (Dim RetVal)
7 Click on OK to confirm your input
Note:
A new procedure can also be entered directly in a module In the case of
procedures without return value, always begin with the instruction "Sub
<Procedure name>" and conclude with "End Sub" In the case of procedures that return values, always begin with the instruction "Function <Procedure name>" and conclude with "End Function" The new procedure is displayed in the navigation window when the module is saved
8.2 Writing Procedure Codes
Introduction
Procedure codes are written in the Global Script editor window
The code of each procedure can call in other procedures via their procedure
names
Procedures can be created with or without return values Use the return value, e.g
to obtain information that the procedure has been executed successfully (e.g 0 = fault, 1 = successfully 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
Trang 39Functions in Global Script
Global Script provides the following functions to support the creation of procedure codes:
Intellisense and Highlight Syntax
During text entry, context-sensitive lists appear containing the properties, methods, and objects possible at the current code position If you insert an element from the list, the required syntax is also indicated automatically
Note:
Full intellisense for all objects can only be utilized in the Graphics Designer if the list is accessed using the object name and the result is assigned to a tag
Otherwise, you are only offered a list of standard properties
Example of full intellisense:
General VBS Functions
Use the "Function List" context menu command in the editor window to display a list of general VBS functions
Listing Objects, Properties and Methods
Using the context menu in the Editor window you can view a list of the possible objects by calling the "Object List" command in the Graphics Designer Global Script only provides the HMIRuntime object in this list because there is no direct access to the objects of Graphics Designer
Use the "Properties/Methods" context menu command to acquire a list of the
possible properties and methods
The same lists can be called in with the key combination <CTRL + Spacebar> but must be according to the context of the script
Code Templates
In the "Code Templates" tab in the Navigation window of the Editor, you will find a selection of frequently used instructions, e.g for loops and conditional instructions The templates can be inserted in the procedure codes by means of 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
directly by double-clicking the error in the output window
Trang 40Note:
The syntax check can only detect syntax errors in the code Programming errors, such as missing references, only become visible in Runtime You should therefore also always check your scripts in the Runtime environment
Changing Procedure
If a procedure is modified while runtime is active, the modification becomes
effective at the following times:
• Procedures called from actions or other procedures in pictures become active following a picture change
• Procedures in Global Script become active directly after being called again
Procedure
Procedure
Procedure
2 Open the module containing the procedure to be edited
3 After double clicking on the procedure in the navigation window, the
cursor skips to the beginning of the required procedure
If a procedure with return value parameters is created (e.g to program repeated calculations or checks), specify a return value at the end on the procedure "procedurename = RetVal"
8.3 Using Standard and Project Procedures
Introduction
Use the drag&drop function in the navigation window or the context menu to insert a procedure in the current code
Project procedures can only be used within the current project, standard
procedures are available for all projects on the computer
Procedures, once created, can be used in other projects or on other computers To
do this, copy the module containing the procedures in the appropriate project or standard directory
Using Procedures in Graphics Designer and Global Script
Procedures defined in Global Script can be called in actions in Global Script and Graphics Designer On executing the action in runtime, the entire module which contains the procedure is loaded
Please observe the following in order to use a global tag defined in a procedure in Global Script:
When using Graphics Designer, always call the procedure in which the tag is defined so that the tag can be used I the procedure is not called in, the
corresponding module is not loaded and access cannot be made to the tag
In the case of picture-independent actions in Global Script, at least one procedure
in the module containing the tag must be called in at least one global action