BASIC-SO

Commands and Statements

DATA

The DATA statement prefaces lines of data that are read sequentially by the READ command and assigned as values to variables. The data is separated by commas and may be numeric, strings, or quoted strings. If strings are not surrounded by quotes (" ") they may not contain commas (,) or semicolons (;) and leading or trailing blanks are ignored. DATA instruction lines may be located anywhere in program text. BASIC maintains a pointer which keeps track of the next DATA element to be read. This pointer is set to the first data element of the first DATA statement when a program is RUN. It increments to subsequent DATA elements when its elements are read. It can be moved with the RESTORE command.

DATA numbeq string literal Iquoted string

[, number Istring literal Iquoted string] ...

10 DATA 10, IS LESS THAN, 77

20DATA 44, IS GREATER THAN, -32

30DATA 1.7, "IS EQUAL TO ", 1.7EO

40FOR 1=1 TO 3

50READ X, A$, Y

60PRINT X; A$; Y

70NEXT RUN

10IS LESS THAN 77

44IS GREATER THAN -32 1.71S EQUAL TO 1.7

Ok

DEF FN(X)

The DEF FN(X) statement defines arithmetic or string functions for later use in pro- gram text. The name given to the function must be FN followed by a valid variable name. The variable(s) given are the arguments used within the function. Any one- line expression can be used. User-defined functions can be of any type, arithmetic or string, and any number of arguments are allowed. The correct number of parameters must be specified when the function is referenced within a program. Functions may not be redefined.

DEF function name [(variable [, variable ... ])]= expression

The rules for function name are the same as for variable name.

10DEF FNAC (X) = (1/(2*3.14159))*X

20FOR X = 1 TO 10

30PRINT FNAC (X),

40NEXT X

50END

RUN

.159155 .31831 .477465 .63662 .795776

.954931 1.11409 1.27324 1.4324 1.59155

6-3

Page 43
Image 43
Intel 9800758-02 manual Def Fnx, Rules for function name are the same as for variable name