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 17 of 47

PDT 1100 Terminal Programmer's Guide: Chapter 10 Statement Reference, pages 141 to 150

Pages 141 to 150 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 141

Statement Reference

Syntax Error When defining a user-defined function Error Code and Message Meaning error 61: Cannot use DEF FN in control structure

The DEF FN statement is defined in other block-structured statements such as FOR and IF statements.

error 64: Function redefinition

Same function name defined twice.

error 65: Function definitions exceed 200 error 66: Arguments exceed 50 error 71: Syntax error functionname is an integer function name, but expression is a real type. (if functionname is a real function name and expression is an integer type, no error occurs.) stringlength is out of range. stringlength is not an integer constant.

When calling a user-defined function Error Code and Message Meaning error 68: Mismatch The number of real parameters is not equal to that of the dummy argument type or number parameters. dummyparameter was an integer variable in defining a function, but realparameter is a real type in calling the function. (if dummyparameter was a real variable in defining a function and realparameter is an integer type, then no error occurs.) error 69: Function undefined

Calling of a user-defined function precedes the definition of the user-created function.

10-31

Page 142

PDT 1100 Terminal Programmer’s Guide

Execution Error Error Code

Meaning

07h

Insufficient memory space (DEF FN instructions nested to more than 10 levels.)

0Fh

String length out of range (the returned value of the stringlength exceeds the allowable range.)

Example Example 1: DEF FNadd(a%,b%)=a%+b% PRINT FNadd(3,5) 8

Example 2: DEF FNappend$(a$,b$)[80]=a$+b$ PRINT FNappend$(“123”,”AB”) 123AB

10-32

Page 143

Statement Reference

DEF FN...END DEF (Block form) Statement Name: DEFine FuNction... END DEFine

Type: User-created Function Definition Statement

Definition Names and defines a user-defined function.

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

Syntax 2 (Defining a character function) DEF FN charafunctionname[(dummyparameter [,dummyparameter...])] “” stringlength]]

Syntax 3 (Exiting from the function block prematurely) EXIT DEF

Syntax 4 (Ending the function block) END DEF

Syntax 5 (Assigning a returned value) FN functionname = generalexpression

Syntax 6 (Calling a function) FN functionname[(realparameter[,realparameter ...])] where: Same as for DEF FN (Single-line form).

Notes Creating a user-defined function DEF FN...END DEF creates a user-defined function. The function definition block between DEF FN and END DEF is a set of some statements and functions.

10-33

Page 144

PDT 1100 Terminal Programmer’s Guide

!

! !

! !

!

!

!

!

!

!

!

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. This statement block 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...END DEF functions can be recursive. 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 block, is a local variable valid only in that block. Therefore, if a variable having the same name as dummyparameter is used outside DEF FN...END DEF statement block or used as a dummyparameter of any other function in the same program, it is treated independently. In user-defined functions, you can call other user-defined functions. You can nest DEF FN...END DEF instructions to a maximum of 10 levels. When using the DEF FN...END DEF 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. If variables other than dummyparameter(s) are specified in the function definition block, they are treated as global variables whose current values are available. EXIT DEF exits the function block prematurely and returns control to the position immediately after the statement that called the user-defined function. The block-format DEF FN statement should be followed by END DEF which ends the function block and returns control to the position immediately after the statement that called the user-defined function. Using Syntax 5 allows you to assign a return value for a function. The type of functionname should match that of a return value. If no return value is assigned to functionname , the value 0 or a null string is returned for a numeric function or a character function, respectively.

FN functionname calls the user-defined function. !

!

10-34

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

Page 145

Statement Reference because all realparameters are passed not by address but by value “Call-byvalue”.

Syntax Error When defining a user-defined function Error Code and Message Meaning error 59: Incorrect use The EXIT DEF statement is specified outside the function definition block. The END DEF statement is specified outside the function definition block. error 60: Incomplete control structure (DEF FN...END DEF)

END DEF is missing.

error 61: Cannot use DEF FN in control structure

The DEF FN...END DEF statement is defined in other blockstructured statements such as FOR and IF statement blocks.

error 64: Function

The same function name was defined twice.

error 71: Syntax error functionname is an integer function name, but generalexpression is a real type. (if functionname is a real function name and generalexpression is an integer type, no error occurs.) stringlength is out of range. stringlength is not an integer constant. The function name is assigned a value outside the function definition block.

10-35

Page 146

PDT 1100 Terminal Programmer’s Guide

When calling a user-defined function Error Code and Message Meaning error 68: Mismatch The number of the real parameters is not equal to that of the argument type or number dummy parameters. dummyparameter was an integer variable in defining a function, but realparameter is a real type in calling the function. (if dummyparameter was a real variable in defining a function and realparameter is an integer type, no error occurs.) error 69: Function undefined

Calling of a user-defined function precedes the definition of the user-created function.

Execution Error Error Code

Meaning

07h

Insufficient memory space (DEF FN instructions nested to more than 10 levels.)

0Fh

String length out of range (the returned value of the stringlength exceeds the allowable range.)

Example DEF FNappend$(a$,b%)[128] C$=“C$=“C$=”” FOR i%=1 TO b% C$=C$+a$ NEXT FNappend$=C$ END DEF PRINT FNappend$(“AB”,3) ABABAB

10-36

Page 147

Statement Reference

DIM Statement Name: DIMension

Type: Memory Control Statement

Definition Declares and dimensions arrays; also declares the string length for a string variable.

Syntax DIM arraydeclaration[,arraydeclaration...] where: arraydeclaration = numericvariable (subscript) DIM n1%(12) DIM n2(5,6) stringvariable (subscript)[[stringlength]] DIM s1$(2) DIM s2$(2,6) DIM s3$(4)[16] DIM s4$(5,3)[30] subscript

For one-dimensional: integerexpression For two-dimensional: integerexpression, integerexpression

Where integerexpression is a numeric expression which returns a value from 0 to 254. stringlength

An integer constant which has a value from 1 to 255 which indicates the number of characters.

Notes DIM declares array variables and dimensions the arrays that a program utilizes.

10-37

Page 148

PDT 1100 Terminal Programmer’s Guide

!

! !

!

A DIM instruction can appear anywhere before the first use of the array in a source program. However, to prevent errors, place all your DIM instructions together near the beginning of the program and not in the program execution loops. Up to 2-dimensional array variables can be declared. In declaring an array string variable, you can specify the string length. If its specification is omitted, the default value of 20 characters takes effect. If no subscript is specified for a string variable, Compiler regards the string variable as a non-array string variable so that the default for a non-array string variable, 40 characters, takes effect.

Syntax Error Error Code and Message

Meaning error 7: Variable name redefinition

The array declared with DIM had been already declared with DEFREG.

error 71: Syntax error stringlength is out of range.

error 72: Variable name redefinition

A same variable name is declared twice inside a same DIM statement. A same variable name is used for a non-array variable and array variable.

stringlength is not an integer constant.

error 78: Array More than 30 variables are declared inside one DIM statement. symbols exceed 30 for one DIM statement

10-38

Page 149

Statement Reference

Execution Error Error Code

Meaning

07h

Insufficient memory space (the variable area has run out.)

08h

Array not defined.

09h

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

0Ah

Duplicate definition (an array is declared twice.)

Reference Statements

ERASE and DEFREG

10-39

Page 150

PDT 1100 Terminal Programmer’s Guide

END Statement Name: End

Type: Flow Control Statement

Description Terminates program execution.

Syntax END

Notes END terminates program execution and sounds the beeper for a second. ! !

!

10-40

An END can appear anywhere in a source program. When an END instruction occurs, all files being opened close, and the following operation takes place depending upon whether or not any application program (user program or Easy Pack) has been selected as an execution program (to be run when the PDT 1100 is powered on) in System Mode. " If an application program has been selected, the PDT 1100 turns off the power after three seconds from the message indication of the “Program end.” " If an execution program has not been selected, control passes to System Mode. (For System Mode, refer to the PDT 1100 User's Manual.) If no END is placed at the end of a source program, Compiler adds an intermediate language code of END to the end of the compiled program.