REM |
[Features] Comments are put
in.
[Format] REM [sentence]
[Explanation]
The following sentence isn't executed.
It is omissible by (').
[e.g.]
LET |
[Features] To assign the value
to a variable.
[Format] [LET]
variable[$]=value
[Explanation]
'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."
[e.g.]
let n=2
m=4
dim d(4) : d(0)=8
ss$="hello"
print ss$;n;m;d(0)
(Result)
hello 2
4 8
DIM |
[Features] Arrays variable is
declared.
[Format] DIM
variable[$](a[,b][,c]...) [,variable[$]...]
[Explanation]
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
dim
member(20,10),name$(20)
member(15,5)=164
print member(15,5)
erase member
Array
initializer
It's possible to substitute data together by
the description enclosed by brackets.
e.g.
10 dim
da(4,8),st$(16)
20
st$={"apple","orange","banana","melon","grapes","cherry"}
30
da={{0,1,2,3,4,5},{10,11,12,13},{20,21,22,23},{30,31,32,33}}
40 print st$(4)
50 print
da(1,2)
[Result]
grapes
12
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
ERASE |
[Features] To eliminate arrays
from a program.
[Format] ERASE
variable[$][,variable[$]]...
[Explanation]
Global arrays are eliminable only
in global area.
What can be erased is arrays which
can be referred to with the current scope.
OPTION BASE |
[Features] To specify the minimum value for array
subscripts.
[Format] OPTION BASE
-1|0|1
[Explanation]
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.
Note:
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
Basic,
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])
[e.g.]
option base
1
dim dat(8)
dat(1)=12
DATA |
[Features] To store the numeric
and string that are accessed by 'READ'statement.
[Format] DATA data1[,data2]...
[Explanation]
'DATA'statement can be placement anywhere.
Character string data, Form enclosed in double quotation, it is not,
either is OK.
[e.g.]
[smp_data.bas]
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$
90 'Datagroup
100 data 10,11,12,abc
110 data
20,21,22
120 data Apple,"Orange"
(Result)
10 11
12abc
Line: 110
AppleOrange
READ |
[Features] To read values from
'DATA'statement and assign them to variables.
[Format] READ variable[$][,variable[$]]...
[Explanation]
The character variable can read the data of
both numerical value and character string.
In a numeric variable, it can read only numeric data.
[e.g.]
RESTORE |
[Features] To specification the
line number of 'DATA' accessed by 'READ'.
[Format] RESTORE [linenumber]
[Explanation]
If
a line number is omitted, it will become a head position of data.
[e.g.]
DTL |
[Features] The line number read
in the 'READ'statement is held and returned.
[Format]
[Explanation]
[e.g.]
if dtl=500
then restore
SWAP |
[Features] It swap the values of
two numeric variables.
[Format] SWAP (array)variable1, (array)variable2
[Explanation]
It can be used for array variable.
(with number of arrangement element)
[e.g.]
st=5:dt=12
swap st,dt
print st;dt
(Result)
12 5
SEARCH (Function) |
[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]] )
[Explanation]
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.
[e.g.]
dim as(10)
as(4)=45
as(7)=28
print search(as,28)
(Result)
7
CLEAR |
[Features] All Variable
initialization, and Area size of (string & numeric)variable are
determined.
[Format] CLEAR
[string-variable-area-size] [,numeric-variable-area-size]
[Explanation]
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'.
[e.g.]
clear ,200000
dim mc(200000)
'Immediately after specifying, the array
of size can be defined at the maximum.
VARPTR |
[Features] To return the address
of a variable stored in the variable area.
[Format] VARPTR("variable-name")
[Explanation]
It is
used in combination with 'BSAVE','BLOAD',
and be used to Into & out of
numeric array variable.
[e.g.]
[smp_varptr.bas]
100 dim az(12)
110az(0)=8:az(1)=345:az(2)=-24
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)
(Result)
8
345
-24
GETTYPE |
[Features] To get information about variable.
[Format] GETTYPE("VariableName"[,Subscript-No])
[Explanation]
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:
0.Undefined
1.Numeric variable-Global
2.Character
variable-Global
3.Numeric
Array-Global
4.Character
Array-Global
5.Numeric
variable-Local
6.Character
variable-Local
7.Numeric
Array-Local
8.Character
Array-Local
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.
e.g. "smp_gettype.bas"
100
cls
110 dim gd(4,8)
120 gi=4
130
gs$="text"
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)
190 f=fn()
200 func fn()
210 dim ld(8)
220 li=4
230 print
"li";gettype("li")
240 print "ld";gettype("ld")
250 print
"gd";gettype("gd")
260
endfunc
[result]
gi 1
gs$
2
gd 3
gd_n 2
gd_1 9
li 5
ld 7
gd 3
BSAVE |
[Features] Data of variable area
of memory is saved at a file.
[Format] BSAVE "file-name",variable-area-address
[Explanation]
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.
[e.g.]
dim
sh(9,9)
bsave "sh.var",varptr("sh")
BLOAD |
[Features] Data is read into the
variable area of memory from a file.
[Format] BLOAD "file-name",variable-area-address
[Explanation]
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.
[e.g.]
dim gd(4095)
bload "gd.var",varptr("gd")