18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

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 />

To create an explicit constant, you use the keyword Const. You cannot use a function or another<br />

constant as part of the explicit value. You cannot use an expression with a <strong>VBScript</strong> Operator. For<br />

example:<br />

Const Threshold = 101.5 ‘ Explicit constant Threshold has a value of 101.5<br />

Const MyColor = &hFFFF ‘ assigns a color constant to MyColor<br />

Const CrLf = Chr(13) & Chr(10) ‘ Not allowed to use a function<br />

Const MyVal = 2 + 4 ‘ Not allowed to have an operator in assignment<br />

String literals are enclosed in double quotation marks (“), while date and time literals are enclosed in<br />

hashes (#). For example:<br />

Const MyString = “Hello World”<br />

Const StartDate = #4-1-2006#<br />

After creating the constant, you can use the constant name in lieu of specifying an explicit value. For<br />

example:<br />

Dim Alarm1, Alarm2<br />

Const Threshold = 101.5 ‘ Create a constant, value = 101.5<br />

Alarm1 = Threshold ‘ Assigns the constant to the variable Alarm1<br />

Alarm2 = Threshold + 5 ‘ Adds 5 to the constant and assigns to Alarm2<br />

Key Notes:<br />

• Use the following <strong>for</strong>mats to assign constant values<br />

Const MyVal = &hFFFF to assign a hexadecimal value<br />

Const MyVal = "Hello" to assign a string value<br />

Const MyVal = “He was “”lost””” to embed quotation marks<br />

Const MyVal = #9-11-2001# to assign a date and time literal<br />

• Use the same naming rules <strong>for</strong> variables as <strong>for</strong> constants<br />

• Can’t use functions or operators in the assignment statement<br />

<strong>InduSoft</strong>, Ltd. 85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!