rbhkamal Posted August 4, 2009 Share Posted August 4, 2009 Is this a bug? Local $array[1] = ["KUKU"] Local $emptyString = "" If $array == $emptyString Then ConsoleWrite( "$array == $emptyString " & @CRLF ) EndIf Output: >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\###\Desktop\tmp.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>13:39:11 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3 CPU:X86 ANSI) >Running AU3Check (1.54.14.0) from:C:\Program Files\AutoIt3 +>13:39:11 AU3Check ended.rc:0 >Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\###\Desktop\tmp.au3" $array == $emptyString +>13:39:11 AutoIT3.exe ended.rc:0 +>13:39:12 AutoIt3Wrapper Finished >Exit code: 0 Time: 1.985 Thanks "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
picaxe Posted August 4, 2009 Share Posted August 4, 2009 Is this a bug?No, the compare should beIf $array[0] == $emptyString Thena previously undeclared var such as $array will have a null string value. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2009 Moderators Share Posted August 4, 2009 rbhkamal, As someone with your number of posts should know, you must use an index when referring to array elements: Local $array[1] = ["KUKU"] Local $emptyString = "" If $array[0] == $emptyString Then ConsoleWrite( "$array == $emptyString " & @CRLF ) Else ConsoleWrite( "$array <> $emptyString " & @CRLF ) EndIf M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
rbhkamal Posted August 4, 2009 Author Share Posted August 4, 2009 (edited) Thanks everyone.... but you jumped into a conclusion too quickly. My point is that an array should NOT be equal to a non-array variable. In my case, I have a function that returns an array on success and empty string on failure. I was checking for errors using $returnValue == "" but that was always true. The workaround was to use isArray($returnValue), which is perfectly fine. But is AutoIt supposed to behave this way? Edited August 4, 2009 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 4, 2009 Moderators Share Posted August 4, 2009 rbhkamal,you jumped into a conclusion too quicklyThen make your question clear in your post and we will not waste our time answering stupid posts. >_< Is the function in question one of your own functions or a built-in AutoIt function?If the former, rewrite your function to set @error for a failure return.If the latter, read the Help file to see if @error is set for a failure return - which it almost certainly will be. If it is not, then think about a bug report.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
picaxe Posted August 4, 2009 Share Posted August 4, 2009 Thanks everyone.... but you jumped into a conclusion too quickly. My point is that an array should NOT be equal to a non-array variable.In my case, I have a function that returns an array on success and empty string on failure.Perhaps a better example would have drawn a better conclusion. Link to comment Share on other sites More sharing options...
rbhkamal Posted August 4, 2009 Author Share Posted August 4, 2009 rbhkamal, Then make your question clear in your post and we will not waste our time answering stupid posts. >_< Is the function in question one of your own functions or a built-in AutoIt function? If the former, rewrite your function to set @error for a failure return. If the latter, read the Help file to see if @error is set for a failure return - which it almost certainly will be. If it is not, then think about a bug report. M23 Don't be angry.... relax. Its a very simple question. Should the following be true of false? [ '', '', '' ] == '' I think it should return false, but autoIt return True, the content of the array is irrelevant. Is this a bug? "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 4, 2009 Share Posted August 4, 2009 Thanks everyone.... but you jumped into a conclusion too quickly. My point is that an array should NOT be equal to a non-array variable. In my case, I have a function that returns an array on success and empty string on failure. I was checking for errors using $returnValue == "" but that was always true. The workaround was to use isArray($returnValue), which is perfectly fine. But is AutoIt supposed to behave this way? Yes, that's exactly how it is supposed to work. So is this: $a = 0 $b = "xyz" If $a = $b Then ConsoleWrite("True" & @LF) Else ConsoleWrite("False" & @LF) EndIf AutoIt does some automatic variable type translation for you, but this has consequences. The lesson is to be aware of variable types and especially cautious comparing different types. >_< Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
rbhkamal Posted August 4, 2009 Author Share Posted August 4, 2009 So autoIt converts my array into an empty string and then does the comparison? "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
trancexx Posted August 4, 2009 Share Posted August 4, 2009 So autoIt converts my array into an empty string and then does the comparison?Because you use == operator AutoIt does String(left side), then String(right side) and then compare. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
rbhkamal Posted August 4, 2009 Author Share Posted August 4, 2009 Because you use == operator AutoIt does String(left side), then String(right side) and then compare. I see. Thanks! "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
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