PDA

View Full Version : How to let the wrong program interrupt execution ?


jthwax
03-15-2009, 01:18 AM
If has carried out a judgment type.

example:
if (a = 10 ) then print "ok" else
(print "stop Function"
stop program
)

How Compiles " stop program" Content .
Requests master help to answer, thanks ~

ZeBoxx2
03-15-2009, 12:07 PM
try 'throw' if you want to throw an error

e.g.

for i = -100 to 100 do (
if (i == 0) then (
throw "zomg! you nearly divided by zero!"
)
print (1.0 / i)
)


If just want to exit a function early, use "return <something>", or exit a loop early using "exit [with <something>]"
( note that 'return' and 'exit' take additional computation time and letting a function/loop run its course is often, paradoxically, faster.

jthwax
03-16-2009, 01:38 PM
Thanks for the advice, i appreciate it.

CGTalk Moderation
03-16-2009, 01:38 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.