Hey Guyz,

Came to know about this cute little secret of Dictionary and thought
of sharing with everyone ( It could be the case that you will be
knowing it before hand, so in that case please bear with me )

Problem Statement :
Wanted to check whether I've already created a dictionary object with
the same name and if yes then delete the previous one to create a new
one.

Hindrance Encountered :
We have .exists method for a dictionary object to check for a key
inside we doesn't provide any method per-se specifically to check for
a object to be already a dictionary object. We can check for a name to
be objcet using IsObject ( objName )


Amusing Thing :
What i encountered is on creating  a dictionary with a same name with
which a dictionary is already present actually doesn;t throw any error
and hence allows the developer to run ( yes, this make the initial
data to get lost which is actually a cause for concern, hence be
careful ).
Eg:-

        Set AFDict = CreateObject("Scripting.dictionary")
        AFDict .Add "1", "wew wew"
        AFDict .Add "2", "wew wew"

        If IsObject(AFDict ) then
                msgbox "Yes"
        End if
        msgbox AFDict.Count

        Set AFDict = CreateObject("Scripting.dictionary")
        msgbox AFDict.Count

First msgbox will show '2' but second msgbox will show '0'.


Cheers ...

-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to