You can find in GitHub the latest release of M2000 Interpreter, plus the M2000paper.pdf (include in setup file and separately to read it and get an idea about version 12 interpreter.
All programs checked on M2000paper and a lot of corrections done, 10 at least, (because of update system of version 12 some aspects of Interpreter not working as expected, so I found all and correct them).
So now Columnssort module in info.gsb file works fine. I do updates to include sorting for 2D for arrays with types (also I correct the issue for variants which introduced from version 12 earlier revisions).
Correction #1
This program was break at READ A() but now run as expected
Dim A(4)=1
A=(1,2,3,4)
Print A ' 1 2 3 4
Print A() ' 1 1 1 1
Print Len(A())=4
Print type$(A)="mArray", Len(A)=4
Push A(), A ' so now top of stack has a copy of A pointer
Stack ' show *[mArray], *[mArray] we see two pointers.
Read A(), A
\\ get a copy of pointer and drop pointer
Print A ' 1 1 1 1
\\ get a copy of array items in A() from pointer, and drop pointer
Print A() ' 1 2 3 4
Correction #2
port=6
port$=("COM0", "COM1","COM2", "COM3", "COM4", "COM5", "COM6","COM7")#val$(port)
List
Correction #3
action$="right"
Print ("right","left","stay")#nothave(action$)
Print ("right","left","stay")#have(action$)
Now Turing module run as expected
Correction #4
This program work fine but in earlier revisions if we use Dim A(10,20) without as long long we got false at last print, because the long long type not processed correct. Now fixed.
Dim A(10,20) as long long
A(0,0)=12345678912345678&&
Print type$(A(0,0))="Long Long"
Dim A(10,3)
Print A(0,0)=12345678912345678&&
Print A()#sum()=12345678912345678&&
k=A()
k-=10&&
Print A()#sum()=12345678912345678&&-300&&
Print type$(k)
Correction #5
This didn't sort based on second column (alfa, beta, delta), but now fixed (and expanded for arrays with types) (so ColumsSort example in info runs ok)
// columns sort
dim a(1 to 3, 1 to 2)
link a() to a$()
a(1,1)=500
a$(1,2)="alfa"
a(2,1)=200
a$(2,2)="delta"
a(3,1)=300
a$(3,2)="beta"
sort a(), 1, 3, 2, 0
for i=1 to 3
Print a(i,1), a$(i,2)
next
Added for arrays with types (this not sort on earlier versions/revisions):
dim a(30) as long long
z=0
for i=30&& to 1&&:a(z)=i:z++:next
dim a(5, 6) as long long
for i=0 to 4
for j=0 to 5
print a(i,j),
next
next
a(0,0)=100
a(1, 0)=100
//sort a(),0,4, 0, 0, 1, 0 ' 0 to 4 row, column 0 ascending, column 1 ascending
sort a(),0,4, 0, 0, 1, 1 ' 0 to 4 row, column 0 ascending, column 1 descending
for i=0 to 4
for j=0 to 5
print a(i,j),
next
next
Correction #6
fix OverWrite statement (old bug). These two example return error, so now fixed.
example 1
Document a$
a$={aaaaaaaaaaa
12345678901234567890
}
OVERWRITE 2, 10 a$="Hello"
REPORT a$
example 2
Document a$, b$
a$={aaaaaaaaaaa
12345678901234567890
}
b$=a$
insert to 2, 10 a$={Hello
two paragraphs
}
Report b$
Report a$
Clear a$
Document a$=b$
insert to 2, 10 a$="Hello"
Report b$
Report a$
Clear a$
DOCUMENT A$
a$=b$
OVERWRITE 2, 10 a$="Hello"
Report b$
Report a$
Clear a$
a$=b$
INSERT 2 a$="Hello" \\ replace line
Report b$
Report a$
Correction #7
This example raised error bad operator for +=, now work fine (was an error which prevent the lists to use operators, but was design to use all except assign operator - we use Return statement)
a=list:= 1:="one",2,-100:="300",4:=100&&,5
? a$(1)
a$(1)+="hello"
? a$(1)
a$(-100)+="-----"
? a$(-100)
a(-100)+="ok"
? a$(-100)
a(4)++
? a(4)
Correction #8
Expand Modules ? statement to correctly display modules and functions names (was a missing logic, which List for variables include but not included in Modules ? - I forgot it, and when a notice it I make the correction). The problem was for those modules with more than 3 letters (which M2000 use a compact form), so instead we got the "good" name, we got the compact form. You can see the problem in module Private in info. New revision remove it.
Correction #9
This work on earlier versions of M2000 Interpreter (version 10) but was a bug on version 12
structure aLong {
k as byte
{
a22 as integer
}
a01 as byte
a10 as byte
a11 as byte
}
? aLong
Print aLong
Now bug removed
Correction #10
The final in functions on classes not work properly for multiple inheritance, so now this fixed.
so this example work now fine (all boolean values from print return True)
\\ because deconstructor (Remove {}) is final
\\ and we want to apply a different deconstructor
\\ for all derived objects from GameObject
\\ intentionally we didn't apply the deconstructor in Class
\\ But see later how we can import this
class GameObject {
\\ by default functions are virtual
state=0
Group PointerToGameObject->0&
function update() {
=2
}
function draw() {
=3
}
function collide() {
=4
}
Class:
Module GameObject (.state) {
\\ this is the user constructor
Print "You just create GameObject"
}
}
\\ Visible, Solid, Movable compose GameObject
\\ Without using the constructor
\\ but their GameObject would be a different instance of class GameObject
class Visible as GameObject {
\\ using final the function stay as is
function final Draw() {
=100
}
}
class Solid as GameObject {
function final collide() {
=1000
}
}
class Movable as GameObject {
function final update() {
=10000
}
}
\\ here we compose Player, Cloud, Building, Trap from other objects
class Player as Solid as Movable as Visible {
Remove {
Print "Player removed"
}
class:
Module Player (.PointerToGameObject) {}
}
Class Cloud as Movable as Visible {
Remove {
Print "Cloud removed"
}
class:
Module Cloud (.PointerToGameObject) {}
}
Class Building as Solid as Visible {
Remove {
Print "Building removed"
}
class:
Module Building (.PointerToGameObject) {}
}
Class Trap as Solid {
Remove {
Print "Trap removed"
}
class:
Module Trap (.PointerToGameObject) {}
}
Class TraitRemove {
Remove {
Print "GameObject Removed"
}
}
\\ Game is a pointer to Group
\\ Because we want to include Remove function
\\ we can do that merging two objects
\\ so Game is a GameObject but has a TraitRemove
Game->(GameObject(1234) with TraitRemove())
Print Game=>Update()=2, Game=>draw()=3, Game=>collide()=4
\\ P, C, B, T are static objects here
P=Player(Game)
Print P.Update()=10000, P.draw()=100, P.collide()=1000
C=Cloud(Game)
Print C.Update()=10000, C.draw()=100, C.collide()=4
B=Building(Game)
Print B.Update()=2, B.draw()=100, B.collide()=1000
T=Trap(Game)
Print T.Update()=2, T.draw()=3, T.collide()=1000
\\ All objects has the same pointer to Game
Print P.PointerToGameObject=>state=1234
Print C.PointerToGameObject=>state=1234
Print B.PointerToGameObject=>state=1234
Print T.PointerToGameObject=>state=1234
\\ When state of Game change, these objects can find it
Game=>state+=20000
Print P.PointerToGameObject=>state=21234
Print C.PointerToGameObject=>state=21234
Print B.PointerToGameObject=>state=21234
Print T.PointerToGameObject=>state=21234
\\ we use Parenthesis to get a pointer to a copy of P
\\ so we make a pointer to a new object with same state
\\ without parentesis we get a pointer to static group
PP->(P)
PC=Pointer((C)) ' this is the same as ->(C)
PB=Pointer((B))
PT=Pointer((T))
Print PP=>Update()=10000, PP=>draw()=100, PP=>collide()=1000
Print PC=>Update()=10000, PC=>draw()=100, PC=>collide()=4
Print PB=>Update()=2, PB=>draw()=100, PB=>collide()=1000
Print PT=>Update()=2, PT=>draw()=3, PT=>collide()=1000
Print PP=>PointerToGameObject=>state=21234
Print PC=>PointerToGameObject=>state=21234
Print PB=>PointerToGameObject=>state=21234
Print PT=>PointerToGameObject=>state=21234
\\ Remove function called for 5 pointers at the end of this module
\\ We can manule execute Remove for static groups if we want
\\ We have 4 static objects (in M2000 we say named groups)
Report "Removing using Clear Named Groups"
Clear P, C, B, T
Report "Automatic Removing Groups erasing Pointers when this module exit . The last one is the GameObject"
Enjoy M2000 Interpreter.
Please write any comment (Although these comments monitoring by me).