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>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

<strong>VBScript</strong> Naming Rules and Conventions<br />

<strong>VBScript</strong> has some simple standard rules that apply to all <strong>VBScript</strong> variable names. These are:<br />

• Must begin with an alpha character (A...Z)<br />

• After the first character, they can contain letters, digits and underscores. No other embedded<br />

characters are permissible.<br />

• Must be less than 255 characters in length<br />

• Must be unique in the scope in which they are declared<br />

• Cannot use names that are Keywords<br />

Permissible Not permissible<br />

a class.item<br />

b2 +a<br />

c_34_ @Test123<br />

Microsoft recommends following a naming convention <strong>for</strong> variables, based on their data type. The<br />

variable name would contain a prefix, signifying its data type. Microsoft used the vb prefix <strong>for</strong> <strong>VBScript</strong><br />

defined constants, and it is recommended to avoid using these prefixes with variables. The Microsoft<br />

recommended prefixes <strong>for</strong> programmer defined variables and constants are:<br />

Microsoft Suggested Naming Convention <strong>for</strong> Variables<br />

Data Subtype Prefix Example<br />

Boolean bln blnFound<br />

Byte byt bytRasterData<br />

Currency cur curTotal<br />

Date/Time dtm dtmStart<br />

Double dbl dblTolerance<br />

Error err errOrderNum<br />

Integer int intQuantity<br />

Long lng lngDistance<br />

Object obj objCurrent<br />

Single sng sngAverage<br />

String str strFirstName<br />

Variant Var varNumber<br />

The Microsoft suggested naming convention are part of the “Hungarian Notation Standard” prefixes,<br />

developed by Microsoft in 1972. Although many of the other prefixes are <strong>for</strong> C++ programmers, there<br />

are a couple other Hungarian Notation prefixes that might be useful:<br />

Additional Hungarian Notation Prefixes<br />

Use Prefix Example<br />

Pointer p pIndex<br />

Class c cObject<br />

Float f fCalc<br />

Nested Class X X<br />

Key Notes:<br />

• Good programming would suggest that variable names are descriptive<br />

• While <strong>VBScript</strong> variable names are not case sensitive, the name of an ActiveX control<br />

inserted by IWS is case sensitive when referenced from a <strong>VBScript</strong> code segment.<br />

• Most <strong>VBScript</strong> naming rules can be overridden by enclosing the name in brackets. For<br />

example, [@a.1] would be a valid <strong>VBScript</strong> name.<br />

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

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

Saved successfully!

Ooh no, something went wrong!