Promotic

Set - statement of language VBScript

Description:
Assignment of an object reference into the variable (or to an object property).
Syntax:

Set objectvar = {object_expression | Nothing}

objectvar Name of the variable or of the property; follows standard variable naming conventions.
object_expression expression consisting of the name of an object, another declared variable of the same object type, or a function or method that returns an object of the same object type
Nothing Discontinues association of objectvar with any specific object. Assigning objectvar to Nothing releases all the system and memory resources associated with the previously referenced object if no other variable refers to it.
Note:
In order to have the object_variable valid, the referred object type must correspond with the variable object type. After assigned, the variable will be of the Object type.

The Dim or ReDim statements only declare a variable that refers to the object. No actual object is referred to until you use the Set statement to assign a specific object.

Generally, when you use Set to assign an object reference to a variable, no copy of the object is created for that variable. Instead, a reference to the object is created. More than one object variable can refer to the same object. Because these variables are references to (rather than copies of) the object, any change in the object is reflected in all variables that refer to it.

In the PROMOTIC system scripts, it is possible to create a variable also by the #pragma variable directive, that allows to create a varible with special predefined value (e.g. object referrence, text in current language, etc.). For a varible created such way the statement Dim and Set are not used.

For similar purpose in the JavaScript language is used the statement var.
See also:
Example:
VBScriptSelect and copy to clipboard

Dim oTemperature
Set oTemperature = pMe.Pm("/Data/#vars/Temperature")
Pm.Debug "Temperature=" & oTemperature.Value
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.