Jump to content

Recommended Posts

Posted

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

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted (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 by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

  • Moderators
Posted

rbhkamal,

you jumped into a conclusion too quickly

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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.
Posted

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

Posted

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
Posted

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

Posted

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

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...