Metrologic IS1000 Series Guía de usuario Pagina 27

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 198
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 26
Chapter
4
Basics
of
the
BASIC
Language
21
Since all the variables in the BASIC program are treated as global variables, passing
arguments to subroutines is meaningless and enclosing arguments in the brackets of the
subroutines will lead to a syntax error while compiling.
A subroutine in BASIC can be recursive, which means it can call itself or other subroutines
that in turn call the first subroutine. The following sample program contains a recursive
subroutine - Factorial, to calculate the value of n! ("n factorial").
PRINT "Please enter a number (1 - 13):"
INPUT N%
FactResult! = 1
Fact% = N%
GOSUB Factorial
PRINT N%, "! = ", FactResult
Loop:
GOTO Loop
Factorial:
IF Fact% < 1 THEN RETURN
FactResult! = FactResult! * Fact%
Fact% = Fact% -1
GOSUB Factorial
RETURN
4.7 Programming Style
The following are the guidelines used in writing programs in this manual, including the
sample program. These guidelines are recommended for program readability, but they are
not compulsory.
Reserved words and symbolic constants appear in uppercase letters:
PRINT "Portable Terminal Demo Program"
BEEP(800,30,0,5,800,15,0,5,800,15)
Variable names are in lowercase with an initial capital letter. If variable names are
combined with more than one part, other capital letters may be used to make it easier to
read:
ProcessFlag% = 0
Temp$ = GET_RECORD$(3,1)
Line labels are used instead of line numbers:
ON READER(2) GOSUB GetSlotReader
Vista de pagina 26
1 2 ... 22 23 24 25 26 27 28 29 30 31 32 ... 197 198

Comentarios a estos manuales

Sin comentarios