G:/ScriptBasic/source/commands/goto.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include "../command.h"

Go to the source code of this file.

Functions

 SETPROGRAMCOUNTER (PARAMETERNODE)
 if (!pEo->ErrorResume) ERROR(COMMAND_ERROR_NO_RESUME)
 SETPROGRAMCOUNTER (pEo->ErrorResume)
 SETPROGRAMCOUNTER (CDR(pEo->ErrorResume))
 if (RESULT)
 if (CAR(PARAMETERLIST))
 if (vErrCode==NULL)
 if (lErrCode< 0||lErrCode >=MAX_ERROR_CODE)
 memcpy (STRINGVALUE(RESULT), en_error_messages[lErrCode], STRLEN(RESULT))
END ERROR (pEo->LastError=LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE))))

Variables

pEo LastError = 0
pEo ErrorGoto = 0
pEo fErrorGoto = 0
END pEo ErrorGoto = PARAMETERNODE
pEo fErrorGoto = ONERROR_RESUME
END pEo ErrorGoto = 0
pEo fErrorGoto = 0
END pEo ErrorGoto = PARAMETERNODE
pEo fErrorGoto = ONERROR_GOTO
END pEo LastError = 0
END pEo fErrorGoto = ONERROR_RESUMENEXT
END pEo LastError = 0
END pEo fStop = fStopSTOP
END pEo fStop = fStopSTOP
END RESULT = NEWMORTALLONG
END VARIABLE vErrCode
long lErrCode
 USE_CALLER_MORTALS
 vErrCode = NULL
else lErrCode = GETLONGVALUE(vErrCode)
 RESULT = NEWMORTALSTRING(strlen(en_error_messages[lErrCode]))
 ASSERTOKE


Function Documentation

END ERROR pEo->  LastError = LONGVALUE(CONVERT2LONG(EVALUATEEXPRESSION(PARAMETERNODE)))  ) 
 

if lErrCode< 0||lErrCode = MAX_ERROR_CODE  ) 
 

Definition at line 246 of file goto.c.

References NULL, RESULT, and RETURN.

if vErrCode  = NULL  ) 
 

Definition at line 242 of file goto.c.

References pEo.

if CAR(PARAMETERLIST)   ) 
 

Definition at line 238 of file goto.c.

References ASSERTOKE.

if RESULT  = NULL  ) 
 

Definition at line 213 of file goto.c.

References LONGVALUE(), pEo, and RESULT.

if !pEo->  ErrorResume  ) 
 

memcpy STRINGVALUE(RESULT ,
en_error_messages  [lErrCode],
STRLEN(RESULT
 

SETPROGRAMCOUNTER CDR(pEo->ErrorResume  ) 
 

SETPROGRAMCOUNTER pEo->  ErrorResume  ) 
 

SETPROGRAMCOUNTER PARAMETERNODE   ) 
 

GOTO =section misc =title GOTO label Go to a label and continue program execution at that label. Labels are local within functions and subroutines. You can not jump into a subroutine or jump out of it.

Use of GOTO is usually discouraged and is against structural programming. Whenever you feel the need to use the T<GOTO> statement (except T<ON ERROR GOTO>) thin it twice whether there is a better solution without utilizing the statement T<GOTO>.

Typical use of the T<GOTO> statement to jump out of some error condition to the error handling code or jumping out of some loop on some condition.

Referenced by COMMAND_FUNCTIONARG(), if(), switch(), and while().


Variable Documentation

ASSERTOKE
 

Definition at line 267 of file goto.c.

END pEo ErrorGoto = PARAMETERNODE
 

Definition at line 114 of file goto.c.

END pEo ErrorGoto = 0
 

ONERRORGOTO =section error =title ON ERROR GOTO [ label | NULL ] =display ON ERROR GOTO

Set the entry point of the error handling routine. If the argument is T<NULL> then the error handling is switched off.

Definition at line 102 of file goto.c.

END pEo ErrorGoto = PARAMETERNODE
 

ONERRORRESUME =section error =title ON ERROR RESUME [ label | next ] =display ON ERROR RESUME

Setting T<ON ERROR RESUME> will try to continue execution on the label or on the next statement when an error occurs without any error handling code.

See also R<ONERRORGOTO>, R<RESUME> and R<ERROR>.

Definition at line 83 of file goto.c.

pEo ErrorGoto = 0
 

Definition at line 62 of file goto.c.

END pEo fErrorGoto = ONERROR_RESUMENEXT
 

Definition at line 139 of file goto.c.

pEo fErrorGoto = ONERROR_GOTO
 

Definition at line 115 of file goto.c.

pEo fErrorGoto = 0
 

Definition at line 103 of file goto.c.

pEo fErrorGoto = ONERROR_RESUME
 

Definition at line 84 of file goto.c.

pEo fErrorGoto = 0
 

Definition at line 63 of file goto.c.

END pEo fStop = fStopSTOP
 

END =section misc

End of the program. Stops program execution.

You should usually use this command to signal the end of a program. Although you can use R<STOP> and T<END> interchangeably this is the convention in BASIC programs to use the command T<END> to note the end of the program and T<STOP> to stop the program execution based on some extra condition inside the code.

Definition at line 186 of file goto.c.

END pEo fStop = fStopSTOP
 

STOP =section misc error

This command stops program execution. There is no possibility to restart program execution after this command was executed.

See also R<END>.

Definition at line 169 of file goto.c.

END pEo LastError = 0
 

Definition at line 150 of file goto.c.

END pEo LastError = 0
 

Definition at line 126 of file goto.c.

pEo LastError = 0
 

Definition at line 61 of file goto.c.

else lErrCode = GETLONGVALUE(vErrCode)
 

Definition at line 244 of file goto.c.

long lErrCode
 

Definition at line 233 of file goto.c.

RESULT = NEWMORTALSTRING(strlen(en_error_messages[lErrCode]))
 

Definition at line 251 of file goto.c.

END RESULT = NEWMORTALLONG
 

ERROR =section error =title ERROR() or ERROR n

The keyword T<ERROR> can be used as a command as well as a built-in function. When used as a function it returns the error code that last happened. The error codes are defined in the header file T<error.bas> that can be included with the command T<import>. The error code is a vital value when an error happens and is captured by some code defined after the label referenced by the command T<ON ERROR GOTO>. This helps the programmer to ensure that the error was really the one that the error handling code can handle and not something else.

If the keyword is used as a command then it has to be followed by some numeric value. The command does not ever return but generates an error of the code given by the argument.

Take care when composing the expression following the keyword T<ERROR>. It may happen that the expression itself can not be evaluated due to some error conditions during the evaluation of the expression. The best practice is to use a constant expression using the symbolic constants defined in the include file T<error.bas>.

Note that the codes defined in the include file are version dependant.

If an error is not captured by any T<ON ERROR GOTO> specified error handler then the interpreter stops. The command line variation passes the error code to the executing environment as exit code. In other word you can exit from a BASIC program

Definition at line 211 of file goto.c.

USE_CALLER_MORTALS
 

Definition at line 235 of file goto.c.

vErrCode = NULL
 

Definition at line 237 of file goto.c.

END VARIABLE vErrCode
 

ERRORD =section errord =title ERROR$() or ERROR

Returns the English sentence describing the last error if the argument is not defined or returns the English sentence describing the error for the error code T<n>.

If the error code T<n> provided as argument is negative or is above all possible errors then the result of the function is T<undef>.

Definition at line 232 of file goto.c.


Generated on Sun Mar 12 23:56:33 2006 for ScriptBasic by  doxygen 1.4.6-NO