Sign in to follow this  
Followers 0
milos83

Another Autoit bug - (NOT!)

16 posts in this topic

#1 ·  Posted (edited)

Now, before you start shouting "don't mix strings and numbers" you should know that this is returning FALSE but still act as its TRUE!
 
Reproducer:

$proxy = "string"
If $proxy = 0 Then ConsoleWrite("Its zero!" & @LF) ; says "Its zero!"

This will fix it:

$proxy = "string"
If $proxy == 0 Then ConsoleWrite("Its zero!" & @LF)
Edited by milos83
Amended title

Share this post


Link to post
Share on other sites



When comparing strings and numbers, an implicit call to the Number() function is performed on the string. Because the string $proxy doesn't start with, or contain, any numbers, the string is converted to a zero so that's why a string is equal to 0.

 

This has been discussed literally hundreds of times on this forum, this is not a bug, this is a user not doing the research necessary.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

The consolewrite will only return the proper value if you include parens:

$proxy = "string"
ConsoleWrite(($proxy = 0) & @LF)

output:

True


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

milos83, this is now the second thread where you have been chagrined, crying Wolf when it turns out to be a lack of understanding. Hopefully on future posts you will ask a question if you have concerns, rather than assuming you have found some bug that the rest of the forum overlooked


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

When comparing strings and numbers, an implicit call to the Number() function is performed on the string. Because the string $proxy doesn't start with, or contain, any numbers, the string is converted to a zero so that's why a string is equal to 0.

 

This has been discussed literally hundreds of times on this forum, this is not a bug, this is a user not doing the research necessary.

 

And if that's mentioned hundred of times, what does that tell you?

Ok. Now I know why is it happening, but that still doesn't render it logical.

If I ask is "john" = 0 I expect the real answer, and thats FALSE.

This is a scripting language and this is what should be expected.

For example,just as you mentioned,  it will ignore the variable type and it will let you compare 1 to "1", and that's great, this is a scripting and the users need that kind of simplicity. This is the beauty of Autoit.

So, the user is doing it right.

Don't take this as disrespect to great Autoit Developers and the community.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

milos83, this is now the second thread where you have been chagrined, crying Wolf when it turns out to be a lack of understanding. Hopefully on future posts you will ask a question if you have concerns, rather than assuming you have found some bug that the rest of the forum overlooked

 

I am using Autoit for 9 years now, and 99% of the stuff I needed, I searched on the forum. Very few post or questions.

But, what I have seen from wast of forum posts very often is the users like you with thousands of posts tend to be very frustrated persons.

Also check my other "crying" because I have done some mistype and wrong values. It is a bug.

 

Don't think I didn't search.

When I encountered this, first I have done is forum searched and found a post back in 4 years ago when Melba said "its a known bug",

I can solve that issue in many ways, and why do I bother reporting this?

You also need to learn have respect to the people who submit bug. They are doing it ONLY FOR THE GOOD OF AUTOIT.

Edited by milos83

Share this post


Link to post
Share on other sites

Not frustrated at all :) I simply see people who claim to have used "AutoIt for 9 years now", making serious blunders because they don't stop to research before they declare something a bug.

It was, in essence, a friendly suggestion, although it apparently struck a nerve. Nevertheless, if it causes you to pause a moment before declaring your next "bug", then mission accomplished :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

And if that's mentioned hundred of times, what does that tell you?

It tells me that hundreds of people can't read, or don't know how to search for the answer.

Ok. Now I know why is it happening, but that still doesn't render it logical.

Logical or not, that's how things work with the language you've chosen to use. I don't find it logical that some languages require a semicolon at the end of every statement, but if I want to use that language, I use the semicolon because that's how it was written to operate.

If I ask is "john" = 0 I expect the real answer, and thats FALSE.

This is a scripting language and this is what should be expected.

Not sure what difference it makes that AutoIt is a scripting language and what you expect.

I expect that, after reading the help file, that the above comes back as True, because I'm comparing a number and a string and the string will be converted using the Number() function as it says in the help file.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Logical or not, that's how things work with the language you've chosen to use. I don't find it logical that some languages require a semicolon at the end of every statement, but if I want to use that language, I use the semicolon because that's how it was written to operate.

 

This doesn't answer anything.

You do realize that the reason for you not understanding the semi column is a lack of knowledge?

The fact YOU accept things that you don't understand, doesnt mean that its the proper way or thinking.

But it does explain why you don't care about this issue.

Semicolon has its purpose. Has its logic behind it.

Whats the purpose of this?

Why would it allow me compare string to a number and it will do it right if its a number char in a string, but fail to do it right if it doesn't?

 

Edited by milos83

Share this post


Link to post
Share on other sites

Not frustrated at all :) I simply see people who claim to have used "AutoIt for 9 years now", making serious blunders because they don't stop to research before they declare something a bug.

It was, in essence, a friendly suggestion, although it apparently struck a nerve. Nevertheless, if it causes you to pause a moment before declaring your next "bug", then mission accomplished :)

Yeah the :) will make you friendly for sure.

 

The point of my claim "using AutoIt for 9 years now" is to tell you, how few times I have asked for anyone's time.

As I said, this post was solely with a purpose of helping.

Sorry I asked.

Share this post


Link to post
Share on other sites

Why would it allow me compare string to a number and it will do it right if its a number char in a string, but fail to do it right if it doesn't?

 

So what is the "right" way from your point of view?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

So what is the "right" way from your point of view?

 

"john" = 0 must return false by no means.

Cant even believe we are arguing about this.

Whats your point of view?

Edited by milos83

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

milos83,

Comparing strings and numbers will always end in tears. Use the == operator to compare strings; use the = operator to compare numbers. Simple. ;)

As AutoIt is untyped (which is one of the "easy" things about it for new users) it is up to the user to make sure that both sides of a comparison match. If you get an answer that you find strange (as in fact I just have done in a script on which I am currently working) then look at the datatypes on both sides and ensure that they are the same - I needed to Number a returned SciTE property. It is the price we have to pay for having untyped variables - and if you pay attention it does not bite you very often, and you can quickly deal with it when it does. :)

You will notice that your thread now has an adjusted titles - please refrain in future from crying "bug" until you confirm it is indeed a bug and not just your misunderstanding of the language. ;)

 

this post was solely with a purpose of helping

M23

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

milos83,

Comparing strings and numbers will always end in tears. Use the == operator to compare strings; use the = operator to compare numbers. Simple. ;)

As AutoIt is untyped (which is one of the "easy" things about it for new users) it is up to the user to make sure that both sides of a comparison match. If you get an answer that you find strange (as in fact I just have done in a script on which I am currently working) then look at the datatypes on both sides and ensure that they are the same - I needed to Number a returned SciTE property. It is the price we have to pay for having untyped variables - and if you pay attention it does not bite you very often, and you can quickly deal with it when it does. :)

You will notice that your 2 threads now have adjusted titles - please refrain in future from crying "bug" until you confirm it is indeed a bug and not just your misunderstanding of the language. ;)

 

M23

 

Hi Melba,

I wouldn't post this if I wasn't 100% assured its a bug.

As you can see yourself. The other post is truly a bug.

Now, before you start shouting "don't mix strings and numbers" you should know that this is returning FALSE but still act as its TRUE!

 

Thank you Melba for your time, but what you said is just a way to solve the issue, and it isn't the answer to why its this way.

 

Anyway, I am done with this issue.

Thank you all for your time and thanks for Autoit.

Edited by milos83

Share this post


Link to post
Share on other sites

milos83,

 

I wouldn't post this if I wasn't 100% assured its a bug

But it 100% is NOT a bug! However, I too am done with this issue as talking to brick walls is not something I enjoy. :bye:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0