07.05.2015 Views

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

166 BRONZE <strong>Edition</strong> <strong>Guide</strong><br />

SUB Structure<br />

SUB identifier (parm 1, ... , param n)<br />

...<br />

EXIT SUB [optional]<br />

...<br />

END SUB<br />

The subroutine may contain one or more EXITSUB statements. A CALLstatement<br />

invokes the subroutine; that is, starts it running. The arguments in the CALL must<br />

match the parameter in the SUB statement in number, position, type, and number of<br />

dimensions. Parameter passing is by reference; that is, changes to the parameter within<br />

the subroutine will cause simultaneous changes to the arguments in the CALL statement.<br />

WHEN Structure<br />

WHEN EXCEPTION IN<br />

... ! Protected part<br />

USE<br />

... ! Executed if an exception is in a protected part<br />

END WHEN<br />

This subroutine may be used to “trap” run-time errors called exceptions. Examples might<br />

be division by 0 or attempting to open a file that doesn’t exist.<br />

If an exception of any type occurs in the protected portion, the recovery statements between<br />

the USE statement and the END WHEN statement are executed. If no exception occurs in<br />

the protected part, the recovery statements are ignored.<br />

The functions EXLINE, EXLINE$, EXTEXT$, and EXTYPE can be used to determine the<br />

exact nature of an exception.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!