Post new topic    
Metal Slime
Send private message
Ending a script 
 PostThu Feb 05, 2015 6:28 pm
Send private message Reply with quote
I was asking myself, what are the ways of ending a script?

Is there a comand for endiing in the middle an if-clause so the rest of the else if's are ignored?
Or just ending a whole script (,named script A, for example) and returning to the script that called script A and continue to execute some commands?

I found
Quote:
break
Breaks out of a for or while loop or switch and continues the script after the end of the do block.

in the dictionary. But it dosen't say anything about if-clauses.
Metal Slime
Send private message
 
 PostThu Feb 05, 2015 6:48 pm
Send private message Reply with quote
1. I think you can use exit script to break out of any script completely. You can also use 'exit returning' to return a value when you break out.

2. Break works on for loops and while loops. It doesn't do anything related to if clauses. However, this shouldn't be a problem because

3. If an if clause is run, all the else if clauses that come afterwards gets skipped, even if the else if condition becomes true after the if clause. It'd be something like this:

Code:
variable := 1
if(variable == 1) then,begin
  # this part gets run.
  variable := 2
end
else if(variable == 2) begin
  # this will not get run!
end
Metal Slime
Send private message
 
 PostThu Feb 05, 2015 6:50 pm
Send private message Reply with quote
Thanks a lot! Smile

That's really helpful to kown.
Display posts from previous: