Notifications
Clear all

[Closed] How to let the wrong program interrupt execution ?

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 ~

2 Replies

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.

Thanks for the advice, i appreciate it.