RosettaCodeData/Task/Collections/M2000-Interpreter/collections-5.m2000
2023-07-01 13:44:08 -04:00

50 lines
1.4 KiB
Text

Module GetC {
declare c collection
def decimal aDecimal=3000032131231231312312
Document doc$
Print type$(c)
\\ we get an inventory list of all methods/properties of a com Object
m=param(c)
IF LEN(m)>1 THEN {
For i=0 to len(m)-1
\\ use index, not key so i! is index
Doc$=m$(i!)+{
} ' we use this block for new line
Next i
}
Report Doc$
Clipboard Doc$
\\ so now we have to use it, using Methid to call Add
Method c, "Add", 100, "Hello"
Method c, "Add", 2000, "There"
\\ add a decimal number
Method c, "Add", aDecimal, "Zero"
Method c, "count" as count
Print count =3 ' we have three members
Method C, "_NewEnum" as Item
Method c, "Item", "Zero" as ZeroItem ' we get the decimal number
Print ZeroItem
Print type$(Item)="Nothing" ' we have numbers
k=0
While Item {
k++
print k, eval(item)
}
c.item=lambda c (akey$) ->{
try ok {
method c, "item", akey$ as ret
}
If type$(Ret)="Empty" Then Error "Key not used"
=ret
}
Print c.item("Hello")
Try {
val=c.item("Hello12")
}
Print Error$
Push c
}
GetC
Read a
Print type$(a)="Collection" ' if we don't declare