Omron SYSMAC C200H-ASC02 Operation Manual page 51

Ascii unit
Hide thumbs Also See for SYSMAC C200H-ASC02:
Table of Contents

Advertisement

BASIC Language
ON ERROR Statement
ON GOSUB and ON GOTO Statements
100
IF LOC (1)=0 THEN 120
110
PRINT INPUT$ (LOC(1),#1)
120
RETURN
Program Remarks:
If an interrupt from port 1 is detected, the buffer contents are displayed.
Note 1. If an interrupt is received on a communications line during processing of
an interrupt routine, a RETURN statement will be returned and a branch
will be made again to the interrupt routine. When this happens, there may
be nothing in the buffer depending on the timing of the interrupt. To handle
this, always place LOC and EOF at the beginning of the interrupt routine
to check if there is data in the buffer, as shown at line 100 in the applica-
tion example given above.
2. When determining the contents of processing for interrupt routines, study
the relationship between the communications speed and processing
speed so that the receive buffers do not overflow while processing the
interrupt routine.
Purpose:
To enable error processing and to specify the first line number of
the error handling routine
Format:
ON ERROR GOTO <line>
<line> is any valid line number.
Remarks:
When an error occurs, this statement directs execution to the proper error
handling routine. When an error is detected, the error number is assigned to
the variable ERR and the line number where the error occurred is assigned
to ERL.
To disable error processing, execute ON ERROR GOTO 0. Subsequent er-
rors will cause an error message to be printed and execution to be halted.
If an error occurs during execution of an error handling subroutine, a BASIC
error message will be printed and execution terminated.
Refer to the discussion of the RESUME Command, and the ERR and ERL
functions.
Purpose:
To branch to one of several specified line numbers, depending
on the resultant evaluation of a numeric or logical expression
Format:
ON <expression> GOTO <list>
ON <expression> GOSUB <list>
<expression> is any valid expression.
<list> is a list of valid line numbers separated by comas.
Example:
ON X-2 GOSUB 50,100,150
Remarks:
The value of <expression> determines which line number in the list will be
used for branching. For example, if the result is 2, then the second line num-
ber in the list will be chosen for branching. If the resultant value is not an inte-
ger, the fractional part is rounded off.
In the ON...GOSUB statement, each line number in the list must be the first
line number of a subroutine.
Section 4-2
41

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents