The text of a manual · part 18 of 47
PDT 1100 Terminal Programmer's Guide: Chapter 10 Statement Reference, pages 151 to 160
Pages 151 to 160 of 413, from PDT 1100 Terminal Programmer's Guide
The original document is the PDF (3.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
For the Symbol PDT-1100
Page 151
Statement Reference
ERASE Statement Name: Erase
Type: Memory Control Statement
Description Erases array variables.
Syntax ERASE arrayvariablename[,arrayvariablename...] where: arrayvariablename = An array numeric or string variable.
Notes ERASE erases an array variable(s) specified by arrayvariablename and frees the memory used by the array. !
arrayvariablename is the name of an array variable already declared by the DIM statement. If it has not been declared by DIM, the ERASE statement is ignored.
!
After erasing the name of an array variable with ERASE, you can use that name to declare a new array variable with the DIM statement. arrayvariablename should not include subscripts or parentheses ( ) as shown below.
!
DIM a(3),b1%(5,10),c$(3)[20] ERASE a,b1%,c$ !
ERASE cannot erase a register variable declared by the DEFREG statement, a common variable declared by the COMMON statement, or a non-array string variable.
10-41
Page 152
PDT 1100 Terminal Programmer’s Guide
Syntax Error Error Code and Message
Meaning error 71: Syntax error Erasing a register variable declared by DEFREG, a common variable by COMMON, or a non-array string variable attempted.
Reference Statements
10-42
DIM and DEFREG
Page 153
Statement Reference
FIELD Statement Name: Field
Type: File I/O Statement
Description Allocates string variables as field variables.
Syntax FIELD[#]filenumber,fieldwidth AS fieldvariable[,fieldwidth AS fieldvariable...] where: filenumber = A numeric expression which returns a value from 1 to
16. fieldwidth = A numeric expression which returns a value from 1 to
254. fieldvariable = A non-array string variable.
Notes FIELD declares the length and field variable of each field of a record in a data file. !
filenumber is the file number of a data file opened by the OPEN statement.
!
fieldwidth is the number of bytes for a corresponding field variable.
!
You can assign a same field variable to more than one field. There is no difference in usage between a field variable and a general variable except that no register variable, common variable, or array variable can be used for a field variable. A record can contain up to 16 fields. The total number of bytes of all fieldwidths plus the number of fields should not exceed 255. If a FIELD instruction executes for an opened file having the number of fields or field width unmatching that of the FIELD specifications except for field variables, an execution error occurs. If more than one FIELD instruction is issued to a same file, the last one takes effect.
!
!
!
!
10-43
Page 154
PDT 1100 Terminal Programmer’s Guide
Syntax Error Error Code and Message Meaning error 71: Syntax error filenumber is missing.
Execution Error Error Code
Meaning
05h
Parameter out of range (fieldwidth out of the range)
34h
Bad file name or number (filenumber of an unopened file specified.)
36h
Improper file type ( filenumber of a file other than data files specified.)
3Ah
File number out of range.
3Ch
FIELD overflow ( FIELD instruction specifies the record length exceeding
255 bytes.) 3Dh
A FIELD statement specifies the field width which does not match one that specified in file creation.
Example fileNumber% = 4 OPEN “Datafile.dat” AS #fileNumber% FIELD #fileNumber%,20 AS code39$, 16 AS itf$,5 AS kyin$
Reference Statements
10-44
GET, PUT, OPEN, CLFILE, and CLOSE
Page 155
Statement Reference
FOR...NEXT Statement Name: For ... Next
Type: Flow Control Statement
Description Defines a loop containing instructions to be executed a specified number of times.
Syntax FOR controlvariable = initialvalue TO finalvalue [STEP increment]
• • • NEXT [controlvariable] where: controlvariable = A non-array numeric variable. initialvalue, finalvalue, and increment = Numeric expressions.
Notes FOR...NEXT defines a loop containing instructions (called “body of a loop”) to be executed by the number of repetitions controlled by initialvalue, finalvalue, and increment.
Processing procedures: 1. The Interpreter assigns initialvalue to controlvariable. 2. The Interpreter checks terminating condition; that is, it compares the value of controlvariable against the finalvalue. " When the value of increment is positive: If the value of controlvariable is equal to or less than the finalvalue, go to step (3). If it becomes greater the finalvalue, the program proceeds with the first line after the NEXT instruction (the loop is over). "
When the value of increment is negative:
10-45
Page 156
PDT 1100 Terminal Programmer’s Guide
If the value of controlvariable is equal to or greater than the finalvalue, go to step (3). If it becomes less than the finalvalue, the program proceeds with the first line after the NEXT instruction (the loop is over). 3. The body of the loop executes and the NEXT instruction increases the value of controlvariable by the value of increment. Then, control returns to the FOR instruction at the top of the loop. Go back to step (2). ! The default value of increment is 1. ! You can nest FOR...NEXT instructions to a maximum of 10 levels. ! When using the FOR...NEXT statement together with other block-structured statements ( IF...THEN...ELSE...END IF, SELECT...CASE...END SELECT, and WHILE...WEND), you can nest them to a maximum of 30 levels. ! A same controlvariable should not be reused in a nested loop. Otherwise, an execution error occurs when the NEXT instruction for an outer FOR...NEXT loop executes. ! Nested loops should not be crossed. Shown below is a correctly nested sample. FOR i%=1 TO 10 FOR j%=2 TO 100 FOR k%=3 TO 1000 NEXT k% NEXT j% NEXT i% FOR l%=1 TO 3 . . . NEXT l%
10-46
Page 157
Statement Reference
Syntax Error Error Code and Message Meaning Too many nesting levels.
error 26:
error 52: Incorrect use NEXT without FOR. of FOR...NEXT error 53: Incomplete index variable control structure
Incomplete pairs of FOR and NEXT.
error 54: Incorrect FOR controlvariable for FOR is different from that for NEXT. error 88: 'TO' missing TO finalvalue is missing.
Execution Error Error Code
Meaning
01h
NEXT without FOR.
07h
Insufficient memory space (too many nesting levels.)
10-47
Page 158
PDT 1100 Terminal Programmer’s Guide
GET Statement Name: Get
Type: File I/O Statement
Description Reads a record from a data file.
Syntax GET [#] filenumber[,recordnumber] where: filenumber = A numeric expression which returns a value from 1 to 16. recordnumber = A numeric expression which returns a value from 1 to
32,767.
Notes GET reads the record specified by recordnumber from the data file specified by filenumber and assigns the data to the field variable(s) specified by the FIELD statement. !
filenumber is the file number of a data file opened by the OPEN statement.
!
If a data file having no record is specified, an execution error occurs. The first record in a data file is counted as 1. If no recordnumber is specified, the GET instruction reads a record whose number is one greater than that of the record read by the preceding GET instruction. If no recordnumber is specified in the first GET instruction after opening of a file, the first record (numbered 1) in the file is read.
! !
!
recordnumber should be equal to or less than the number of written records. If it is greater, an execution error occurs.
!
If a GET instruction without recordnumber is executed after occurrence of an execution error caused by an incorrect record number in the preceding GET instruction, then the new GET instruction reads the record whose record number is one greater than that of the latest record correctly read.
10-48
Page 159
Statement Reference
!
If a GET instruction without recordnumber is executed after execution of the preceding GET instruction specifying the last record (the number of the written records), then an execution error occurs.
Syntax Error Error Code and Message
Meaning error 71: Syntax error filenumber is missing.
Execution Error Error Code
Meaning
34h
Bad file name or number (filenumber of an unopened file specified.)
36h
Improper file type ( filenumber of a file other than data files specified.)
3Ah
File number out of range.
3Eh
A PUT or GET instruction executed without a FIELD instruction.
3Fh
Bad record number (no record to be read in a data file.)
Example GET #filNo,RecordNo GET #4 GET #3,100
Reference Statements
OPEN, FIELD, and PUT
10-49
Page 160
PDT 1100 Terminal Programmer’s Guide
GOSUB Statement Name: Gosub
Type: Flow Control Statement
Description Branches to a subroutine.
Syntax GOSUB label
Notes GOSUB calls a subroutine specified by label. !
!
!
!
!
10-50
Within the subroutine, use a RETURN instruction to indicate the logical end of the subroutine and return control to the statement just after the GOSUB that called the subroutine. You may call a subroutine any number of times as long as the Interpreter allows the nest level and other conditions. Subroutines can appear anywhere in a source program. However, separate subroutines from the main program by, for example, placing them after the END or GOTO statement, to prevent the main part of the program from falling into those subroutines. A subroutine can call other subroutines. You can nest GOSUB instructions to a maximum of 10 levels. When using the GOSUB statement together with block-structured statements (FOR...NEXT, IF...THEN...ELSE...END IF, SELECT...CASE...END SELECT, and WHILE...WEND), you can nest them to a maximum of 30 levels.