Dictionary Object




Dictionary Object in VBScript

Dictionary Object

It is used to define Key, value pairs

VBScript            Perl Script
-----------------------------------------------------
Scalar                       Scalar
Array                        Array
DictionaryObject        Associated Array / hash

----------------------------------
Array            Associated Array
----------------------------------
Dim a(3)
a(0) = "India"
a(1) = 10
a(2) = 20
a(3) = #10/10/2010#

Keys    Values

Create Dictionary Object

Set Variable = CreateObject("Scripting.Dictionary")

----------------------------------------------
'Example:

 
Dim objDictionary
Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Agent", "Hyderabad"
objDictionary.Add "Password", "mercury"
objDictionary.Add 1, 100
objDictionary.Add "*", "abcd"
objDictionary.Add "d", #10/10/2010#

Msgbox objDictionary.Count '5

Msgbox objDictionary.Exists("*") 'True
Msgbox objDictionary.Exists("a") 'false

objDictionary.Remove("d")
Msgbox objDictionary.Count '4

objDictionary.RemoveAll
Msgbox objDictionary.Count '0
----------------------------------------------
SystemUtil.Run objDictionary("AppPath")
Dialog("Login").Activate 

Dialog("Login").WinEdit("Agent Name:").Set objDictionary("Agent")
Dialog("Login").WinEdit("Password:").Set objDictionary("Password")
wait 2
Dialog("Login").WinButton("OK").Click
 

0 comments:

Post a Comment