Script object model reference
A language-by-language reference of the objects and functions that can be accessed from scripts: common concepts, a comparison table of the languages, the VBS and JavaScript object model. Python and C are in separate topics.
How to read this reference
Only the members that the engine actually recognizes are listed here. The Reference panel in the code area (VBS, C and Python) gives the same data together with sample code; clicking a row inserts the sample at the cursor. Detailed lists for Python and C are in the topics Python object model and C functions.
Common concepts
Tag value types
| Tag type | VBS | JavaScript | C | Python |
|---|---|---|---|---|
| Bool | binary value (1 / 0, True / False) | true / false | GetTagBit (1 / 0) | bool |
| Integer types | number | number | Byte, SByte, Word, SWord, DWord, SDWord | int |
| Real / LReal | number | number | GetTagFloat / GetTagDouble | float |
| String / WString | text | text | GetTagChar | str |
| DateTime | text (ISO format) | text | GetTagDateTime | ISO str |
Quality codes
VBS (QualityCode), C (…StateQC) and Python (.quality) use the same codes: 192 good, 84 value outside the tag's lower / upper limit (the value is usable), 8 no connection, 4 undefined (tag not found), 0 bad.
System tags
Special names that start with @ and can be read if no tag with the same name is defined in the project:
| Name | Meaning |
|---|---|
@LocalMachineName | The name of the Live PC. |
@CurrentUser, @CurrentUserName | The name and display name of the logged-on user (empty if there is no session). |
@UA_<Rapor>_ID, @UA_<Rapor>_Job | Adds a record to the report named <Rapor> now: first -1 is written to _ID, then 6 to _Job. When the record has been added, Job becomes 0 and ID becomes the new record number; if the report does not exist or another Job value is given, Job becomes −1 and a warning is written to the event log. |
For creating a report record, scada.report_add("Rapor") is shorter in Python. Report side: Report design.
Comparison by language
The — sign indicates that there is no equivalent in that language.
| Operation | VBS | JavaScript | C | Python |
|---|---|---|---|---|
| Read tag | HMIRuntime.Tags("Ad").Read or SmartTags("Ad") | Tag.oku('Ad') | GetTagFloat("Ad") | scada.read("Ad") |
| Write tag | HMIRuntime.Tags("Ad").Write 1 or SmartTags("Ad") = 1 | Tag.yaz('Ad', 1) | SetTagFloat("Ad", 1.0f) | scada.write("Ad", 1) |
| Quality / state | .QualityCode, .LastError | — | GetTagFloatStateQC("Ad", &d, &k) | scada.tag("Ad").quality |
| Several tags together | Tags.CreateTagSet | — | GetTagMultiWait | scada.read_many, write_many, tagset |
| Open screen | HMIRuntime.BaseScreenName = "Sayfa" | Sayfa.ac('Sayfa') | OpenPicture("Sayfa") | scada.open_screen("Sayfa") |
| Previous screen | — | Sayfa.geri() | OpenPrevPicture() | scada.back() |
| Pop-up window | — | — | OpenScreeninPopup(…) | scada.open_window("Sayfa") |
| Object property | ScreenItems("N").Text = "x" | — | SetText("Sayfa", "N", "x") | scada.screen.items["N"].text = "x" |
| Show / hide layer | Screens("S").Layers(1).Visible = False | — | — | sayfa.layers[0].visible = False |
| Logged-in user | HMIRuntime.Tags("@CurrentUser").Read | Kullanici.ad | PWRTGetCurrentUser (UseAdmin.dll) | scada.user |
| Login window | — | — | ShowLogonDialog() | scada.login_dialog() |
| Message / confirmation window | MsgBox | Bildir(metin) (information only) | MessageBoxA (user32.dll) | scada.msgbox(…), scada.notify(…) |
| Prompting for a value | InputBox | — | — | scada.inputbox(…) |
| Live language | HMIRuntime.Language = 1033 | — | SetLanguage(1033) | scada.language = 1033 |
| Values between scripts | HMIRuntime.DataSet | Adding to window | file-level variable | scada.dataset |
| Adding a record to a report | @UA_Rapor_ID / _Job | — | — | scada.report_add("Rapor") |
| Database | ADODB.Connection | — | — | scada.db.connect(…), pyodbc |
| File | Scripting.FileSystemObject | — | fopen, fprintf | open(), os, pathlib |
| Start program | WScript.Shell.Run | — | ProgramExecute | scada.run(…) |
| Waiting | (DateDiff loop) | setTimeout | Sleep(ms) | scada.sleep(sn), scada.wait_for(…) |
| Diagnostics output | HMIRuntime.Trace | — | printf, TraceText | print, scada.trace |
| Exit Live | HMIRuntime.Stop | — | DeactivateRTProject() | scada.stop() |
VBS object model
Object member names are not case-sensitive. For CreateObject objects that require permission, see VBScript scripts.
HMIRuntime
| Member | Description |
|---|---|
Tags("Ad") | Tag object (same as Tags.Item("Ad")). |
SmartTags("Ad") | Reads the value of the tag; SmartTags("Ad") = v writes it. |
Screens("Sayfa") | An open screen (main screen, pop-up window, inside a screen window). A closed screen is not in the list; Screens.Count and For Each work. |
ActiveScreen | The screen in front. |
BaseScreenName | Name of the main screen; assigning it opens that screen. |
Language | Live language number (1055 Turkish, 1033 English, 1031 German); if assigned, the language changes. |
ActiveProject.Name, .Path | Name and folder of the project. |
DataSet | Values shared by all scripts and kept in memory for the whole session. |
CurrentContext | The context from which the script is called. |
Trace "metin" | Writes a line to the event log and to script diagnostics. |
Stop | Sends a request to close Live. |
HMIRuntime.Logging, AlarmLogs, DataLogs, Alarms and MenuToolBarConfig are not available in this version (an error occurs if they are called).
Tag, TagSet
| Object | Members |
|---|---|
| Tag | Read([kip]), Write [değer], Value (default property), Name, QualityCode, TimeStamp, LastError, ErrorDescription, TagPrefix |
TagSet (Tags.CreateTagSet) | Add, Remove, RemoveAll, Read, Write, Item / grup("Ad"), Count, LastError |
The mode parameter of Read and the mode parameter of Write are accepted but make no difference: a write is always sent to the driver immediately and awaited.
Screen, ScreenItem, Layers, DataSet
| Object | Members |
|---|---|
| Screen | ObjectName, ScreenItems, Layers, DataSet, ActiveScreenItem, Parent, AccessPath, Activate(), Refresh(), Width, Height, BackColor, Zoom, Enabled, TagPrefix |
| ScreenItem | ObjectName, Type, Left, Top, Width, Height, Visible, Enabled, Layer, Parent, TagPrefix, ToolTipText, Activate(); common names: Text, BackColor, ForeColor, BorderColor, FontName, FontSize, FontBold, FontItalic, FontUnderline, ProcessValue, OutputValue, RotationAngle, Transparency, FlashingEnabled; also the object's own property names in the Properties tab |
| Layers | Layers(no) (in VBS 1 = layer 0): Visible, Name, MinZoom, MaxZoom |
| DataSet | Add "ad", değer, DataSet("ad").Value, Remove, RemoveAll, Count |
A value written as an object property is valid for the duration of the session; it is not written to the project file. If the property is bound to a tag, the binding wins. Logical properties (Visible, Enabled …) return a real Boolean. In event code (Run VBS code), the names Item, ScreenItems, Parent, Layers, DataSet are used directly.
Err
Number, Description, Source, Clear, Raise numara, kaynak, açıklama.
JavaScript object model
| Member | Description |
|---|---|
Tag.oku(ad) | Returns the current value; undefined if the tag does not exist. |
Tag.yaz(ad, değer) | Writes a value and returns a Promise; a rejected write is shown to the operator as an error window. |
Sayfa.ac(ad, [önek]) | Changes the main screen. |
Sayfa.geri() | Previous screen. |
Bildir(metin) | Shows an info window. |
Kullanici.ad | The name of the user in the session (empty if none). |
There are no other members: if you write a name that is not under Tag., Sayfa. or Kullanici., Studio warns about it during compilation.
Limitations and points to note
- Generating and acknowledging alarms and accessing archive and alarm logs are not available in any language (for calls that are defined in C and Python but do nothing, see the relevant topics).
- VBS, C and Python can change object properties; JavaScript cannot. Writing object properties is not supported in a 3D screen.
- The "Unsupported" tabs in the Reference panel give the current list of the calls that Studio warns about in advance.