DOC PREVIEW
GT AE 6382 - Dictionary Object

This preview shows page 1-2-3-4-5-6-7-8-9-10-11-12-82-83-84-85-86-87-88-89-90-91-92-165-166-167-168-169-170-171-172-173-174-175-176 out of 176 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 176 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Dictionary Object Object that stores data key, item pairs. Remarks A Dictionary object is the equivalent of a PERL associative array. Items can be any form of data, and are stored in the array. Each item is associated with a unique key. The key is used to retrieve an individual item and is usually a integer or a string, but can be anything except an array. The following code illustrates how to create a Dictionary object: [JScript] var y = new ActiveXObject("Scripting.Dictionary"); y.add ("a", "test"); if (y.Exists("a")) document.write("true"); ... [VBScript] Dim d ' Create a variable. Set d = CreateObject("Scripting.Dictionary") d.Add "a", "Athens" ' Add some keys and items. d.Add "b", "Belgrade" d.Add "c", "Cairo" ... Methods Add Method (Dictionary) | Exists Method | Items Method | Keys Method | Remove Method | RemoveAll Method Properties Count Property | Item Property | Key Property See Also Scripting Runtime Library Page 1 of 176Dictionary Object9/3/2003file://C:\Documents%20and%20Settings\latham\Local%20Settings\Temp\~hhBBE7.htmFileSystemObject Object | TextStream Object © 2001 Microsoft Corporation. All rights reserved. Build: Topic Version 5.6.9309.1546 Count Property Returns the number of items in a collection or Dictionary object. Read-only. object.Count The object is always the name of one of the items in the Applies To list. Remarks The following code illustrates use of the Count property: [JScript] function CountDemo() { var a, d, i, s; // Create some variables. d = new ActiveXObject("Scripting.Dictionary"); d.Add ("a", "Athens"); // Add some keys and items. d.Add ("b", "Belgrade"); d.Add ("c", "Cairo"); a = (new VBArray(d.Keys())); // Get the keys. s = ""; for (i = 0; i < d.Count; i++) //Iterate the dictionary. { s += a.getItem(i) + " - " + d(a.getItem(i)) + "<br>"; } return(s); // Return the results. Scripting Runtime Library Page 2 of 176Dictionary Object9/3/2003file://C:\Documents%20and%20Settings\latham\Local%20Settings\Temp\~hhBBE7.htm} [VBScript] Function ShowKeys Dim a, d, i, s ' Create some variables. Set d = CreateObject("Scripting.Dictionary") d.Add "a", "Athens" ' Add some keys and items. d.Add "b", "Belgrade" d.Add "c", "Cairo" a = d.Keys ' Get the keys. For i = 0 To d.Count -1 ' Iterate the array. s = s & a(i) & "<BR>" ' Create return string. Next ShowKeys = s End Function See Also CompareMode Property | Item Property | Key Property Applies To: Dictionary Object | Drives Collection | Files Collection | Folders Collection © 2001 Microsoft Corporation. All rights reserved. Build: Topic Version 5.6.9309.1546 Item Property Sets or returns an item for a specified key in a Dictionary object. For collections, returns an item based on the specified key. Read/write. object.Item(key)[ = newitem] Arguments Scripting Runtime Library Page 3 of 176Dictionary Object9/3/2003file://C:\Documents%20and%20Settings\latham\Local%20Settings\Temp\~hhBBE7.htmobject Required. Always the name of a collection or Dictionary object. key Required. Key associated with the item being retrieved or added. newitem Optional. Used for Dictionary object only; no application for collections. If provided, newitem is the new value associated with the specified key. Remarks If key is not found when changing an item, a new key is created with the specified newitem. If key is not found when attempting to return an existing item, a new key is created and its corresponding item is left empty. The following example illustrates the use of the Item property. [JScript] function DicTest(keyword) { var a, d; d = new ActiveXObject("Scripting.Dictionary"); d.Add("a", "Athens"); d.Add("b", "Belgrade"); d.Add("c", "Cairo"); a = d.Item(keyword); return(a); } [VBScript] Function ItemDemo Dim d ' Create some variables. Set d = CreateObject("Scripting.Dictionary") d.Add "a", "Athens" ' Add some keys and items. d.Add "b", "Belgrade" d.Add "c", "Cairo" ItemDemo = d.Item("c") ' Get the item. End Function See Also CompareMode Property | Count Property | Key Property Page 4 of 176Dictionary Object9/3/2003file://C:\Documents%20and%20Settings\latham\Local%20Settings\Temp\~hhBBE7.htmApplies To: Dictionary Object | Drives Collection | Files Collection | Folders Collection © 2001 Microsoft Corporation. All rights reserved. Build: Topic Version 5.6.9309.1546 Key Property Sets a key in a Dictionary object. object.Key(key) = newkey Arguments object Required. Always the name of a Dictionary object. key Required. Key value being changed. newkey Required. New value that replaces the specified key. Remarks If key is not found when changing a key, a new key is created and its associated item is left empty. The following example illustrates the use of the Key property: [JScript] var d; d = new ActiveXObject("Scripting.Dictionary"); Scripting Runtime Library Page 5 of 176Dictionary Object9/3/2003file://C:\Documents%20and%20Settings\latham\Local%20Settings\Temp\~hhBBE7.htmfunction AddStuff() { var a; d.Add("a", "Athens"); d.Add("b", "Belgrade"); d.Add("c", "Cairo"); } function ChangeKey(oldkey, newkey) { var s; d.Key("c") = "Ca"; s = "Key " + oldkey + " changed to " + newkey; return(s); } [VBScript] Function DicDemo Dim d ' Create some variables. Set d = CreateObject("Scripting.Dictionary") d.Add "a", "Athens" ' Add some keys and items. d.Add "b", "Belgrade" d.Add "c", "Cairo" d.Key("c") = "d" ' Set key for "c" to "d". DicDemo = d.Item("d") ' Return associate item. End Function See Also CompareMode Property | Count Property | Item Property Applies To: Dictionary Object © 2001 Microsoft Corporation. All rights reserved. Build: Topic Version 5.6.9309.1546 Scripting Runtime Library Page 6 of 176Dictionary Object9/3/2003file://C:\Documents%20and%20Settings\latham\Local%20Settings\Temp\~hhBBE7.htmAdd Method (Dictionary) Adds a key and item pair to a Dictionary object. object.Add (key, item) Arguments object Required. Always the name of a Dictionary object. key Required. The key associated with the item being added. item Required. The item associated with the key being added. Remarks An error occurs if the key already exists. The following example illustrates the use of the Add method. [JScript] var d; d = new ActiveXObject("Scripting.Dictionary"); d.Add("a", "Athens");


View Full Document

GT AE 6382 - Dictionary Object

Download Dictionary Object
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Dictionary Object and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Dictionary Object 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?