Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
95
Task/Variables/M2000-Interpreter/variables.m2000
Normal file
95
Task/Variables/M2000-Interpreter/variables.m2000
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
\\ M2000 use inference to state the type of a new variable, at run time
|
||||
\\ We can use literals of a numeric type
|
||||
\\ @ for Decimal
|
||||
\\ # for Currency
|
||||
\\ ~ for Single
|
||||
\\ & for Long (32bit)
|
||||
\\ % for Integer (16bit)
|
||||
\\ Double and Boolean have no symboles
|
||||
Module TopA {
|
||||
Module Alfa {
|
||||
Print A=10000, Type$(A)="Double"
|
||||
\\ A is local, we use =
|
||||
A=10@
|
||||
Print A=10, Type$(A)
|
||||
\\ Or we can state the type before
|
||||
Def Currency K, Z=500, M
|
||||
K=1000
|
||||
\\ Currency Currency Currency
|
||||
Print Type$(K), Type$(Z), Type$(M)
|
||||
Def Double K1, K2 as Integer=10, K3=1
|
||||
\\ double integer double
|
||||
Print Type$(K1), Type$(K2), Type$(K3)
|
||||
Mb=1=1
|
||||
\\ We get a boolean
|
||||
Print Type$(Mb)
|
||||
Def boolean Mb1=True
|
||||
Print Type$(Mb1)
|
||||
\\ True and False are Double -1 and 0 not Boolean
|
||||
Mb3=True
|
||||
Print Type$(Mb3)="Double"
|
||||
\\ For strings we have to use $ (like in old Basic)
|
||||
A$="This is a String"
|
||||
Global G1 as boolean = True
|
||||
\\ To change a global variable we have to use <=
|
||||
G1<=1=0
|
||||
\\ If we do this: G1=1=0 we make a local variable, and shadow global
|
||||
\\ In a For Object {} we can make temporary variables
|
||||
For This {
|
||||
Local G1=122.1212
|
||||
Print G1, Type$(G1)="Double"
|
||||
}
|
||||
Print G1, Type$(G1)="Boolean"
|
||||
}
|
||||
\\ shadow A for this module only
|
||||
A=100
|
||||
\\ Now we call Alfa
|
||||
Alfa
|
||||
Print (A=100)=True
|
||||
}
|
||||
Global A=10000
|
||||
TopA
|
||||
Print A=10000
|
||||
Module CheckStatic {
|
||||
\\ clear static variables and variables (for this module)
|
||||
Clear
|
||||
Module K {
|
||||
\\ if no A exist created with value 100@
|
||||
\\ Static variables can't be referenced
|
||||
Static A=100@
|
||||
Print A, Type$(A)="Decimal"
|
||||
A++
|
||||
}
|
||||
For i=1 to 10 : K : Next i
|
||||
Print A=10000
|
||||
}
|
||||
CheckStatic
|
||||
Print A=10000
|
||||
|
||||
\\ reference and use of stack of values
|
||||
C=100&
|
||||
Module ChangeC {
|
||||
\\ we leave arguments in stack of values
|
||||
Module HereChangeC (&f) {
|
||||
\\ interpreter execute a Read &f
|
||||
f++
|
||||
}
|
||||
\\ now we call HereChangeC passing current stack of values
|
||||
HereChangeC
|
||||
}
|
||||
\\ Calling a module done without checking for what parameters a module take
|
||||
ChangeC &C
|
||||
Print C, Type$(C)="Long"
|
||||
K=10010001001@
|
||||
ChangeC &K
|
||||
Print K, Type$(K)="Decimal"
|
||||
Module TypeRef (&x as Double) {
|
||||
Print x
|
||||
x++
|
||||
}
|
||||
D=100
|
||||
TypeRef &D
|
||||
Try ok {
|
||||
TypeRef &K
|
||||
}
|
||||
If Error or Not Ok then Print Error$ ' we get wrong data type
|
||||
Loading…
Add table
Add a link
Reference in a new issue