© Tyl Software Foundation 2019-2021
▶ FUNCTION BREAK STATEMENT
Function break statements are used when the execution of the enclosing function
needs to be stopped immediately.
To make a function break statement, write:
To make a function break statement, write:
%%
Tyl symbolizer will replace the double percent code '%%', with '✖✖',
the function break symbol:
✖✖
Consider this program:
num 6
divisor 0
%%
num // divisor
print num
The critical division by zero line
Say we have a divide by program:
num // divisor
, and all lines thereafter,
will not be executed since the function break line '%%
', will cause the
system to stop executing the program.
Say we have a divide by program:
go:
num 6
divideby num 2
divideby num divisor: num // divisor
All divisions by non zero divisors will be fine. But to ensure code integrity,
we need to handle also the zero divisor case.
We add global
We add global
ok
variable to the program:
ok \t
go:
num 6
divisor 2 ~
result divideby num divisor
not ok ?
print 'Division by zero!'
\
print 'Division result: ' + result
^
^
divideby num divisor:
ok \t
divisor 0 ? %% ok \f
num // divisor
In
divideby
function, the zero divisor check statement
'divisor 0 ?
', will activate function break statement '%% ok \f
'.
As with all break statements, a statement can be activated upon
breaking, so ok
flag will be turned off, and function execution
will be stopped. If divisor
is not zero, division is done.