Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Set - statement of language VBScript

Description:
Assigns an object reference to a variable (or to an object property).
Syntax:

Set objectvar = {objectexpression | Nothing}

 
objectvar Name of the variable or property; follows standard variable naming conventions.
objectexpression 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 when 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 data type.
 
The Dim or ReDim statements only declare a variable that refers to an 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 Dim and Set commands are not used.
 
For similar purpose in the JavaScript language is used the command var.
See also:
Example:
Dim oTemperature
Set oTemperature = pMe.Pm("/Data/#vars/Temperature")
Pm.Debug "Temperature =" & oTemperature.Value
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice