Jump to content

Function after Function


Recommended Posts

If you want it to work like that, what's the point of having functions?

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

Like this? Even though it makes no sense.

test1()

Func test1()
    MsgBox(0, "", "hello from test1")
    test2()
EndFunc

Func test2()
    MsgBox(0, "", "hello from test2")
    test3()
EndFunc

Func test3()
    MsgBox(0, "", "hello from test3")
    test4()
EndFunc

Func test4()
    MsgBox(0, "", "hello from test4")
EndFunc
Edited by Pain
Link to comment
Share on other sites

You could also do something like this.

CONST $NUMFUNCS = 4
;
FOR $i = 0 TO $NUMFUNCS
 ConsoleWrite("RETURNS: "& Call("_F"& $i,"Function: "& $i) & @LF)
NEXT
EXIT
;
FUNC _F0($N)
 ConsoleWrite($N & @LF)
 RETURN 0
ENDFUNC
;
FUNC _F1($N)
 ConsoleWrite($N & @LF)
 RETURN 1
ENDFUNC
;
FUNC _F2($N)
 ConsoleWrite($N & @LF)
 RETURN 2
ENDFUNC
;
FUNC _F3($N)
 ConsoleWrite($N & @LF)
 RETURN 3
ENDFUNC
;
FUNC _F4($N)
 ConsoleWrite($N & @LF)
 RETURN 4
ENDFUNC
;

wtfpl-badge-1.png

Link to comment
Share on other sites

thnx pain.

Hawkwing functions have 2/3 anwsers. So every anwser has a other function to start.

Is English your native language? Your reply didn't make much sense. If you want to do something like Pain's example, why would you not just have the four msgboxes without putting them in funcs? I don't see any reason whatsoever to have 8 funcs set up so that the first would call the second, then the second would call the third, etc.

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Link to comment
Share on other sites

Is English your native language? Your reply didn't make much sense. If you want to do something like Pain's example, why would you not just have the four msgboxes without putting them in funcs? I don't see any reason whatsoever to have 8 funcs set up so that the first would call the second, then the second would call the third, etc.

I guess that would depend on whether he always wanted to chain to the next function inline or whether he wanted to chain to another function based on the answer given in that function ie. if input = yes goto function x or if input = no, goto function y.

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