Sign in to follow this  
Followers 0
reb

how do I exit a function before the end of the function

7 posts in this topic

Hi

I have a script running (all functions called by hot keys) and if a condition is true (call it a flag)

I need to exit the function before it finishes and keep the script running.

I am really drawing a blank on this one.

Here is an example of what I want to do.

$test = ""

test()

Func Test()

if $test = "" then EndFunc ; (If I use exit it closes the script but I need to keep the script running)

MsgBox(0,"","this is a test")

EndFunc

Thanks for your help.

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites



Try Return.

Share this post


Link to post
Share on other sites

Try Return.

Here is what I tried.

test()

global $test, $x

$test = "dick"

Func Test()

if $test = "" then Return $x; If I use exit it closes the script

MsgBox(0,$test,"this is a test")

EndFunc

error (6) : ==> Variable used without being declared.:

if $test = "" then Return $x

if ^ ERROR

What am I doing wrong?

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

What am I doing wrong?

REB

Didn't you read the error? You used the variable before declaring it!

You probably want your script to start more like:

global $test, $x
$test = "dick"
test()

Share this post


Link to post
Share on other sites

Perhaps because you're calling test() before you've declared $test.

Share this post


Link to post
Share on other sites

Didn't you read the error? You used the variable before declaring it!

You probably want your script to start more like:

global $test, $x
$test = "dick"
test()

I sure did. Works now

THANK YOU

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

Perhaps because you're calling test() before you've declared $test.

Thank you.

You are right on.

REB


MEASURE TWICE - CUT ONCE

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  
Followers 0