Jump to content

some unstable features in autoit


Recommended Posts

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

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

  • Moderators

Richard Robertson,

Absolutely correct! ;)

From the Help file page for Default:

"Remarks

This 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

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

 

Link to comment
Share on other sites

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

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)
Link to comment
Share on other sites

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

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 1111

The -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 1111

Sometimes it is an indicator of an error condition. You'll notice both start with the same 32 1 bits though.

Edited by Richard Robertson
Link to comment
Share on other sites

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

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) :)

Edited by nguoibachviet
Link to comment
Share on other sites

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

  • Moderators

nguoibachviet,

the problem is we don't have any default values for params

Yes we do, but you have to set them. ;)

Try running this:

; 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

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

 

Link to comment
Share on other sites

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.

;)

Link to comment
Share on other sites

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

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

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
 Share

  • Recently Browsing   0 members

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