[Features] Comments are put in.
[Format] REM [sentence]
The following sentence isn't executed.
It is omissible by (').
[Features] To assign the value to a variable.
[Format] [LET] variable[$]=value
'let' is omissible. (In SQL mode, it isn't omissible.)
Capital letter and Small letter are distinguished and are processed as another variable.
Please also read "[func]statement-Notes of global variable definition position."
dim d(4) : d(0)=8
hello 2 4 8
[Features] Arrays variable is declared.
[Format] DIM variable[$](a[,b][,c]...) [,variable[$]...]
Subscripts(a[,b][,c]...) are specified.
Multidimensional array is possible.
Range that can be used is (0~subscript)
When it is character array, attach '$' in the variable name.
[e.g.] Normal Array assignment
It's possible to substitute data together by the description enclosed by brackets.
10 dim da(4,8),st$(16)
40 print st$(4)
50 print da(1,2)
The n-th dimension count of subscript is in the order from the right.
(example, the order is 8 4) Count from the right side.
As in the example, the case of array of 2 or more dimensional,
arrange the data with multiple brackets.
The number in brackets does not matter smaller than the size of specified subscript.
At the point where being closed by mark '},', it be moved up to the next digit.
1 dimensional 'st$' is substituted like this.
(0)->"apple" (1)->"orange" (2)->"melon" (3)->"grapes" (4)->"cherry"
2 dimensional 'da' is substituted like this.
(0,0)->0 (0,1)->1 (0,2)->2 (0,3)->3 (0,4)->4 (0,5)->5
(1,0)->10 (1,1)->11 (1,2)->12 (1,3)->13
[Features] To eliminate arrays from a program.
[Format] ERASE variable[$][,variable[$]]...
Global arrays are eliminable only in global area.
What can be erased is arrays which can be referred to with the current scope.
[Features] To specify the minimum value for array subscripts.
[Format] OPTION BASE -1|0|1
To specify the minimum value for array subscripts by 0 or 1.
(Default is 0)
This command must be written before the array is declared.
When changing specification on the way, have to execute the 'CLEAR' command once.
Because range check of the subscript of arrangement is simplified by C-mode,
even if 0 is specified in the state of minimum value 1, no error is output.
And as unique feature of this Basic,
it's possible to specify -1 as the original specification.
This is not a minimum value specification,
it become the specification which reduce the maximum value by 1.
When the range of array is declared to be 10 in
it become to handle 11 data from 0 to 10.
This become the same setting method as the general language, C language and Java.
This is mainly, used when handle arrays as matrix in 'mathrix' command of linear algebra.
(For example, when the matrix is declared with 2,
it avoids becoming array size of 3[1large])
option base 1
[Features] To store the numeric and string that are accessed by 'READ'statement.
[Format] DATA data1[,data2]...
'DATA'statement can be placement anywhere.
Character string data, Form enclosed in double quotation, it is not, either is OK.
10 read a,b
20 print a;b
30 read s1$,s2$
40 print s1$;s2$
50 print "Line:";dtl
60 restore 120
70 read s1$,s2$
80 print s1$;s2$
100 data 10,11,12,abc
110 data 20,21,22
120 data Apple,"Orange"
[Features] To read values from 'DATA'statement and assign them to variables.
[Format] READ variable[$][,variable[$]]...
The character variable can read the data of both numerical value and character string.
In a numeric variable, it can read only numeric data.
[Features] To specification the line number of 'DATA' accessed by 'READ'.
[Format] RESTORE [linenumber]
If a line number is omitted, it will become a head position of data.
[Features] The line number read in the 'READ'statement is held and returned.
if dtl=500 then restore
[Features] It swap the values of two numeric variables.
[Format] SWAP (array)variable1, (array)variable2
It can be used for array variable.
(with number of arrangement element)
[Features] To find specified 'search value' from numeric array variable, and return the 'subscript-number'.
[Format] SEARCH( Numeric-array-variable-name,search-value[,start-subscript[,step-value]] )
To find specified 'search value' from numeric array variable and return the 'subscript-number'.
If not found, it return -1.
Array variables must be primary array.
It must be declared by 'DIM' beforehand.
It specify at 'start-subscript' for 'where to start searching'.
The default is 0.
Specifying 'step value' is looking for at the interval.
The default is 1.
[Features] All Variable initialization, and Area size of (string & numeric)variable are determined.
[Format] CLEAR [string-variable-area-size] [,numeric-variable-area-size]
All the variables are initialized. (in the same state as startup)
Opened files are closed.
All the interruption will be in OFF state.
Random generator series is initialized.
In the state of the first, String - 4000, Numeric - 100000.
String variable have another actual data store area separate from this value.
(The length of one string is free)
The omitted will keep the previous values.
This is legacy compatible command.
It is not necessary to use in present day when large memory is allocated from the beginning.
If want to set variable to the same initial state as the boot, simply write 'clear'.
'Immediately after specifying, the array of size can be defined at the maximum.
[Features] To return the address of a variable stored in the variable area.
It is used in combination with 'BSAVE','BLOAD',
and be used to Into & out of numeric array variable.
100 dim az(12)
120 bsave "da.dat",varptr("az")
130 erase az
140 dim az(12)
150 bload "da.dat",varptr("az")
160 print az(0)
170 print az(1)
180 print az(2)
[Features] To get information about variable.
Variable type, scope, Array information, and subscript data are acquired.
When specifying Array name, it is unnecessary to writte brackets'()' part.
The returned number is 0~8 and correspond to the following contents:
When [Subscript-No] is specified,
it's possible to acquire subscript information of the array.
0 To acquire the number of dimensions of the array.
1 To acquire size of the 1st subscript of the array.
2 To acquire size of the 2nd subscript of the array.
3 To acquire size of the n-th subscript...
In the next case, 0 is returned.
'specified variable name is not Array',
'the number of dimensions of Array is exceeded'
The order of the subscripts are counted from the right side.
The case: da(3,2,1)
1st subscript is 1
2nd subscript is 2
3rd subscript is 3
It be like this.
110 dim gd(4,8)
140 print "gi";gettype("gi")
150 print "gs$";gettype("gs$")
160 print "gd";gettype("gd")
170 print "gd_n";gettype("gd",0)
180 print "gd_1";gettype("gd",1)
200 func fn()
210 dim ld(8)
230 print "li";gettype("li")
240 print "ld";gettype("ld")
250 print "gd";gettype("gd")
[Features] Data of variable area of memory is saved at a file.
[Format] BSAVE "file-name",variable-area-address
The address of numerical array to save is specified using 'VARPTR' function.
The value of array is a decimal omitted,
and changed into 2-byte signed integer, and be saved.
The kind, can be saved is only numerical array.
The length of the array end is determined automatically.
The "filename" must have an extension.
[Features] Data is read into the variable area of memory from a file.
[Format] BLOAD "file-name",variable-area-address
The address of numerical array to load is specified using 'VARPTR' function.
Array to be read must be the same size as it is saved.