Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on December 11, 2017, 10:04:08 AM

Title: Script termination
Post by: garry23 on December 11, 2017, 10:04:08 AM
Hope someone can educate me.

At the moment one of my scripts, on loading for the first time, uses an IF-THEN-ELSE, which first detects that a lens is AF capable, and if it is it carries on with the script, ie loading variables, menus and function.

If the lens is not an AF one, the script simply shows a console message and does nothing else.

This means I need to put the main part of my script in the (main) IF-THEN-ELSE, like this:


IF test-true THEN
carry on with main script
ELSE
console-message
END


Is there a way to put a test, up front in a script, that checks things and then doesn't load the script?

Cheers

Garry

PS having been prompted by @dmilligan, I hope this is an X question, rather than a Y one  ;)
Title: Re: Script termination
Post by: dmilligan on December 11, 2017, 02:45:36 PM

if test() == false then
    print("exiting...")
    return
end
Title: Re: Script termination
Post by: garry23 on December 11, 2017, 02:57:35 PM
@dmilligan

David

Can you please confirm that if I do a test such as that as the first few lines in my script, i.e. with a return, then the rest of the script won't be loaded.

Just tried it: thank you :)

Cheers

Garry