nguoibachviet Posted September 17, 2010 Share Posted September 17, 2010 test it with your self : MsgBox(0, "", 0 >= Default) ;=> non error, return true MsgBox(0, "", 0 <= Default) ;=> non error, return true MsgBox(0, "", 0 = Default) ;=> non error, return false MsgBox(0, "", 0 > Default) ;=> non error, return false MsgBox(0, "", 0 < Default) ;=> non error, return false MsgBox(0, "", Default <|>|= 0) ;=> error, no acceptable So, if user call a func with default params, it may be generate an error : Func X($a) If ($a>0) then do somethings If (10 <= $a) then do somethings EndFunc X(default) So, can i call this problem is unstable autoit's features? thanks! Link to comment Share on other sites More sharing options...
JohnOne Posted September 17, 2010 Share Posted September 17, 2010 I doubt its a bug, since in your top example you are testing a numeric value against a bool or a keyword If (0 >= Default) Then MsgBox(0, "", 0 >= Default) ;=> non error, return true If (0 <= Default) Then MsgBox(0, "", 0 <= Default) ;=> non error, return true If (0 = Default) Then MsgBox(0, "", 0 = Default) ;=> non error, return false If (0 > Default) Then MsgBox(0, "", 0 > Default) ;=> non error, return false If (0 < Default) Then MsgBox(0, "", 0 < Default) ;=> non error, return false $var = Default $var2 = (0 >= Default) MsgBox(0,"Type",VarGetType($var) & @LF & VarGetType($var2)) I read somewhere that autoit trys to determine what you are trying to achieve when the user makes errors like this. If that is true then autoit returns the same results each time, so it cannot be labelled "unstable". AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 17, 2010 Share Posted September 17, 2010 I believe it says somewhere in the helpfile that the Default keyword is not to be used in equations. You are supposed to only use it for passing or not passing parameters and you can check for it by doing IsKeyword($param1). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 17, 2010 Moderators Share Posted September 17, 2010 Richard Robertson,Absolutely correct! From the Help file page for Default:"RemarksThis keyword should not be used in a general computation expression. AutoIt will not detect such situations because it has too much of a performance penalty"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...
RagsRevenge Posted September 17, 2010 Share Posted September 17, 2010 test it with your self : So, if user call a func with default params, it may be generate an error : Func X($a) If ($a>0) then do somethings If (10 <= $a) then do somethings EndFunc X(default) So, can i call this problem is unstable autoit's features? You haven't assigned a default value in your function declaration. Func X($a = 1) If ($a>0) then do somethings If (10 <= $a) then do somethings EndFunc X(default) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 17, 2010 Share Posted September 17, 2010 You haven't assigned a default value in your function declaration. You make no sense there. $a is still Default. A default value of a parameter has nothing to do with the Default-keyword. Func X($a = 1) ConsoleWrite($a & @CRLF) If $a = Default Then $a = 1 ConsoleWrite($a & @CRLF) EndFunc X(Default) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
MvGulik Posted September 17, 2010 Share Posted September 17, 2010 Seems Default can't make up his mind whether it likes to be "-1" or a "-1.#IND". "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 17, 2010 Share Posted September 17, 2010 (edited) Seems Default can't make up his mind whether it likes to be "-1" or a "-1.#IND". That's the difference between an integer and a floating point value.The -1 is 32 1s as the bits 1111 1111; 1111 1111; 1111 1111; 1111 1111The -1.#IND is basically NaN (not a number). For a double, it is 1111 1111; 1111 1111; 1111 1111; 1111 1111; 0111 1111; 1111 1111; 1111 1111; 1111 1111Sometimes it is an indicator of an error condition. You'll notice both start with the same 32 1 bits though. Edited September 17, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
MvGulik Posted September 17, 2010 Share Posted September 17, 2010 I knew I was forgetting/missing something. Numbers come in two flavors. Did not give that a second thought. Thanks for reminding me. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
nguoibachviet Posted September 19, 2010 Author Share Posted September 19, 2010 (edited) the problem is we don't have any default values for paramstry this with your self:Func a($a,$b,$c,$d,$e,$f) if iskeyword($a) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($b) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($c) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($d) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($e) or ($a=default) then msgbox(0,'','oh my god') return StringLeft($a,2);---->do all this for one line code :)) EndFunccan you do this with all your funcs? No , we can'tSo let guest that you have code like this:Func a($a,$b,$c,$d,$e,$f) return StringLeft($a,2);---->do all this for one line code :)) EndFuncok, let guest that this autoit's feature is good, but my func unstable problem is my code have bad document, just include this line to all your code document:Func a($a,$b,$c,$d,$e,$f);<--please dont put Default to $a,$b,$c,$d,$e,$f, is a keyword and we need value pleasedo it with you all func (may be thousand? ) ) and now it's stable? :-? NOlet guest that someone dev some UDF and forgot the above rule : oh my godfunc b($a='this is default value',$b) ;-->do somethings a($a) ;-->do somethings Endfuncdocs : func b( $a,$b ) ; $a='this is default value' (default)and end dev call : b(default,'dsfsdf') --> this will return 'De' --> NO WAY TO DEBUGThe problem is : -a keyword is NOT a value, so we can't compare or use mixed both keyword and value with no error-a Func need only value (keyword is compiler problem), if we need a default value, simple use option params : $a='somethings'So can i call Default is unstable autoit's feature now?thanks (and sorry about my bad english) Edited September 19, 2010 by nguoibachviet Link to comment Share on other sites More sharing options...
Kalin Posted September 19, 2010 Share Posted September 19, 2010 the problem is we don't have any default values for params try this with your self: Func a($a,$b,$c,$d,$e,$f) if iskeyword($a) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($b) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($c) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($d) or ($a=default) then msgbox(0,'','oh my god') if iskeyword($e) or ($a=default) then msgbox(0,'','oh my god') return StringLeft($a,2);---->do all this for one line code :)) EndFunc can you do this with all your funcs? No , we can't So let guest that you have code like this: Func a($a,$b,$c,$d,$e,$f) return StringLeft($a,2);---->do all this for one line code :)) EndFunc ok, let guest that this autoit's feature is good, but my func unstable problem is my code have bad document, just include this line to all your code document: Func a($a,$b,$c,$d,$e,$f);<--please dont put Default to $a,$b,$c,$d,$e,$f, is a keyword and we need value please do it with you all func (may be thousand? ) ) and now it's stable? :-? NO let guest that someone dev some UDF and forgot the above rule : oh my god func b($a='this is default value',$b) ;-->do somethings a($a) ;-->do somethings Endfunc docs : func b( $a,$b ) ; $a='this is default value' (default) and end dev call : b(default,'dsfsdf') --> this will return 'De' --> NO WAY TO DEBUG The problem is : -a keyword is NOT a value, so we can't compare or use mixed both keyword and value with no error -a Func need only value (keyword is compiler problem), if we need a default value, simple use option params : $a='somethings' So can i call Default is unstable autoit's feature now? thanks (and sorry about my bad english) I've seen some unstable features in AutoIt, but this isn't one of them. It's the way you made your code. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 19, 2010 Moderators Share Posted September 19, 2010 nguoibachviet, the problem is we don't have any default values for paramsYes we do, but you have to set them. Try running this: expandcollapse popup; Function with defined value as default parameter ; Call function with no parameter _Function_1() ; Call function with a parameter _Function_1(2) ; Call function with Default as parameter _Function_1(Default) ConsoleWrite(@CRLF) ; Function with Default as default parameter ; Call function with no parameter _Function_2() ; Call function with a parameter _Function_2(2) ; Call function with Default as parameter _Function_2(Default) ConsoleWrite(@CRLF) ; Function with Default as default parameter ; Call function with no parameter _Function_3() ; Call function with a parameter _Function_3(2) ; Call function with Default as parameter _Function_3(Default) ; Function with default parameter Func _Function_1($iParam = 1) ConsoleWrite($iParam & @CRLF) EndFunc ; Function with Default as default parameter Func _Function_2($iParam = Default) ConsoleWrite($iParam & @CRLF) EndFunc ; Function with check for Default as parameter Func _Function_3($iParam = 1) If $iParam = Default Then $iParam = 3 ConsoleWrite($iParam & @CRLF) EndFunc Seems pretty comprehensive to me. Do you still have a problem? If so then please post the code. 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...
Richard Robertson Posted September 19, 2010 Share Posted September 19, 2010 Melba's code is correct in illustrating the correct use of Default, however I believe IsKeyword is more accurate than = Default. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 19, 2010 Share Posted September 19, 2010 Melba's code is correct in illustrating the correct use of Default, however I believe IsKeyword is more accurate than = Default.Why is that? Logic says that Default = Default should work. And it does. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 19, 2010 Share Posted September 19, 2010 (edited) Except that the helpfile says not to use it in computations and equals is a computation. Keep in mind things like NaN is not equal to NaN as well. Even though it is the same binary value they may not be equatable. Edited September 19, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 19, 2010 Share Posted September 19, 2010 Right. That. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
MvGulik Posted September 19, 2010 Share Posted September 19, 2010 Is the NaN not the result of wrong use of the Default keyword. (I think it is -> Auto conversion result as the result of a pre-compare computation with the Default/keyword.) "<,>,<=,>=" could be seen as computations. There also implying that the data on both side are of the same type. Relying on AutoIt variant conversion should only be done with strings and numbers. (in my view.) "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 19, 2010 Share Posted September 19, 2010 (edited) Yes, NaN can be the result of using Default in an equation, but my example was actually that NaN == NaN is false. It was showing that Default == Default may also be invalid. Edited September 19, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
MvGulik Posted September 20, 2010 Share Posted September 20, 2010 ... Erm, Having a problem connecting some of your points/logic. Will give it some more though in private. ...Taking the easy way out (of this topic) and falling back to the Default keyword help remark. "This keyword should not be used in a general computation expression." "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... 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