Compiler enhancement (edit 462): Functions and procedures may now contain a special label "$EXIT:" which the EXITPROCEDURE and EXITFUNCTION statements will effectively jump to. This allows you to insert code into the function/procedure that will always be executed at the end of the routine, even if the routine is terminated with the EXITPROCEDURE or EXITFUNCTION statement. For example:
PROCEDURE TEST()
DIMX A(100),S,50
...
IF <some condition) EXITPROCEDURE
...
...
$EXIT:
REDIMX A(0) ! release the memory used by A()
ENDPROCEDURE
In the example above, without the $EXIT: label, the EXITPROCEDURE statement would have ended the procedure without closing the file. The only way around that problem would have been to replace the EXITPROCEDURE with a GOTO statement. Although that is effectively what EXITPROCEDURE does, this is slightly more elegant, since it leaves no doubt as to the intent.
However, note that it easily possible to abuse this capability by putting the $EXIT label somewhere other than the end of the procedure. In fact, if the $EXIT occurs above the EXITPROCEDURE, you may well create an infinite loop.
Also note:
• | Unlike normal labels, which are case sensitive, the $EXIT label is not case sensitive. ($EXIT:, $exit, and $Exit are all equivalent.) |
• | Do not confuse a label named "exit" with "$exit". The former is a legal label but will not be associated with the EXITPROCEDURE/EXITFUNCTION statements. (This is an unfortunate invitation to subtle bugs, but to outlaw the use of a label called "exit" (without the $) would likely force modification of existing source code. |