Spiff59 Posted January 27, 2009 Posted January 27, 2009 (edited) I couldn't find any posts regarding this, and there's nothing under "Language Reference - Operators" Test(1,3,0,5) ;------------------------------------------------- Func Test($a="",$b="",$c="",$d="",$e="",$f="") Local $Parms[7] = [0, $a,$b,$c,$d,$e,$f] For $i = 1 to 6 If $Parms[$i] = "" Then ExitLoop $Parms[0] += 1 Next MsgBox(1,"","Parms = " & $Parms[0]) $Parms[0] = 0 For $i = 1 to 6 If $Parms[$i] == "" Then ExitLoop $Parms[0] += 1 Next MsgBox(1,"","Parms = " & $Parms[0]) EndFunc;------------------------------------------ (There are more differences between the "=" and "==" operators than just case sensitivity) Edited January 27, 2009 by Spiff59
BrettF Posted January 27, 2009 Posted January 27, 2009 (edited) Think of 0 being false. Which in a sense is also null. And since Autoit doesn't have data types, I kinda expect this... And now comes a question, what is the outcome for this? Its obvious you are working on something, and well knowing the outcome can provide base for solutions... I could think of a few ways for a few different things, but I'm not sure how well they would go exactly...EDIT:A better way to explain what AutoIt perceives as true of false is like so:Basically anything that is 0 or a blank string is false. True is everything else.So we can do the following:$d = 0 If $d = False Then MsgBox (0, "$d = 0", "$d is false!") EndIf $d = "" If $d = False Then MsgBox (0, "$d = """"", "$d is false!") EndIfAnd they are both false...Since If <EXP> Then is looking for something true, it will work (because 0 and "" are false...)If we use == then it is case sensitive where it will look for whether they are both the same.This is very complicated for me to explain P.S- I may be wrong, and if I am, can one of you more knowledgeable peeps tell me Cheers,Brett Edited January 27, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
ivan Posted January 27, 2009 Posted January 27, 2009 You are correct in the documentation. You are comparing to a string, so perhaps you should cast your parameters as strings. Test(1, 3, 0, 5) ;------------------------------------------------- Func Test($a = "", $b = "", $c = "", $d = "", $e = "", $f = "") Local $Parms[7] = [0, String($a), String($b), String($c), String($d), String($e), String($f)] For $i = 1 To 6 If $Parms[$i] = "" Then ExitLoop $Parms[0] += 1 Next MsgBox(1, "", "Parms = " & $Parms[0]) $Parms[0] = 0 For $i = 1 To 6 If $Parms[$i] == "" Then ExitLoop $Parms[0] += 1 Next MsgBox(1, "", "Parms = " & $Parms[0]) EndFunc ;==>Test Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3
Spiff59 Posted January 27, 2009 Author Posted January 27, 2009 (edited) I understand exactly what is taking place, and understand the reasoning behind it. Minus seperate string and numeric data types, the behavior of the "=" operator in boolean compares is required. It is also valuable, when necessary, to be able to determine between an ASCII "0" and a null-string. My point is that, being useful, this behavior of the "==" operator ought to be mentioned in the documentation. EDIT: Technically, I guess I should be trying to fight my way through the 'ticket' system and request someone update the docs, rather than posting here. Edited January 27, 2009 by Spiff59
BrettF Posted January 27, 2009 Posted January 27, 2009 Well wait for a Dev to pop their head in, and if they give the okay, make a feature request Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
ivan Posted January 27, 2009 Posted January 27, 2009 I posted what seemed to me a viable solution to the problem, though it's good to have a ref. IVAN Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3
Spiff59 Posted January 27, 2009 Author Posted January 27, 2009 I posted what seemed to me a viable solution to the problem, though it's good to have a ref.IVANActually, I didn't have a problem, I prefer to pass a variable number of parameters in numeric format to the function. The loop using "==" works perfectly for me. I was just surprised that I had happened upon a currently undocumented difference between the two operators (= and ==).
ivan Posted January 27, 2009 Posted January 27, 2009 As mentioned, I agree with need for improved documentation Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3
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