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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

Dictionary Object<br />

The dictionary object is contained in the Scripting Type library and is a general-purpose data structure<br />

that is a cross between a link list and an array. The dictionary stores data and makes the data<br />

accessible from one variable. The advantages of a dictionary over an array are:<br />

• You can use “keys” to identify items in the dictionary. Keys are usually strings or integers but<br />

can be any data type other than an array or a dictionary. Keys must be unique.<br />

• Methods are provided to add new items and check <strong>for</strong> existing items in the dictionary<br />

• The dictionary size can be changed without calling the ReDim statement<br />

• Automatically “shifts up” the remaining items when any item in the dictionary is deleted<br />

You can use a Dictionary when you need to access random elements frequently or need to access<br />

in<strong>for</strong>mation contained in the array based on its value, not position.<br />

Dictionary<br />

Description Is an associative array that can store any type of data. Data is accessed by a key.<br />

Remarks Keys must be unique.<br />

Property CompareMode<br />

Description: Sets and returns the comparison mode <strong>for</strong> comparing a string keys in a<br />

Dictionary object.<br />

Arguments: Compare<br />

Optional. If provided, compare is a value representing the comparison mode.<br />

Values are:<br />

0 = Binary<br />

1 = Text<br />

2 = Database<br />

Values >2 can be used to refer to comparisons using specific Locale IDs<br />

(LCID)<br />

Return: Comparison mode<br />

Remarks: An error occurs if you try to change the comparison mode of a Dictionary object<br />

that already has data<br />

Use Object.CompareMode[ = compare]<br />

Example: Dim d<br />

Set d = CreateObject(“Scripting.Dictionary”)<br />

d.CompareMode = vbTextCompare<br />

d.Add “a”, “Chicago”<br />

d.Add “b”, “New York”<br />

d.Add “A” = “Austin” ‘ Method fails because “b” already exists<br />

Property Count<br />

Description: Returns the number of items pairs in a Dictionary object.<br />

Usage: Object.Count<br />

Arguments: None<br />

Return: Integer value of the count of item pairs in a Dictionary object.<br />

Remarks: Read Only.<br />

Example: Dim d, item_count<br />

Set d = CreateObject(“Scripting.Dictionary”)<br />

d.Add “a”, “Chicago”<br />

d.Add “b”, “New York”<br />

item_count = d.Count ‘ Count the items in a Dictionary object<br />

MsgBox item_count<br />

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

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

Saved successfully!

Ooh no, something went wrong!