Jump to content
Sign in to follow this  
nusaki

What�s a Return command or GoTo

Recommended Posts

nusaki

Sorry Im a new

Its stupid and basic question but I cant seem to find an answer.

What command should I use to abort current function and return to other one?

For example

First ()

Second()

Third()

Func Second()

Bla bla bla

EndFunc

Func Third()

If $col71 not=3479300 Then

STOP THIRD FUNC RIGHT HERE GO BACK TO SECOND()

Bla bla bla

EndFunc

So how do I stop it send it back to second function?

Thanks for help in advance


keywen.com

Share this post


Link to post
Share on other sites
Richard Robertson

Return. It's a keyword. It exits the current function and jumps back to where it was called. If you add a value after it, that is your return value.

Share this post


Link to post
Share on other sites
Malkey

Sorry I'm a new 

Its stupid and basic question but I can't seem to find an answer.

What command should I use to abort current function and return to other one?

For example

First ()

Second()

Third()

Func Second()

Bla bla bla

EndFunc

Func Third()

If $col71 not=3479300 Then

STOP THIRD FUNC RIGHT HERE GO BACK TO SECOND()

Bla bla bla

EndFunc

So how do I stop it send it back to second function?

Thanks for help in advance

Here are two examples. Both give the same result.

I hope you can follow the logic in both.

All output is to console.

Global example

;
;Using a Global variable for use in all functions
 Global $col71 = 0
 
 ConsoleWrite("The Start" & @TAB & "$col71 = " & $col71 & @CRLF)
 First()
 Second()
 Third()
 ConsoleWrite(" The  End " & @TAB & "$col71 = " & $col71 & @CRLF & @CRLF)
 
 
 Func First()
    $col71 = 34793
    ConsoleWrite("Func First" & @TAB & "$col71 = " & $col71 & @CRLF)
    Return
 EndFunc  ;==>First
 
 Func Second()
    $col71 *= 10; Same as $col71 = $col71 * 10
    ConsoleWrite("Func Second" & @TAB & "$col71 = " & $col71 & @CRLF)
    Return
 EndFunc  ;==>Second
 
 Func Third()
    ConsoleWrite("Func Third" & @TAB & "$col71 = " & $col71 & @CRLF)
    If $col71 <> 3479300 Then Second()
 ;STOP THIRD FUNC RIGHT HERE GO BACK TO SECOND()
    ConsoleWrite("End Third Func " & @TAB & "$col71 = " & $col71 & @CRLF)
    Return
 EndFunc  ;==>Third

Parameter example

;
;Using a parameter to pass a variable to function
 Local $col71 = 0
 
 ConsoleWrite("The Start" & @TAB & "$col71 = " & $col71 & @CRLF)
 
;local $a = First ($col71)
;local $b = Second($a)
;local $c = Third($b)
 
 Local $c = Third(Second(First($col71)))
 ConsoleWrite(" The  End " & @TAB & "$col71 = " & $c & @CRLF & @CRLF)
 
 
 Func First($var)
    $var = 34793
    ConsoleWrite("Func First" & @TAB & "$col71 = " & $var & @CRLF)
    Return $var
 EndFunc  ;==>First
 
 Func Second($var1)
    $var1 *= 10; Same as $col71 = $col71 * 10
    ConsoleWrite("Func Second" & @TAB & "$col71 = " & $var1 & @CRLF)
    Return $var1
 EndFunc  ;==>Second
 
 Func Third($var2)
    Local $var3
    ConsoleWrite("Func Third" & @TAB & "$col71 = " & $var2 & @CRLF)
    If $var2 <> 3479300 Then $var3 = Second($var2)
 ;STOP THIRD FUNC RIGHT HERE GO BACK TO SECOND()
    ConsoleWrite("End Third Func " & @TAB & "$col71 = " & $var3 & @CRLF)
    Return $var3
 EndFunc  ;==>Third
;

Share this post


Link to post
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
Sign in to follow this  

×