Remote-processing BASIC for the CX-10 Modbus Manuale Utente Pagina 32

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 84
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 31
BASIC PROGRAMMING GUIDE
2-23
GOSUB
Syntax: GOSUB
line number
...
line number
program statements
RETURN
Function: Transfers program control to the specified
line number
. The RETURN causes execution to resume at
the program statement after GOSUB.
Mode: Run
Use: 100 FOR A=1 to 20 : GOSUB 200 : NEXT A : END
200 PRINT A, SQR(A) : RETURN
DESCRIPTION
GOSUB provides subroutine capability within BASIC-52 programs. A subroutine may be called from within
another subroutine.
GOSUB saves the location of the program statement after GOSUB on the C-Stack and immediately transfers
program control to
line number
. When a RETURN is encountered, program execution resumes at program
statement after GOSUB.
GOSUBs can be nested. The number nesting is limited by available C-Stack RAM, but is usually enough for
at least 30 routines.
RELATED
GOTO, ON-GOTO, ON-GOSUB
ERROR
C-STACK An unexpected RETURN is encountered or the number of subroutines executed was excessive.
EXAMPLE
10 GOSUB 100
20 PRINT "Back from routine"
30 END
100 PRINT "In subroutine"
110 RETURN
>run
In subroutine
Back from routine
Vedere la pagina 31
1 2 ... 27 28 29 30 31 32 33 34 35 36 37 ... 83 84

Commenti su questo manuale

Nessun commento