Jump to content

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


reb
 Share

Recommended Posts

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

Link to comment
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

Link to comment
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()
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...