DATA
FORMAT: DATA list of values
See Also: READ, RESTORE
PURPOSE:
Provides values for use by READ.
REMARKS:
When assigning initial values to an array, it is convenient to list the values
in a DATA statement and use a READ statement in a FOR...NEXT loop to load the
values into the array. When the first READ is executed, the first value in the
first DATA statement is returned. Succeeding READs use succeeding values in the
sequential order in which they appear in the program, regardless of how many
values are listed in each DATA statement or how many DATA statements are used.
A DATA statement may contain any numeric or string values, separated by commas. Enclose string values in quotes. Spaces at the beginning or end of a string should be included in the quotes.
DATA statements have no effect if encountered in the course of regular execution of the program, so they can be inserted wherever appropriate. Many programmers include them after the READ that uses them. If desired, the values in a DATA statement can be read a second time using the RESTORE statement.
Do not use the multi-statement.
EXAMPLE:
10 DIM B(10)
20 WAIT
30 FOR I = 1 TO 10
40 READ B(I)
50 PRINT B(I)
60 NEXT I
70 DATA 10,20,30,40,50,60
80 DATA 70,80,90,100
90 DATA "AB", "AB:CD"
100 END
[10] Sets up an array.
[40] Loads the values from the DATA statement so that B(1) will be 10, B(2) will
be 20, B(3) will be 30, etc.
ERASE
FORMAT: ERASE array [, array ... ]
See Also: CLEAR, DIM
PURPOSE:
Erases specified arrays.
REMARKS:
Array elements cannot be erased individually; the whole array is cleared and its
memory area is freed. To re-define an array size, first ERASE it and then
re-specify it in a DIM statement.
Do not use the ERASE command within a FOR...NEXT loop. ERASE command can not be used in multi-statement.
EXAMPLE:
10 DIM AA (10)
:
:
200 ERASE AA
FOR...NEXT
FORMAT: FOR numeric variable = expression 1 TO
expression 2
[STEP expression 3] NEXT numeric variable
PURPOSE:
In combination with NEXT, repeats a series of operations a specified number of
times.
REMARKS:
FOR and NEXT are used in pairs to enclose a group of statements that are to be
repeated. If the variable following NEXT is omitted, the variable following FOR
is assumed. The first time this group of statements is executed the loop
variable (the variable named immediately following FOR) is assigned its initial
value (expression 1).
When execution reaches the NEXT statement, the loop variable is increased by the STEP value (expression 3) and then this value is tested against the final value (expression 2). EXPRESSION 3 is plus If the value of the loop variable is less than or equal to the final value, the enclosed group of statements is executed again, starting with the statement following FOR. EXPRESSION 3 is minus If the value of the loop variable is more than or equal to the final value, the enclosed group of statements is executed again, starting with the statement following FOR. If expression 3 for step size is omitted, the increment becomes 1. If the value of the loop variable is greater than the final value, execution continues with the statement that immediately follows NEXT. Because the comparison is made at the end, the statements within a FOR...NEXT pair are always executed at least once.
When the increment is zero, FOR...NEXT will continue in an infinite loop.
The loop variable may be used within the group of statements, for example as an index to an array, but care should be taken in changing the value of the loop variable.
Write programs so that the program flow does not jump out of a FOR...NEXT loop before the counter reaches the final value. To exit a loop before it has been repeated the specified number of times, set the loop variable higher than the final value.
The group of statements enclosed by a FOR...NEXT pair can include another pair of FOR...NEXT statements that use a different loop variable as long as the enclosed pair is completely enclosed; i.e., if a FOR statement is included in the group, the matching NEXT must also be included. FOR...NEXT pairs may be "nested" up to six levels deep. Illegally jumping out of an inner loop will generate an error, a nesting error.
Do not use the CLEAR, DIM or ERASE command within a FOR...NEXT loop. And do not use more than one "FOR" or "NEXT" command in a line.
FOR...NEXT statement may be "nested" up to 6 levels deep.
Do not use the multi-statement after FOR...TO(...STEP).
Release ERROR BRANCH with ON ERROR GOTO 0 before a line including FOR because it
will cause an error in the line to cause malfunction.
GOSUB...RETURN
FORMAT: GOSUB line number
*label
RETURN
See Also: GOTO, ON...GOSUB
PURPOSE:
Diverts program execution to a BASIC subroutine.
REMARKS:
When you wish to execute the same group of statements several times in the
course of a program, it is convenient to use the BASIC capability for
subroutines using GOSUB and RETURN.
The group of statements is included in the program at some location where they are not reached in the normal sequence of execution. A common location is following the END statement that marks the end of the main program.
At each location in the main body of the program where a subroutine is to be executed, include a GOSUB statement with a line number or *label that indicates the starting line number of the subroutine. The last line of each subroutine must be a RETURN. When GOSUB is executed, the device transfers control to the indicated line number or *label and processes the statements until a RETURN is reached. Control is then transferred back to the statement following the GOSUB.
Subroutines may be "nested" up to 10 levels deep.
Since there is an ON...GOSUB structure for choosing different subroutines at given locations in the program, the expression in a GOSUB statement usually consists of just the desired line number or *label.
Do not use ELSE statement, if GOSUB statement is used in THEN statement. Otherwise ERROR number is not correct if error occurred in RETURN statement.
Do not use more than one "GOSUB" or "NEXT" command in a line.
EXAMPLE:
10 WAIT
20 GOSUB 100
30 END
100 PRINT "HELLO"
110 RETURN
When run, this program prints HELLO once.
Return to TopIF...THEN...ELSE
FORMAT:
line
number
line number
IF condition THEN *label [:ELSE *label ]
statement
statement
See Also: AND, OR, NOT, XOR
PURPOSE:
Conditionally executes a statement at the time the program is run.
REMARKS:
When the condition of the IF statement is true, the statement following THEN is
executed; if it is false, the statement following ELSE is executed. When the
ELSE statement is omitted and the condition is false, the statement following
THEN is skipped.
Put LET statement before using "=" statement such as "A=A-1", Otherwise error line number is not correct, if error occurred in IF statement.
If THEN or ELSE is followed by a GOTO statement, either THEN or GOTO may be omitted (ELSE statement must be included).
EXAMPLE 1:
IF A < 5 THEN LET C=A*B
IF A is smaller than 5, then assign the product, A*B, to C.
EXAMPLE 2:
IF B=C+1 GOTO 60 :ELSE 100
or
IF B=C+1 THEN 60 :ELSE 100
If B equals C+1, then go to line 60; otherwise go to line 100.
EXAMPLE 3:
IF A=B THEN LET A=B+1:ELSE LET A=A-1
The condition (e.g. A < 5) of the IF statement can be any relational expression as listed below.
| Relational expression | Description |
|---|---|
| OO=XX OO>XX OO>=XX OO<XX OO<=XX OO<>XX |
Equal to Greater than No less than Less than No greater than Not Equal to |
Note : OO and XX represent expressions (5*4, A, 8, etc.).
More than one relational expression can be linked with the logical operators "*" or "+".
For example:
IF (A>5) *(B>1) THEN...
If A is greater than 5 and B is greater than 1, the statement following THEN is
executed. Logical operator "AND" may be used in place of
"*".
IF (A>5)+(B>1) THEN...
If A is greater than 5 or B is greater than 1, the statement following THEN is
executed. Logical operator "OR" may be used in place of "+".
Using Character Strings in Relational Expressions
The magnitudes of character strings can be compared when used in a relational
expression of an IF...THEN...ELSE statement. The magnitudes of character codes
are compared. For example, characters A, B, and C have codes 65, 66, and 67,
respectively. So A is smaller than B, and B is smaller than C.
EXAMPLE:
10 INPUT"CONTINUE?";A$
20 IF A$="YES" THEN 10
30 IF A$="NO" THEN 60
40 PRINT "YES OR NO, PLEASE"
50 GOTO 10
60 END
Note:
Whenever a variable name is to be followed by a statement, be sure to insert a
space between them, for example:
100 IF A=B_THEN 200
A space is needed.
Pay special attention to this when you use the IF, FOR, ON...GOTO, or ON...GOSUB
command.
Release ERROR BRANCH with ON ERROR GOTO 0 before a line including IF statement because it will cause an error in the line to cause malfunction.
Return to TopWAIT
FORMAT: 1.WAIT expression
2.WAIT
See Also: PRINT, GPRINT, CIRCLE
PURPOSE:
Controls the length of time that displayed information is shown before program
execution continues.
REMARKS:
Format 1 specifies the time in which execution of the PRINT command halts. The
program temporarily halts for the specified time interval, then automatically
restarts.
The value of the expression may be set to any value from 0 to 1800. A value of 1 as the expression corresponds to an interval of approx.1/10 sec. The power on default for the value of the expression is zero.
Keep in mind when you use WAIT that it is impossible to discontinue with ESC, ON or application keys during WAIT. Execute WAIT 0 to release WAIT. To set an infinite interval, use format 2.
Press the Enter key to restart the program again. ESC key cannot discontinue the program during WAIT. Execute WAIT 0 to release WAIT.
The WAIT command is valid for all the PRINT,CIRCLE or GPRINT commands used in the program. Do not enter 2nd keys during WAIT. At the beginning of a program wait value is 0
Note:
The WAIT command is not available on personal computers in general. On PCs, the
FOR...NEXT statement is used for wait time control as follows:
50:FOR J=1 TO 500:NEXT J
EXAMPLE:
10:WAIT 10
Causes PRINT to wait about 1 second.
Return to TopCLOSE
FORMAT: CLOSE [# file number, # file number, ...]
See Also: OPEN
PURPOSE:
Closes a file or files on the currently accessed device.
REMARKS:
This command closes files with the specified file numbers. If no file number is
specified, all files are closed. The file numbers are then released for use with
other files.
All files are closed in the following cases:
- An END command is executed.
- A STOP command is executed.
- The Program is terminated.
CLOSE immediately after completing file input/output.
EXAMPLE:
CLOSE #2, #5
Closes files #2, #5
Return to TopEOF
FORMAT: EOF (file number)
See Also: OPEN
PURPOSE:
Determines if the end of a sequential file has been reached.
REMARKS:
The EOF function checks if all data in a sequential file (with the specified
file number) has been read.
If all data has been read, EOF returns -1 (true) as its function value. If not, EOF returns 0 (false). For the device name COM, EOF returns 0. An error occurs if a file with the specified number has not been opened for input.
EXAMPLE:
IF EOF (1) THEN CLOSE #1
File #1 is closed if all data in that file has been read.
EXAMPLE:
10 OPEN "E:TESTDAT" FOR OUTPUT AS #2
20 PRINT #2, 123,456,789
30 CLOSE
40 OPEN "E:TESTDAT" FOR INPUT AS #2
50 INPUT #2,A,B
60 X = EOF(2)
70 INPUT #2,C
80 Y = EOF(2)
90 CLOSE
100 END
[60] Not all date has been read in this line. X = 0.
[80] All data has been read. Y = -1.
ERL
FORMAT: ERL
See Also: ERN,ON ERROR GOTO
PURPOSE:
Returns the line number at which an error occurred during program execution.
REMARKS:
The ERL function is used with the ERN function and the ON ERROR GOTO statement
in error processing routines to control program flow when an error occurs. A
line number is only set in ERL if the error occurred during program execution.
ERL will be cleared when program is started
EXAMPLE:
See ERN.
ERN
FORMAT: ERN
See Also: ERL,ON ERROR GOTO
PURPOSE:
Returns the error code number of the execution error.
REMARKS:
The ERN function is used with the ERL function and the ON ERROR GOTO statement
in error processing routines to control program flow when an error occurs.
See error list for a list of error messages.
ERN will be cleared when program is started.
EXAMPLE:
10 ON ERROR GOTO 100
15 WAIT
20 FOR N = 1 TO 20
30 READ A
40 PRINT A
50 NEXT N
60 END
100 IF ERL = 30 AND ERN = 53 THEN PRINT "YOU HAVE NO DATA"
FRE
FORMAT: FRE
PURPOSE:
Finds out the number of non-use sectors in memory for save files. The
estimated value varies depending on how the temporary file is used for
applications like address book and memo, so that it is only a rough standard.
REMARKS:
You can input 62 bytes into 1 sector. If you want to see the free bytes ,
please calculate of FRE *62.
EXAMPLE:
10 N = FRE
20 PRINT "Free area size is";N
Note:
If FRE function returns 0 , you should not output or append any files.
Otherwise, an error will occur in the memory shortage soon.
INPUT#
FORMAT: INPUT# file number, Variable [, Variable...]
See Also: OPEN, PRINT#
PURPOSE:
Reads items from sequential files.
REMARKS:
The file number is the number given to the file when opened for input with the
OPEN statement. The file number must be a number specified in an OPEN statement.
Specify variables as follows:
-Simple variables(CD, EF$, B$, etc.)
-Array elements(B(10),C$(5,5),etc.)
An error occurs if the file contains less data than the number of specified variables. If the file contains more data, the rest of the data is ignored.
The data and variables must be of the same type(e.g.,numeric values must be assigned to numeric variables.)
Use a comma (,), space (&H20), CR(&H0D), LF(&H0A) or CR + LF as a delimiter when data are read into numeric variables. Spaces preceding data are ignored.
Use a comma(,), CR, LF or CR + LF as a delimiter to read data into character variables. The 256th character is also a delimiter. Spaces preceding data are ignored. If a double quotation mark appears at the beginning of data, data is read up to the next double quotation mark. A comma in a character string enclosed by double quotation marks is assumed not to be a delimiter.
EXAMPLE:
10 WAIT
20 A$ = "AB" + CHR$ 34 + "CDE" + CHR$ 34
30 B$ = CHR$ 34 + "CD,EF" + CHR$ 34
40 PRINT A$
50 PRINT B$
60 OPEN "E:ABCDEF" FOR OUTPUT AS #2
70 PRINT #2, A$ ; "," ; B$
80 CLOSE
90 OPEN "E:ABCDEF" FOR INPUT AS #2
100 INPUT #2, C$, D$
110 PRINT C$
120 PRINT D$
130 CLOSE
140 END
Execution
AB"CDE"
"CD,EF"
AB"CDE"
CD,EF
KILL
FORMAT: KILL "E:filename"
PURPOSE:
Deletes a file on FLASH.
Filename Length is 1~7.
REMARKS:
Specify the device(E:) and filename.
The file which is opened can't be killed.
EXAMPLE:
KILL"E:PROFIL1"
Deletes the file PROFIL1 on flash.
Return to TopLOF
FORMAT: LOF file number
See Also: OPEN
PURPOSE:
Returns the size of the specified file.
REMARKS:
The LOF command returns the size of a file with the specified file number. The
actual size of the file is displayed in bytes. (Max approx. 15000 Byte.)
If the device name is COM (communication), this command returns "0".
An error will occur if the specified file is not opened.
EXAMPLE:
10 WAIT
20 OPEN "E:FILE01" FOR INPUT AS #2
30 N=LOF(2)
40 PRINT "FILE01 FILE SIZE IN BYTES IS ";N
50 CLOSE #2
60 END
[20] Opens the file FILE01 for input.
[30-40] Finds the size of the file and prints out the value.
[50] Closes the file.
ON ERROR GOTO
FORMAT:| 1. ON ERROR GOTO | line number *label |
| 2. ON ERROR GOTO 0 |
See Also: ERN,ERL,RESUME
PURPOSE:
Sets up an error trapping routine.
REMARKS:
When the error trap function is enabled, control is transferred to the error
routine if an error is detected. An error message is not displayed.
Within an error routine, control can be branched depending on the value of ERN and ERL. The routine is terminated by the RESUME command.
Format 2 clears declaration of error trapping. Declaration of error trapping is also cleared in any of the following cases:
MyProgram is executed.
The program stops executing if an error occurs within an error routine. Release ERROR BRANCH with ON ERROR GO TO 0 before a line including IF and FOR because it will cause an error in the line to cause malfunction. The use of RESUME NEXT to deal with errors in a line including OPEN is prohibited because it will cause an error in the line to cause malfunction of RESUME NEXT.
If an ERROR occurs during dealing with an ERROR BRANCH, it may cause malfunction. Beware of it when you program.
Return to TopOPEN
FORMAT:
1. OPEN "E:filename" FOR mode AS # file number
2. OPEN "COM:delimiter, end-of-file code" AS # 1
See Also: CLOSE
PURPOSE:
Format 1 opens the file specified by "E:filename" for use with the
specified file number. Subsequent input/output to the file is accomplished
by referring to the file number. Formats 2 allow data to be transferred
through the serial I/O interface (COM).
REMARKS:
The file number must be from 1 to 5.
A total of 5 file number control areas for a flash memory and serial I/O interface. However, only one file can be opened as #1 for devices COM.
In format 1 , "mode" specifies the method of access to the file, as
follows:
INPUT Specifies sequential input from an existing
file.
OUTPUT Specifies sequential output to a file.
APPEND Specifies addition to a sequential file.
If OUTPUT is specified using an existing filename, that file is erased before the new one is created.
An error occurs when using the APPEND or INPUT mode if the specified file does not exist. An error occurs if an attempt is made to open a file which has already been opened, or allocate a file number which has already been allocated.
Note:
File is made related with BASIC Program. If you delete the BASIC program on the
unit then related file will be deleted.
Although one to seven letters can be used as a file name created on E:drive, it is recommended to use long names in order to prevent them to be the same as file names in other programs.
File name is max 7 characters. And spaces after characters is not recognized as the file name. ("E:TESTA " and "E:TESTA" are treated as a same file name.)
COM port is only used for #1
CLOSE immediately after completing file input/output. Use the POWER key to discontinue a program when a COM port is used.
Do not use "INPUT" and "INKEY$" including "INKEY$(1)" when COM is opened because it may cause the communication speed to become unstable.
EXAMPLE:
For flash disk E
OPEN "E:PRO1" FOR OUTPUT AS #1
Creates a new file E named PRO1 with file number 1.
In format 2, the following parameters can be selected:
Delimiter: C, F, L
Specifies the type of delimiter to indicate the end of data, end of a
program line, etc.
C: Specifies the CR (carriage return)code.
F: Specifies the LF (line feed)code.
L: Specifies the CR code + LF code. (CR code, LF code or CR+LF
code)
End-of-file Code: &H00-&HFF
Specifies the end-of-file code used to indicate the end of the program, etc.
Communication parameter is set as follows. (Not changeable)
| Speed (bps) | : 9600bps |
| Parity | : none |
| Data bits | : 8 bit |
| Stop bits | : 2 bit |
| Flow-control | : none |
Transmitting large sized data at once may cause loss of some data bits.
When you connect PC with this unit, please set DTR to "Disable" of PC side software.
EXAMPLE:
OPEN"COM:C,&H1A"AS#1
C....Delimiter (CR code)
&H1A....End-of-file code (&H1A)
PAINT
FORMAT: PAINT (expression1, expression2), expression3
See Also: CIRCLE, GCURSOR, LINE
PURPOSE:
Fills an area encircling a designated point with a designated pattern.
REMARKS:
* Fills an area encircling a point designated by (expression1,
expression2) with a pattern designated by the expression3. The pattern which
fills inside the circle by CIRCLE command and displayed letters are also
boundaries.
* The values of the expressions 1 and 2 are within a range from -32,768 to 32,767. However, the expression1 has to be from 0 to 238 and the expression 2 from 0 to 69 when the designated point is within the screen.
* When a point outside the screen is designated, the PAINT command is ignored.
* The expression3 indicates a pattern as below:
1: Stripe (Vertical)
2: Stripe (Horizontal)
3: Black
PRINT#
FORMAT:| PRINT# file number | , expression [, expression][, or ;] , string [; string][, or ;] |
See Also: OPEN, INPUT#
PURPOSE:
Writes values of specified variables into a specified file.
REMARKS:
PRINT# is valid only for a file opened for OUTPUT or APPEND with the OPEN
command. The file number is the number given to the file when opened.
When a character or string element is used, it must not be specified using a
comma (,) or semicolon (;):
PRINT#2,"ABC"
PRINT#2,A$
If PRINT#2,"ABC";A$ is executed, no data delimiter is written and
"ABC" and A$ cannot be distinguished.
A numeric value is recorded in such a from that the sign (space when it is positive), numeric character string, and space appear in that from. The recording format is shown below:
(1) When a comma or semicolon does not follow the data, CR(&H0D) and LF(&H0A) are provided.
EXAMPLE:
PRINT #2,-1.2
-1.2_ CR LF ( _ is a space character)
PRINT #2,"ABC"
ABC CR LF
(2) When a comma follows the data, 20 bytes are occupied. A numeric value is right justified and a character string is left justified.
EXAMPLE:
PRINT#2,"ABC","DEF"
ABC- (20 bytes) DEF CR LF
When the character string exceeds 20 bytes, the excess part is written to the next 20-byte area. The maximum size is 254 bytes.
(3) When a semicolon follows the data, it is stored without spaces.
EXAMPLE:
PRINT #2,-1.2;3
-1.2 3 CR LF
PRINT#2, "ABC";"DEF"
ABCDEF CR LF
in this case, character strings "ABC" and "DEF" are not read separately.
EXAMPLE:
10 OPEN "E:DATA" FOR OUTPUT AS #2
11 N=10
12 M=10
15 DIM C$(N,M)
20 FOR J=0 TO N
30 FOR K=0 TO M
40 PRINT #2,C$(J, K)
50 NEXT K
60 NEXT J
70 CLOSE
Note: Maximum file size is approx. 15,000 Byte. When memory is full, SYNTAX ERROR occurs.
Return to TopRESUME
FORMAT:
1. RESUME
2. RESUME NEXT
3. RESUME line number
*label
See Also: ON ERROR GOTO
PURPOSE:
Resumes program execution at the end of an error handling routine.
REMARKS:
RESUME resumes program execution after completing an error handling routine to
which control was passed by the ON ERROR GOTO command. This command validifies
the ON ERROR GOTO command again. If control is returned to the main program by
any other command(GOTO, etc.),execution will be aborted if an error subsequently
occurs.
The error handling routine lets you take the necessary action to prevent recurrence of the same error.
Control is returned depending on the format:
(1) Format 1 returns control to the statement which caused the error. If an
error occurs again
in the same statement, the error handling routine is executed
again.
(2) Format 2 returns control to the statement following the error statement.
(3) Format 3 returns control to the specified line.
EXAMPLE:
10 ON ERROR GOTO 100
20 INPUT A,B
30 PRINT A/B
:
:
100 RESUME 20
If zero is assigned to variable B or an overflow occurs from A/B,control returns to the input routine on line 20 and prompts for correct data entry.
Note: Please be sure to put "END" statement after RESUME command The use of RESUME NEXT to deal with errors in a line including OPEN is prohibited because it will cause an error in the line to cause malfunction of RESUME NEXT.
Return to TopSTOP
FORMAT: STOP
See Also: END
PURPOSE:
Signals the end of a program.
REMARKS:
The program will be terminated when the STOP statement is executed. All
opened files are closed. This command is same as END command.