Notifications
Clear all

[Closed] Terminate script execution?

I have a script that uses a rollout control from a custom max plugin.

Problem is, if I run the script on a computer that doesn’t have that plugin, the script crashes. Ideally I’d like to be able to just bring up a pop up window that says to install the plugin if it’s missing and end the script. Putting my rollout declaration inside try()catch() brackets does not solve the problem, as the script still crashes even if all the declarations are made inside the try function.

I’ve also tried if-then statements but the script still crashes. The only solution I can think of is to have two scripts, one checks for the plugin and if the plugin is found it does a fileIn on the second script, which has the rollout declaration. That’s a shitty fix though because it means I have to have two scripts instead of just one.

Here’s the pseudocode of the type of solution that would be nice:


hasPlugin = check for plugin
if hasPlugin == false then 
(
messagebox "You don't have the right plugin!"
stopScriptAndExit 
)

rollout declarations, etc....

Does anyone know of a command that can terminate a script like that? Break() is close but I don’t want to bring up the debugger. Exit, return, etc only work inside functions…

4 Replies

Hi,

Did you try using return?

Like:

hasPlugin = check for plugin
if hasPlugin == false then 
(
    messagebox "You don't have the right plugin!"
    return false
)

Light

1 Reply
(@ivanisavich)
Joined: 11 months ago

Posts: 0

Return only works inside functions, and even if it was inside a function it doesn’t stop the code after that function from evaluating…

I don’t just need a function to prematurely terminate, I need the entire script to stop being parsed

I see. I guess the best way I can think of might be to use that variable to include that script.

So like:


hasPlugin = check for plugin
if hasPlugin then 
(
    Include "myplugin.ms"
)
else
(
    messagebox "You don't have the right plugin!"
)

Light

 lo1

not very elegant, but why not put your entire script in an if-then-else statement?