Jump to content

By Design Or.....?


GEOSoft
 Share

Recommended Posts

Playing with some code for an AutoIt script generator, I discovered Func/EndFunc appears to have a default value. I forgot to add the Return in a couple of places but it seems as if that is the default anyway.

Global $a
Func1()
MsgBox( 0 , '',$a)
Exit

Func Func1()
    $a = 'This is just a demo'
EndFunc
Either way, if this can be confirmed, it might be an idea to add it to the docs.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I think GEOSoft is saying that the function has a return value even though he did not include an explicit "Return" statment.

For example, the following prints zero:

MsgBox(0,"", foo() )

Func foo()
EndFunc

The "feature" has to do with the way AutoIt is designed. Look in the help file for all functions that list "None" as a return value, such as Break(0). If you assign such a function to a varaible, you typically get a value of 1.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

I didn't know user functions default to returning 1, but all built-in functions return 1 unless explicity set to return something else, so it doesn't surprise me that a user function would also have the same behavior.

I just didn't understand by his code what he was trying to do. He never caused any visible sign that he was checking the return value of the function. All I see is a global variable, then assigning that variable in the function, and printing the result of it. :whistle:

Link to comment
Share on other sites

I didn't know user functions default to returning 1, but all built-in functions return 1 unless explicity set to return something else, so it doesn't surprise me that a user function would also have the same behavior.

Er, do you mean user-functions default to 0 and built-in functions default to 1, because that the behavior I got.... :whistle: bug/feature?

It used to be that built-in functions defaulted to zero (for success), but Jon changed this in version 3.0.83

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

I think GEOSoft is saying that the function has a return value even though he did not include an explicit "Return" statment.

Exactly and it will come in handy. While I'm at it, has anyone figured a way to enter a compiled script at a certain point or function? Same as using switches.

Example (from the command line)

  • myapp.exe /1 Starts my app at Func1()
  • myapp.exe /2 Starts my app at Func2()
Okay, so I guess we can ask for too much. :whistle:

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If $CmdLine[0] > 0 And $CmdLine[1] = "/1" Then
  doFirstFunction()
ElseIf $CmdLine[0] > 0 And $CmdLine[1] = "/2"
  doSecondFunction()
EndIf

But you cannot enter code at an arbitrary point since AutoIt lacks the GOTO statement. Also, think of the security implications if you could skip over a validation routine :whistle:

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Er, do you mean user-functions default to 0 and built-in functions default to 1, because that the behavior I got....  B) bug/feature?

It used to be that built-in functions defaulted to zero (for success), but Jon changed this in version 3.0.83

Uhh, yeah. :whistle::angry:

Edit: See, I told you I didn't understand what was trying to be conveyed. :evil:

Edited by Valik
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...