Author Topic: Script termination  (Read 418 times)

garry23

  • Hero Member
  • *****
  • Posts: 1524
Script termination
« 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:

Code: [Select]
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  ;)

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3217
  • 60Da / 1100D / EOSM
Re: Script termination
« Reply #1 on: December 11, 2017, 02:45:36 PM »
Code: [Select]
if test() == false then
    print("exiting...")
    return
end

garry23

  • Hero Member
  • *****
  • Posts: 1524
Re: Script termination
« Reply #2 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