VBScript Reference Manual for InduSoft Web Studio
VBScript Reference Manual for InduSoft Web Studio
VBScript Reference Manual for InduSoft Web Studio
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />
Array Functions & Statements<br />
Array Functions Description<br />
Array Returns a variant containing an array<br />
Dim Declares variables and allocates storage space<br />
Erase Reinitializes the elements of fixed-size arrays, deallocates dynamic-array storage space.<br />
Filter Returns a zero-based array that contains a subset of a string array based on a filter criteria<br />
IsArray Returns a Boolean value that indicates whether a specified variable is an array<br />
Join Returns a string that consists of a number of substrings in an array<br />
LBound Returns the smallest subscript <strong>for</strong> the indicated dimension of an array<br />
ReDim Declare dynamic array variables, allocates or reallocates storage space at procedural level<br />
Split Returns a zero-based, one-dimensional array that contains a specified number of substrings<br />
UBound Returns the largest subscript <strong>for</strong> the indicated dimension of an array<br />
Examples using these array functions are:<br />
Dim MyArray(3), MyString, VarArray(), MyIndex, littleArray<br />
MyArray(0) = “President ”<br />
MyArray(1) = “George ”<br />
MyArray(2) = “W. ”<br />
MyArray(3) = “Bush”<br />
MyString = Join(MyArray) ‘ MyString equals “President George W. Bush”<br />
MyString = “HelloxWidexWorld”<br />
MyArray = Split (MyString, “x”, -1,1) ‘ MyArray(0) contains “Hello”<br />
‘ MyArray(1) contains “Wide”<br />
‘ MyArray(2) contains “World”<br />
MyIndex = Filter(MyArray, “W. “) ‘ MyIndex will equal 2<br />
ReDim VarArray(10) ‘ Redimension the VarArray array<br />
ReDim VarArray(20) ‘ Redimension the VarArray array<br />
VarArray(19) = 19<br />
VarArray(20) = 20<br />
littleArray = Array(12.3.64, 15) ‘ Populate the array with the Array function<br />
Erase VarArray ‘ Deallocates memory <strong>for</strong> the dynamic array<br />
Erase MyArray ‘ Simply erases the fixed size array<br />
Key Notes:<br />
• <strong>VBScript</strong> Array indices always start with 0. This is not the case with VBA.<br />
• An array MyArray(2) has 3 elements, with indices 0, 1, and 2.<br />
• Multi-dimensional arrays are supported up to 60 dimensions.<br />
• Dim MyArray() is a dynamic array, and must be sized later with the ReDim statement .<br />
• The Preserve keyword will preserve existing elements in a dynamic array<br />
• Erase function deallocates memory <strong>for</strong> dynamic arrays, only clears fixed size arrays<br />
Boolean Variables<br />
Boolean variables have one of two values; True or False. The <strong>VBScript</strong> Keywords True or False can<br />
be used to assign a value to the boolean variable. A boolean False is stored as a 0, but the boolean<br />
True is not stored as a 1. Since the data storage element <strong>for</strong> the boolean value is a signed 32-bit value,<br />
a boolean True will have all bits in the 32-bit value set to 1, which is a negative signed integer value of -<br />
1. It is best to work with the boolean values True or False when working with boolean variables.<br />
<strong>InduSoft</strong>, Ltd. 67