What is the role of ASP in Scripting.Dictionary objects?

Source: Internet
Author: User
Objects <br>
<b>5.3 scripting.dictionary</b><b> Objects </b><br>
Many Microsoft programming languages, such as Visual Basic, VBScript, and JScript, provide collections (collection). You can think of a set as an array, and you can use the built-in functions to accomplish basic tasks such as storing and manipulating data. There is no need to worry about the ranks of the data, but access using unique keys. <br>
Both VBScript and JScript provide similar objects, commonly known as scripting.dictionary objects or Dictionary objects. It is similar to a two-dimensional array, where the data for the key and related entries are stored together. However, the real object-oriented approach should not directly access data entries, it must be implemented using the methods and properties supported by the Dictionary object. <br>
This chapter provides sample pages that allow you to test the methods and properties of the script Runtime object. These instances are in the CHAPER05 subdirectory of the file of the downloaded file. <br>
<br>
<b>5.3.1 </b><b> Create and use dictionary</b><b> objects </b><br>
Create an example of a Dictionary object such as the next:<br>
' In vbscript:<br>
Dim objmydata<br>
Set objmydata = Server.CreateObject ("scripting.dictionary") <br>
<br>
In jscript:<br>
var objmydata = Server.CreateObject (' scripting.dictionary ');<br>
<br>
<!--server-side with an OBJECT element--><br>
<object runat= "SERVER" scope= "PAGE" id= "Objmydata" <br>
Progid= "Scripting.Dictionary" ><br>
</OBJECT><br>
The Dictionary object can also be used in the client's ie. <br>
1. Dictionary The members of the object <br>
Table 5-2 and Table 5-3 list the properties and methods of the Dictionary object and the corresponding description. <br>
An error occurs when a key/entry pair is added, if the key already exists, or when a key/entry pair is deleted, the keyword/entry pair does not exist, or the CompareMode of the Dictionary object that already contains the data is changed. <br>
Table 5-2 Properties and descriptions of Dictionary objects <table Class=ubb cellspacing=0><tr><td class=ubb><br>
Property </td><td class=ubb><br>
Description &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
COMPAREMODE&LT;/TD&GT;&LT;TD class=ubb><br>
(VBScript only) Sets or returns the string comparison mode for a key &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
COUNT&LT;/TD&GT;&LT;TD class=ubb><br>
Read-only. Returns the number of key/entry pairs in dictionary </td></tr><tr><td class=ubb><br>
Item (<i>key</i>) </td><td class=ubb><br>
Sets or returns the entry value of the specified key &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
Key (<i>key</i>) </td><td class=ubb><br>
Set key value </td></tr></table><br>
Table 5-3 methods and descriptions of Dictionary objects <table Class=ubb cellspacing=0><tr><td class=ubb><br>
Method </td><td class=ubb><br>
Description &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
ADD (<i>key,item</i>) </td><td class=ubb><br>
Add key/entry pairs to DICTIONARY&LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
Exists (<i>key</i>) </td><td class=ubb><br>
Returns true if the specified key exists, otherwise returns FALSE&LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
Items () </td><td class=ubb><br>
Returns an array containing all the entries in the Dictionary object </td></tr><tr><td class=ubb><br>
Keys () </td><td class=ubb><br>
Returns an array containing all the keys in the Dictionary object </td></tr><tr><td class=ubb><br>
Remove (<i>key</i>) </td><td class=ubb><br>
Deletes a specified key/entry for &LT;/TD&GT;&LT;/TR&GT;&LT;TR&GT;&LT;TD class=ubb><br>
RemoveAll () </td><td class=ubb><br>
Delete all keys/entries to </td></tr></table><br>
2. Add and delete entries in dictionary <br>
Once you get a new (empty) Dictionary, you can add entries to it, get entries from it, and delete entries:<br>
' In vbscript:<br>
Objmydata.add "MyKey", "myitem" ' Add Value myitem with key mykey&l



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.