WinCC V7.4 WinCC: Scripting (VBS, ANSI-C, - Siemens

Transcription

SIMATIC HMIWinCC V7.4WinCC: Scripting (VBS, ANSI-C,VBA)System ManualPrint of the Online Help02/2016A5E37536061-AAVBS for Creating Proceduresand Actions1ANSI-C for CreatingFunctions and Actions2VBA for AutomatedConfiguration3

Legal informationWarning notice systemThis manual contains notices you have to observe in order to ensure your personal safety, as well as to preventdamage to property. The notices referring to your personal safety are highlighted in the manual by a safety alertsymbol, notices referring only to property damage have no safety alert symbol. These notices shown below aregraded according to the degree of danger.DANGERindicates that death or severe personal injury will result if proper precautions are not taken.WARNINGindicates that death or severe personal injury may result if proper precautions are not taken.CAUTIONindicates that minor personal injury can result if proper precautions are not taken.NOTICEindicates 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 beused. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to propertydamage.Qualified PersonnelThe product/system described in this documentation may be operated only by personnel qualified for the specifictask in accordance with the relevant documentation, in particular its warning notices and safety instructions. Qualifiedpersonnel are those who, based on their training and experience, are capable of identifying risks and avoidingpotential hazards when working with these products/systems.Proper use of Siemens productsNote the following:WARNINGSiemens products may only be used for the applications described in the catalog and in the relevant technicaldocumentation. If products and components from other manufacturers are used, these must be recommended orapproved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation andmaintenance are required to ensure that the products operate safely and without any problems. The permissibleambient conditions must be complied with. The information in the relevant documentation must be observed.TrademarksAll names identified by are registered trademarks of Siemens AG. The remaining trademarks in this publicationmay be trademarks whose use by third parties for their own purposes could violate the rights of the owner.Disclaimer of LiabilityWe 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 inthis publication is reviewed regularly and any necessary corrections are included in subsequent editions.Siemens AGDivision Digital FactoryPostfach 48 4890026 NÜRNBERGGERMANYA5E37536061-AA 03/2016 Subject to changeCopyright Siemens AG 2016.All rights reserved

Table of contents1VBS for Creating Procedures and Actions.111.1VBS for creating procedures and actions.111.2Using Visual Basic Script in WinCC.121.3Modules and Procedures.151.4Actions.181.5Multiple Use of Procedures and Actions.201.6Use of CrossReference.221.7Using Global Tags in VBS.241.81.8.11.8.21.8.31.8.41.8.5VBScript Editors.26VBScript Editors.26Global Script Editor.27Working in an Editing Window.30Working with the Toolbars.33Deleting Actions or 71.9.8Creating and Editing Procedures.36Creating and Editing Procedures.36Creating a New Procedure.39How to Write Procedure Codes.41Using Standard and Project Procedures.44How to add module-related information.45Protecting a Module with a Password.47Saving a Procedure.48Renaming a Procedure or 7.61.10.8Creating and Editing Actions.52Creating and Editing Actions.52Creating a New Action.56How to Edit Actions.57How to add action-related information.60Protecting an Action with a Password.62Saving Actions.63Triggers.64Triggers.64Animation trigger.68How to add a trigger of the type "Timer".70How to add a trigger of the type "Tag".72How to change a trigger.74How to delete a trigger.75How to Rename an Action.761.11How to activate global actions in Runtime.781.12Diagnostics.80WinCC: Scripting (VBS, ANSI-C, VBA)System Manual, 02/2016, A5E37536061-AA3

Table of 80GSC Diagnostics.81GSC Diagnostics.81Inserting the GSC Diagnostics Window into a Picture.82GSC Diagnostics Attributes.82GSC Diagnostics Toolbar.83GSC Runtime.84GSC Runtime.84How to insert the GSC Runtime Window into a Picture.85GSC Runtime Attributes.86Testing with the Debugger.87Testing with the Debugger.87How to Activate the Debugger.89Principles of Debugging.90Structure of VBScript Files.92Action and Procedure Names in the Debugger.94Selecting a Script for Editing.96Processing Scripts Step-by-Step.97Setting Breakpoints.98Deleting Breakpoints.99How to Set Bookmarks in Scripts.100How to Determine and Modify Tag and Property Values.101Executing Script Commands.1021.13Printing 1.14.2.211.14.2.221.14.2.231.14.3VBS Reference.105VBS Reference.105Objects and Lists.107Objects and Lists.107Alarm object.110Alarms object (list).110AlarmLogs Object.112DataItem Object.113DataLogs Object.114DataSet Object (List).116HMIRuntime Object.118Item Object.119Layer Object.120Layers Object (Listing).121Logging Object.122ProcessValue Object.123ProcessValues Object (List).124Project Object.124ScreenItem Object.125ScreenItems Object (List).129Screen Object.131Screens Object (List).134SmartTags Object.136Tag Object.137Tags Object (List).140TagSet Object (List).141Object types of the ScreenItem object.143WinCC: Scripting (VBS, ANSI-C, VBA)System Manual, 02/2016, A5E37536061-AA

Table of .1Object types of the ScreenItem object.143Standard objects.144Smart objects.169Windows objects.201Tube objects.215Controls.218Customized 97X - Z.702Methods.710Methods.710Methods A to E.712Get methods.720Methods H to M.769Methods N to R.779Methods S to T.797Methods U to Z.812Appendix.820Error Messages from Database 15.2.41.15.2.51.15.2.61.15.2.7Examples of VBScript.823Examples of VBScript.823Examples in WinCC.823Examples in WinCC.823Example: Accessing objects in Graphics Designer.824Example: Defining the color of objects.825Example: How to Configure Language Changes.825Example: Deactivating Runtime.826Example: Configuring change picture globally.826Example: Configuring Change Picture Via Property.827WinCC: Scripting (VBS, ANSI-C, VBA)System Manual, 02/2016, A5E37536061-AA5

Table of 31.15.3.4Example: Configuring diagnostics output via Trace.827Example: Writing tag values.828Example: How to Read Tag Values.830Example: Writing Object Properties.833Example: How to Start an Action on the Server (Logging Object).836Example: You connect or disconnect a database backup with VBS.838Dynamization of Controls.841General Examples.855General examples for VBScript.855Example: Configuring a Database Connection with VBS.856Example: Using the MS Automation interface.858Example: Starting an external application.8591.161.16.11.16.2Basic Principles of VBScript.861Basic Principles of VBScript.861VBScript Basics.861ANSI-C for Creating Functions and Actions.8632.1Creating Functions and Actions with ANSI-C.8632.2Creating Functions and Actions.8642.3Characteristics of Project Functions.8672.4Characteristics of Standard Functions.8682.5Characteristics of Internal Functions.8702.6Characteristics of Local Actions.8712.7Characteristics of Global Actions.8722.8How to Add Global Script Runtime to a Project's Startup List.8732.9Use of Global C-Tags.8742.10Use of DLLs in Functions and 2.11.112.11.11.12.11.11.22.11.11.32.11.11.4The Global Script Editor.878The Global Script Editor.878Working in the Edit Window.880Working in the Edit Window.880Editing Functions with the Keyboard.881Editing Functions with the Mouse.882Working with the Toolbars.882How to Set Different Views.885How to Set the Font Style.885How to Use "Save As.".886How to Delete Actions or Project and Standard Functions.887How to Generate a New Header.887How to Compile All Functions.888How to Search in Files.889Printing Functions and Actions.890Printing Functions and Actions.890How to Set the Print Parameters.890How to Open Page View.891How to Print the Project Documentation.891WinCC: Scripting (VBS, ANSI-C, VBA)System Manual, 02/2016, A5E37536061-AA

Table of 12.72.12.82.12.92.12.10Creating and Editing Functions.892Creating and Editing Functions.892How to Create a New Function.895How to Write Function Code.896How to Use Internal Functions.897How to Use Standard and Project Functions.897Inserting Additional Function-Related Information.898How to Protect a Function Against Unauthorized Access.

SIMATIC HMI WinCC V7.4 WinCC: Scripting (VBS, ANSI-C, VBA) System Manual Print of the Online Help 02/2016 A5E37536061-AA VBS for Creating Procedures