Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Null-object/M2000-Interpreter/null-object-1.m2000
Normal file
12
Task/Null-object/M2000-Interpreter/null-object-1.m2000
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Module CheckWord {
|
||||
Declare Alfa "WORD.APPLICATION"
|
||||
Declare Alfa Nothing
|
||||
Print Type$(Alfa)="Nothing"
|
||||
Try ok {
|
||||
Declare Alfa "WORD.APPLICATION"
|
||||
\\ we can't declare again Alfa
|
||||
|
||||
}
|
||||
If Not Ok Then Print Error$ ' return Bad Object declaration
|
||||
}
|
||||
CheckWord
|
||||
54
Task/Null-object/M2000-Interpreter/null-object-2.m2000
Normal file
54
Task/Null-object/M2000-Interpreter/null-object-2.m2000
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
Module CheckContainers {
|
||||
\\ Arrays (A() and B() are value types)
|
||||
Dim A(10)=1, B()
|
||||
\\ B() get a copy of A(), is not a reference type
|
||||
B()=A()
|
||||
\\ we make a pointer to Array
|
||||
B=A()
|
||||
\\ now B is a reference type object
|
||||
Print Len(B)=10 ' ten items
|
||||
B+=10
|
||||
Print A(3)=11, A(7)=11
|
||||
\\ we can change pointer using a pointer to an empty array
|
||||
B=(,)
|
||||
\\ we can erase A() and B()
|
||||
Dim A(0), B(0)
|
||||
Print Len(A())=0, Len(B())=0
|
||||
Print Len(B)=0
|
||||
B=(123,)
|
||||
\\ B() is a value type so get a copy
|
||||
B()=B
|
||||
Print Len(B)=1, B(0)=123
|
||||
\\ Using Clear we pass a new empty array
|
||||
Clear B
|
||||
Print Type$(B)="mArray"
|
||||
Print Len(B)=1, B(0)=123
|
||||
|
||||
|
||||
\\ Inventrories. Keys must be unique (for normal inventories)
|
||||
Inventory M=1,2,3,4:=400,5
|
||||
Print M
|
||||
Clear M
|
||||
Inventory M=1,2,3,4,5
|
||||
Print M
|
||||
|
||||
\\ Inventory Queue can have same keys.
|
||||
Inventory Queue N=1,1,2:="old",2:="ok",3
|
||||
If Exist(N,2) Then Print Eval$(N)="ok", Eval(N!)=3 ' 4th item
|
||||
Clear N
|
||||
Print Len(N)=0, Type$(N)="Inventory"
|
||||
|
||||
\\ Stack Object
|
||||
Z=Stack:=1,2,3
|
||||
Stack Z {
|
||||
While not empty {Print Number}
|
||||
}
|
||||
Print Len(Z)=0
|
||||
Z=Stack((Stack:=1,2,3,4),Stack:=20,30,40 )
|
||||
Print Len(Z)=7
|
||||
Print Z ' 1 2 3 4 20 30 49
|
||||
Z=Stack ' This is an empty stacl
|
||||
Print Len(Z)=0
|
||||
Print Type$(Z)="mStiva"
|
||||
}
|
||||
CheckContainers
|
||||
29
Task/Null-object/M2000-Interpreter/null-object-3.m2000
Normal file
29
Task/Null-object/M2000-Interpreter/null-object-3.m2000
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class something {
|
||||
}
|
||||
class alfa as something {
|
||||
x=10, y=20
|
||||
}
|
||||
a->alfa()
|
||||
Print a is type alfa = true
|
||||
Print a is type something = true
|
||||
a->0&
|
||||
Print a is type null = true
|
||||
\\ beta is a named object, is static
|
||||
group beta {
|
||||
type: something, alfa
|
||||
x=10, y=20
|
||||
}
|
||||
Print beta is type alfa = true
|
||||
Print beta is type something = true
|
||||
\\ now a is a pointer as a weak reference to beta
|
||||
a->beta
|
||||
print a is type alfa = true
|
||||
print a is type something = true
|
||||
a=pointer() ' same as a->0&
|
||||
Print a is type null = true
|
||||
\\ now a is a pointer of a copy of beta
|
||||
a->(beta)
|
||||
print a is type alfa = true
|
||||
print a is type something = true
|
||||
a=pointer() ' same as a->0&
|
||||
Print a is type null = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue