sksbir Posted January 18, 2006 Share Posted January 18, 2006 (edited) Try this littre script: msgbox(0,"test0","1=0 --> " & 1=0) msgbox(0,"test1","1=0 --> " & (1=0) ) ; EXPECTED : 1=0 --> 0 .... Test 0 fail : Shouldn't contatenation be evaluated after comparison tests ? Today, I have to use parenthesis to get it working like : see test 1 Using Autoit 3.1.1.0 [edit] I now understand what is happening : first, autoit evaluates "1=0 --> " & 1 then compare "1=0 --> 1" = 0 so result is 0 Edited January 18, 2006 by sksbir Link to comment Share on other sites More sharing options...
LoWang Posted August 14, 2015 Share Posted August 14, 2015 (edited) Nobody answered this and yes after 9years I am confused by this strange behavior as well...$str="something" if not $str="somethingelse" then dosomething()does nothing. What is the reason for such strange behavior in autoit? This leads to unnecessary errors and prolongs development time when you have to debug it. Or is there any reason one would want to negate string with not $str? Edited August 14, 2015 by LoWang Link to comment Share on other sites More sharing options...
Danyfirex Posted August 14, 2015 Share Posted August 14, 2015 By default autoit evaluation return bool type. it you want number just use int. Please Don't revive old topic. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
jchd Posted August 14, 2015 Share Posted August 14, 2015 What is the reason for such strange behavior in autoit?This results from the priority of operators. See help file under "Operators". 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted August 14, 2015 Moderators Share Posted August 14, 2015 $str="something"if not $str="somethingelse" then dosomething()Would be more correctly written$str="something" If $str <> "somethingelse" then dosomething() "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
LoWang Posted August 17, 2015 Share Posted August 17, 2015 (edited) Guys thank you for poingint me to the help pages and manuals, but I understand how to do it right and how it works already.What I was asking is why is this behavior coded into AutoIt and if there is any specific reason or some advantage in certain situations or type of code which justifies this unusual "feature" of AutoIt programming language. So far I find only a lot of questions around the web with people being confused by this operators priority. Edited August 17, 2015 by LoWang Link to comment Share on other sites More sharing options...
guinness Posted August 17, 2015 Share Posted August 17, 2015 (edited) So you understand how it works, therefore what is the problem? Also jchd linked to the help file because it explains why it happens and yes it's "behaviour coded into AutoIt"! Edited August 17, 2015 by guinness Typo UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
LoWang Posted August 17, 2015 Share Posted August 17, 2015 (edited) Do I need to have a problem to ask a question like that? Or is my curiosity too impolite if I question developers? But if there was no special reason for this default operator priority or the origin of this decision it is no longer known then OK... Edited August 17, 2015 by LoWang Link to comment Share on other sites More sharing options...
jchd Posted August 17, 2015 Share Posted August 17, 2015 LoWang,How exactly the AutoIt operators' priority differs from the languages you know and use and why it's so surprising to you? 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
guinness Posted August 17, 2015 Share Posted August 17, 2015 if (!'string' === false) { // !'string' is equal to false and then false is compared with false hence true console.log('Internet is NOT broken!'); }This is JavaScript. Therefore if AutoIt is broken, so is the entire web. Maybe contact ECMAScript and W3C and explain to them that they're wrong. Let us know what they respond with so we can change AutoIt. Thanks LoWang 1 UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
LoWang Posted August 20, 2015 Share Posted August 20, 2015 (edited) OK OK, thank you for the effort, but your example unfortunately does not show anything, because I don't think strings are usually compared to false and if you add parenthesisif (!('string' === false)) { // 'string' is not equal to false thus negating it with ! makes true console.log('Internet is NOT broken!'); }it produces the same result...However when I rewrote my example with comparing string to string to JavaScript I gotta say you are right. I did not know JavaScript's ! had higher priority then comparison var str="something" if (! str=="somethingelse"){ console.log('something'); }else{ console.log('! has precedence in Javascript over =='); }The same seems to apply to PHP (again it uses exclamation mark instead of not) However if you try that in Python:In [1]: str="abc" In [2]: not str=="abcd" Out[2]: True Or Perl:$str="abc"; if (not $str eq "abcd"){ print "eq has higher priority then not \n"; }else{ print "false \n"; }And here we see something quite interesting. You can use either ! or not as an operator but their behavior is different!$str="abc"; if (! $str eq "abcd"){ print "true \n"; }else{ print "! has higher priority then eq \n"; }This leads me to a conclusion: It looks like languages using "not" instead of ! have it's precedence lower. Unlike those using only ! The main thing which makes higher precedence of exclamation mark obvious is that you can (and usually everyone do) write it without space right after it. On the other hand you cannot usually ommit space after "not" operator (you can in Perl though…). So it seems AutoIt indeed is a bit special because there is no ! as a logical operator and the behavior of not operator is different then in other languages I know of. So thank you for an interesting discussion guys Edited August 20, 2015 by LoWang 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