Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeEnglishEspañolContact

The text of a manual · part 16 of 47

PDT 1100 Terminal Programmer's Guide: Chapter 10 Statement Reference, pages 131 to 140

Pages 131 to 140 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 131

Statement Reference

Syntax Error Error Code and Message Meaning error 71: Syntax error Specification other than ON and OFF is described.

Reference Statements

INPUT, LINE INPUT, and LOCATE

Functions

INPUT$ and INKEY$

10-21

Page 132

PDT 1100 Terminal Programmer’s Guide

DATA Statement Name: Data

Type: Declarative Statement

Description Stores numeric and string literals for READ statements.

Syntax DATA literal[,literal...] where: literal = A numeric or string constant.

Notes DATA stores numeric and string literals so that READ instructions can assign them to variables. ! ! !

! !

!

10-22

A DATA instruction can appear anywhere in a source program. A string data should be enclosed with a pair of double quotation marks ("). You may have any number of DATA instructions in a program. The READ instruction assigns data stored by DATA instructions in the same order that those DATA instructions appear in a source program. Using the RESTORE statement can read a same DATA statement more than once. You can specify more than one literal in a program line (within 512 characters) by separating them with commas (,). You can describe DATA statements also in included files.

Page 133

Statement Reference

Syntax Error Error Code and Message Meaning error 3: “” missing

No double quote precedes or follows a string data.

Reference Statements

READ, REM, RESTORE and $INCLUDE

10-23

Page 134

PDT 1100 Terminal Programmer’s Guide

DEFREG Statement Name: DEFine REGister

Type: Declarative Statement

Definition Defines register variables.

Syntax DEFREG registerdefinition[,registerdefinition ...] where: registerdefinition = non-arraynumericvariable [= numericconstant] DEFREG n1%=10 DEFREG n2=12.5 arraynumericvariable(subscript) [= numericinitialvaluedefinition] DEFREG n3(5,6) non-arraystringvariable[[stringlength]] [= stringconstant] DEFREG s1$=“abc123” DEFREG s2$[6]=“abc123” arraystringvariable(subscript)[[stringlength] ] [= stringinitialvaluedefinition] DEFREG s2$(1,3)[16] subscript

For one-dimensional: integerconstant DEFREG n4%(3)

For two-dimensional: integerconstant, integerconstant DEFREG n5%(4,5)

10-24

Page 135

Statement Reference

Where integerconstant is a value from 0 to 254. numericinitialvaluedefinition

For one-dimensional: {numericconstant[, numericconstant...]} DEFREG n6%(3)={9,8,7,6}

For two-dimensional: {{ numericconstant[,numericconstant...]}, { numericconstant[,numericconstant...]} ...} DEFREG n7(1,2)={{10,11,12},{13,14,15}} stringinitialvaluedefinition

For one-dimensional: { stringconstant[, stringconstant...]} DEFREG s3$(3)={“a”,“bc”,“123”,“45”}

For two-dimensional: {{ stringconstant[, stringconstant...]}, { stringconstant[, stringconstant...]} ...} DEFREG s4$(1,1)={{“a”,“b”},{“c”,“1”} stringlength = An integer constant from 1 to 255.

Notes DEFREG defines non-array or array register variables. ! ! !

A DEFREG instruction can appear anywhere in a source program. Up to 2-dimensional array variables can be defined. For both non-arraystringvariable and arraystringvariable, the string length can be specified.

10-25

Page 136

PDT 1100 Terminal Programmer’s Guide

!

!

! !

Defaults: stringlength for non-array variables:

40 characters stringlength for array variables:

20 characters

The memory area for register variables is allocated in user program files in the memory. Register variables, therefore, are always updated. An uploaded user program, for example, contains the updated register variables if defined. The total number of bytes allowable for register variables is 64 kilobytes. You can specify an initial value to an array variable by enclosing it in braces { }. No comma (,) is allowed for terminating the list of initial values. If the number of the specified initial values is less than that of the array elements or if no initial value is specified, Compiler sets a zero (0) or a null string as an initial value for a numeric variable or a string variable of the array elements not assigned initial values, respectively.

Syntax Error Error Code and Message Meaning error 6: Variable name redefinition

A same register variable name is declared twice in a program.

error 71: Syntax error stringlength is not an integer constant. The number of the specified initial values is greater than that of the array elements. The list of initial values is terminated with a comma. The type of the specified variable does not match that of its initial value. (note that a real variable can have an integer constant as an initial value.) subscript is not an integer constant.

error 73: Improper string length stringlength is out of range.

error 74: Improper array element number subscript is out of range.

error 75: Out of space for register variable area

Definition by DEFREG exceeds the register variable area.

10-26

Page 137

Statement Reference error 77: Initial string too long

The dimension of the specified array variable does not match that of its initial value. The number of initial value elements for the specified register string variable is greater than its string length.

error 83: “)” missing

No closing parenthesis follows subscript.

error 84: “]” missing

No closing square bracket follows stringlength.

error 90: “{” missing

No opening brace precedes the initial value.

Execution Error Error Code

Meaning

09h

Subscript out of range (an array referred to is different from a defined array in dimension.)

Examples Example 1: Valid DEFREG statements DEFREG a,e$ DEFREG b=100,c(10),d$(2,4)[10] DEFREG bps$=“19200” DEFREG a%(2)={1,2} DEFREG a%(2)={1,,3} DEFREG a%(2)={,,3} DEFREG b%(1,1)={{},{1,2}} DEFREG b%(1,1)={,{1,2}} DEFREG b%(1,1)={{1,2}}

Example 2: Position of elements in an array DEFREG a%(1,1)={{1},{,3}}

The elements of the above array have the following initial values: a%(0,0) : 1 a%(0,1) : 0 a%(1,0) : 0 a%(1,1) : 3

10-27

Page 138

PDT 1100 Terminal Programmer’s Guide

DEFREG b$(1,1)[3]={,{“123”}}

The elements of the above array have the following initial values: b$(0,0) : “” b$(0,1) : “” b$(1,0) : “123” b$(1,1) : “”

Example 3: DEFREG statements causing syntax errors DEFREG c%(2)={1,2,3,4} DEFREG d%(2)={1,2,} DEFREG e%(1,1)={{,},{1,2}} DEFREG f%(1,1)={{1,2},}

Reference Statements

10-28

DIM

Page 139

Statement Reference

DEF FN (Single-line form) Statement Name: DEFine FuNction

Type: User-created Function Definition Statement

Definition Names and defines a user-created function.

Syntax Syntax 1 (Defining a numeric function) DEF FN functionname[(dummyparameter[,dummyparameter ...])]=expression

Syntax 2 (Defining a string function) DEF FN functionname[(dummyparameter[,dummyparameter...])] [[stringlength]]= expression

Syntax 3 (Calling the function) FN functionname[(realparameter[,realparameter ...])] where: functionname = For numerics functionname% = Integer function name functionname = Real function name

For strings functionname$ = Character function name where the FN can be lowercase. dummyparameter = A non-array integer variable, a non-array real variable, or a non-array string variable. stringlength = An integer constant having a value from 1 to 255. expression and realparameter = A numeric or a string expression.

10-29

Page 140

PDT 1100 Terminal Programmer’s Guide

Notes DEF FN creates a user-defined function.

Definition of a user-defined function should preceed a calling statement of the userdefined function in a source program. ! You cannot define the same function name twice. ! The DEF FN statement should not be defined in the block-structured statements (FOR...NEXT, IF...THEN...ELSE...END IF, SELECT...CASE... END SELECT, and WHILE...WEND), in the error-handling routine, event-handling routine, or in the subroutines. ! DEF FN functions cannot be recursive. ! The type of functionname should match that of the function definition expression. ! In defining a character function, you can specify the maximum stringlength. If its specification is omitted, the default value of 40 characters takes effect. ! dummyparameter, which corresponds to the variable having the same name in the function definition expression, is a local variable valid only in that expression. Therefore, if a variable having the same name as dummyparameter is used outside DEF FN statement or used as a dummyparameter of any other function in the same program, it is treated independently. ! expression describes some operations for the user-defined function. It should be within one program line including definition described left to the equal sign. ! expression can call other user-defined functions. You can nest DEF FN instructions to a maximum of 10 levels. ! If variables other than dummyparameter(s) are specified in expression, they is treated as global variables whose current values are available. ! stringlength should be enclosed with a pair of square brackets []. FN functionname calls a user-defined function. !

!

!

10-30

The number of realparameters should be equal to that of dummyparameters, and the types of the corresponding variables used in those parameters should be identical. If you specify a global variable in realparameter when calling a user-defined function, the user-defined function cannot update the value of the global variable because all realparameters are passed not by address but by value “Call-byvalue”.