Remote-processing BASIC for the CX-10 Modbus Manual de usuario Pagina 45

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 84
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 44
BASIC PROGRAMMING GUIDE
2-36
ON GOSUB
Syntax: ON
expr
GOSUB
line0[,line1[,line2...]]
Where:
expr
= 0 to number of subroutines after GOSUB
line
n = subroutine line number to execute
Function: Calls subroutine based on value of
expr
.
Mode: Run
Use: ON A GOSUB 100, 200, 500
DESCRIPTION
The ON-GOSUB instruction conditionally branches to one of several possible subroutines depending on the
value of
expr
.
expr
must evaluate to greater than or equal to zero. If
expr
evaluates to zero, execution
branches to
line0
. When
expr
evaluates to one, execution branches to
line1
, etc. If necessary,
expr
is truncated
to an integer.
ON-GOSUB saves the location of the program statement after ON-GOSUB on the control stack and
immediately transfers program control to the selected subroutine. The subroutine is then executed. When
Basic encounters the RETURN instruction, program execution resumes at the program statement after ON-
GOSUB. ON-GOSUB instructions can be nested.
One or more of
line
n may be the same, to execute the same subroutine with different
expr
values. At least
one
line
n must be provided.
line
n can be in any order.
RELATED
ON GOTO, GOSUB, RETURN
ERRORS
BAD ARGUMENT The value of
expr
is less than 0
BAD SYNTAX The
expr
value is larger than the number of subroutine locations provided, or commas
were omitted between {subr n line#} values, or no subroutine locations were given.
C-STACK Attempted recursion caused control stack overflow
EXAMPLE
10 P=2
20 ON P GOSUB 1000, 3000, 2000
30 END
1000 PRINT "Line 1000"
1010 RETURN
2000 PRINT "Line 2000"
2010 RETURN
3000 PRINT "Line 3000:
3010 RETURN
>run
Line 3000
Vista de pagina 44
1 2 ... 40 41 42 43 44 45 46 47 48 49 50 ... 83 84

Comentarios a estos manuales

Sin comentarios