TheAutomator Posted February 22, 2015 Posted February 22, 2015 (edited) Can someone please say me what i'm missing here? this little problem is driving me crazy! i feel so stupid that i have to ask this but why does this script thinks that "=" doesn't exist inside the dictionary? $regex = ObjCreate("VBScript.RegExp") $regex.Pattern = "=" $regex.Global = True $regex.IgnoreCase = True $test = ObjCreate("scripting.dictionary") $test.add("=", 2) $sentence = "=" Local $find = $regex.execute($sentence) for $part in $find msgbox(0,1,$part.Value) MsgBox(0,2,$part.Value = "=") MsgBox(0,3,$test.exists("=")) msgbox(0,4,$test.exists($part)) ;this should be true! next Thanks for any help TheAutomator. Edited February 22, 2015 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone MiniMark Editor
Solution SadBunny Posted February 22, 2015 Solution Posted February 22, 2015 (edited) $part is not the thing that equals "=", $part.Value is. MsgBox(0, 4, $test.exists($part.Value)) ;this should be true! Edited February 22, 2015 by SadBunny TheAutomator 1 Roses are FF0000, violets are 0000FF... All my base are belong to you.
TheAutomator Posted February 22, 2015 Author Posted February 22, 2015 $part is not the thing that equals "=", $part.Value is. MsgBox(0, 4, $test.exists($part.Value)) ;this should be true! Ow, i see i thought "$part" only would work to. i'm so confused right now because i was testing it in vbscript in the meantime and have a look at this: Set regex = New RegExp regex.Pattern = "=" regex.Global = True regex.IgnoreCase = True set test = createobject("scripting.dictionary") test.add "=", 2 sentence = "=" set find = regex.execute(sentence) for each part in find msgbox part msgbox test.exists(part) next here "part" really equals "=" why isn't this working then? TheAutomator. Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone MiniMark Editor
SadBunny Posted February 22, 2015 Posted February 22, 2015 I'm not 100% sure about COM object handling in AutoIt, but I guess the problem is that AutoIt has no way to know what field or method to call from the generic COM object to get the toString value. VBScript is quite a different language. Object oriented, for one. In this case, the RegExp.execute() method returns an object of the type MatchCollection which then your iterator "part" goes through. I guess there is auto-invocation of the .Value getter/field (don't know how that works in VBscript, never used it) when you access it as a string. I.e. it works not because part equals "=", but because the string auto-invoked string representation equals "=". Note that this is mostly guesswork, mostly based on the example this link: http://www.regular-expressions.info/vb.html TheAutomator 1 Roses are FF0000, violets are 0000FF... All my base are belong to you.
TheAutomator Posted February 22, 2015 Author Posted February 22, 2015 SadBunny, Thanks for the information, i found out (in vbscript) you have to type ".value" after it to let it work but "part" itself still is a string containing "=".. regards TheAutomator. Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone MiniMark Editor
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now