Jump to content

How can this func return 1?


typhoon
 Share

Recommended Posts

Definitely a bug.  Test this small script for proof:

MsgBox(4096, "", Test1()); Prints 500

Func Test1()
    Test2(); No Return statement!
EndFunc

Func Test2()
    Return 500
EndFunc

<{POST_SNAPBACK}>

I do not get post #5. The result of Test1(), in the messagebox is the result of Test2(). If you do not want this reponse, do not call Test2() from Test1(). This is logical.

Does anyone have a better example. :lmao:

Link to comment
Share on other sites

MHz, it shouldn't return anything... it wants the return from Test1, which is nothing. Not the return from Test2.

Get it?

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

MHz, it shouldn't return anything... it wants the return from Test1, which is nothing.  Not the return from Test2.

Get it?

<{POST_SNAPBACK}>

No, if Test1(), does not return 500, then that would be a bug.

; Example from Valik.

MsgBox(4096, "", Test1()); Prints 500

Func Test1()
    Test2(); No Return statement!
EndFunc

Func Test2()
    Return 500
EndFunc


; Same as

MsgBox(4096, "", Test1()); Prints 500

Func Test1()
    Return 500;; Replaced function call with function code.
EndFunc
Link to comment
Share on other sites

...I don't believe it works like that in PHP/C++?

Let me test it in PHP...

<?php
    echo Test1();
    
    function Test1()
    {
        Test2();
     }

    function Test2()
    {
        return 500;
    }
?>

Doesn't return a thing.

Why? Because I don't tell it to, I tell another function to return something. If functions started doing things you didn't tell them to, that'd be kinda buggy wouldn't it? :lmao:

EDIT:

Not trying to be a dick, it's just not supposed to work that way.

Edited by Insolence
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

  • Developers

No, if Test1(), does not return 500, then that would be a bug.

<{POST_SNAPBACK}>

Don't think so... Valiks example should return a 0 since you would expect an implicit "return 0" when in func test1 like:

MsgBox(4096, "", Test1()); Prints 500

Func Test1()
    Test2(); No Return statement!
    Return 0  
EndFunc

Func Test2()
    Return 500
EndFunc

This is what the helpfile says about it:

Use the Return keyword to exit the function. Unlike built-in functions, user-defined functions return 0 unless another return value is specified.

Even this returns 500:

MsgBox(4096, "", Test1()); Prints 500

Func Test1()
    Test2(); No Return statement!
    Return  
EndFunc

Func Test2()
    Return 500
EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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