Flow-control structures: Difference between revisions

Added XPL0 example.
(Added XPL0 example.)
Line 3,032:
=== On Error Goto ===
 
This brancesbranches in the event of an error. Usually there is an Exit (Sub|Function) to seperateseparate the normal code from the error handling code
 
<syntaxhighlight lang="vbnet"> Sub foo()
Line 3,140:
</pre>
 
=={{header|XPL0}}==
XPL0 does not have a ''goto'' statement, but it has other similar
statements. Its ''quit'' statement jumps out of a ''loop'' block. A
''return'' jumps out of a procedure, or a function where it's also used
to return the numerical result of the function. A ''return'' in the main
procedure terminates a program. An ''exit'' statement terminates a
program from any location. Like the ''return'' statement, it can send an
optional value, in this case to the operating system.
 
Some routines called ''intrinsics'' that are automatically included in a
program also affect flow control. The Abort intrinsic is like the
''exit'' statement except it does not return a value. (It's deprecated in
preference to ''exit''.) The Restart intrinsic, which can be called from
anywhere, restarts a program at its beginning. (The Rerun intrinsic is
used to distinguish a restart from a normal start.) Certain errors such
as divide-by-zero or attempting to open a non-existent file abort a
program. The Trap intrinsic can disable this feature. It's normally used
with the GetErr intrinsic, which provides a way to detect these kinds of
errors and handle them without aborting.
 
=={{header|Yabasic}}==
295

edits