Skip to content

Version 14 Revision 45

Latest

Choose a tag to compare

SHA 256 57a6c32a4111fa62ca1e803ca83287b00052e9cd5fbdd1fcbdbd0a8a60aa4ad9

  1. A Book for OOP for Greek Language plus all programs (97)of book in one module, as oop97.gsb
  2. A tiny fix:

Class Alfa {
Private:
	{read z as double}
	k=z
Public:
	value (n) {=n*.k}
}
M=Alfa(100)
Print M(3)=300
Print Eval(M, 3)=300 ' <<< this fixed

Version 14 Revision 44
I fixed an error from revision 40. I forgot to fix Interpreter for constant objects and a lambda function. The Interpreter finds the constant (is an object of type constant) and then uses this object to pass arguments x, y to the default property. That is fault. So, I changed it, so now Interpret skips this object and then find the function L() and we get the result as expected. Previous revisions are ok because they did nothing for any object, except the Inventory object.

This is the code:
Const L=Lambda (x, y)->x^y
Print L(2,3)=8 ' here was the error

Version 14 Revision 43
Fix the Select Case: One problem was the Case and Με (greek version) using semi boolean like <50 which interpreter before the fix saw this as a variable with the start of an operator. The second problem was an error on End Select with a fault for an inner select case at the last case - case else or else case (both works).

tuple=(100, 200, 77, 500, 1005, -20, 75, 90)
Case=100  ' this is a variable
for i=1 to 100
    x=tuple#Val(Random(0,7))
    LIST
    Print "x=";x
    Select Case x
    Case 100, 200
        Print "One line1"
        Print "One line2"
    Case 1000, 500
        x+=10
    Case <50
    {
        x++
    }
    Case 70 έως 80
        Select Case x
        Case 73
            x/=10
        Case Else
            x|Υπόλ 10
        End Select
    Case Else
        x-=50
    End Select
    Print "Export x=";x, Case=100, i
next 

This is the Greek Version:

Π=(100, 200, 77, 500, 1005, -20, 75, 90)
Για ι=1 εως 100
    Με=100
    Χ=Π#Τιμή(Τυχαίος(0,7))
    Λίστα	
    Τύπωσε "Χ=";Χ
    Επίλεξε Με Χ
    Με 100, 200
        Τύπωσε "Σε μια γραμμή1"
        Τύπωσε "Σε μια γραμμή2"
    Με 1000, 500
      	Χ+=10
    Με <50
    {
        Χ++
    }
    Με 70 έως 80
      	Επίλεξε Με Χ
      	Με 73
            Χ/=10
        Με Αλλιώς
            Χ|Υπόλ 10
        Τέλος Επιλογής
    Με Αλλιώς
        Χ-=50
    Τέλος Επιλογής
    Τύπωσε "Εξαγωγή Χ=";Χ, Με=100, ι
Επόμενο

Version 14 Revision 42
See Readme.txt
Help now has VARPTR() also (and an example for making the STRPTR())

With English staments:

Declare Peek.Long lib "msvbvm60.GetMem4" {Long addr, Long retValue}
Declare Peek.Integer lib "msvbvm60.GetMem2" {Long addr, Long retValue}
Declare Peek.Byte lib "msvbvm60.GetMem1" {Long addr, Long retValue}

Integer ret : Long ret2, there: Byte Ret3
If Locale=1032 then
	Const frm="###,### \Ψ\η\φ\ί\α"
else
	Const frm="###,### \B\y\t\e\s"
end if
a$="alfa12345"
Print str$(Len(a$)*2, frm)
there=StrPtr(VarPtr(a$))
hex "StrPtr:";there
If there>0 then
		Call Peek.Long there-4, varptr(ret2)
		Print "bytes=";ret2
		For n=0 to (ret2-1) div 2
			Call Peek.Integer there, varptr(ret)
			there+=2
			Print chrcode$(ret);
		Next
	Print
end if
Print str$(Len(String$(a$, 2000000))*2, frm)
there=StrPtr(VarPtr(a$))
hex "StrPtr:";there
a$=str$("alfa12345")
Print str$(Len(a$)*2, frm)

there=StrPtr(VarPtr(a$))
hex "StrPtr:";there
If there>0 then
		Call Peek.Long there-4, varptr(ret2)
		Print "bytes=";ret2
		For n=0 to ret2-1
			Call Peek.Byte there, varptr(ret3)
			there++
			Print chr$(ret3);
		Next
	Print
end if
Print str$(Len(String$(a$, 2000000))*2, frm)
there=StrPtr(VarPtr(a$))
hex "StrPtr:";there

function StrPtr(varptr as Long)
	Local thatptr as Long
	Call Peek.Long varptr, varptr(thatptr)
	=thatptr
end function

Slight different (using constant values) for the Greek version:

Όρισε Πάρε.Μακρύ Από "msvbvm60.GetMem4" {Μακρύς διεύθυνση, Μακρύς διεύθυνση_μεταβλητής}
Όρισε Πάρε.Ακέραιο Από "msvbvm60.GetMem2" {Μακρύς διεύθυνση, Μακρύς διεύθυνση_μεταβλητής}
Όρισε Πάρε.Ψηφίο Από "msvbvm60.GetMem1" {Μακρύς διεύθυνση, Μακρύς διεύθυνση_μεταβλητής}

Ακέραιος Επ1 : Μακρύς Επ2, Δείκτης_Στο_Χαρακτήρα: Ψηφίο Επ3
Σταθερές Δεικτ="Δείκτης Στο Πρώτο Χαρακτήρα:",
         Ψηφ="Ψηφία (αριθμός καταχωρημένος στο αλφαριθμητικό):",
         Δείγμα="Alfa12345"
 
Αν Τοπικό=1032 Τότε
	Σταθερή φόρμα_αριθμού="###,### \Ψ\η\φ\ί\α"
Αλλιώς
	Σταθερή φόρμα_αριθμού="###,### \B\y\t\e\s"
Τέλος Αν
α$=Δείγμα
Τύπωσε Γραφή$(Μήκος(α$)*2, φόρμα_αριθμού)
Δείκτης_Στο_Χαρακτήρα=ΔείκτηςΑλφ(ΔιευθΜ(α$))
Δεκαεξ Δεικτ;Δείκτης_Στο_Χαρακτήρα
Αν Δείκτης_Στο_Χαρακτήρα>0 Τότε
		Κάλεσε Πάρε.Μακρύ Δείκτης_Στο_Χαρακτήρα-4, ΔιευθΜ(Επ2)
		Τύπωσε Ψηφ;Επ2
		Για ν=0 έως (Επ2-1) δια 2
			Κάλεσε Πάρε.Ακέραιο Δείκτης_Στο_Χαρακτήρα, ΔιευθΜ(Επ1)
			Δείκτης_Στο_Χαρακτήρα+=2
			Τύπωσε ΧαρΚωδ$(Επ1);
		Επόμενο
	Τύπωσε
Τέλος Αν
Τύπωσε Γραφή$(Μήκος(Επαν$(α$, 2000000))*2, φόρμα_αριθμού)
Δείκτης_Στο_Χαρακτήρα=ΔείκτηςΑλφ(ΔιευθΜ(α$))
Δεκαεξ Δεικτ;Δείκτης_Στο_Χαρακτήρα
α$=Γραφή$(Δείγμα)
Τύπωσε Γραφή$(Μήκος(α$)*2, φόρμα_αριθμού)

Δείκτης_Στο_Χαρακτήρα=ΔείκτηςΑλφ(ΔιευθΜ(α$))
Δεκαεξ Δεικτ;Δείκτης_Στο_Χαρακτήρα
Αν Δείκτης_Στο_Χαρακτήρα>0 Τότε
		Κάλεσε Πάρε.Μακρύ Δείκτης_Στο_Χαρακτήρα-4, ΔιευθΜ(Επ2)
		Τύπωσε Ψηφ;Επ2
		Για ν=0 έως Επ2-1
			Κάλεσε Πάρε.Ψηφίο Δείκτης_Στο_Χαρακτήρα, ΔιευθΜ(Επ3)
			Δείκτης_Στο_Χαρακτήρα++
			Τύπωσε χαρ$(Επ3);
		Επόμενο
	Τύπωσε
Τέλος Αν
Τύπωσε Γραφή$(Μήκος(Επαν$(α$, 2000000))*2, φόρμα_αριθμού)
Δείκτης_Στο_Χαρακτήρα=ΔείκτηςΑλφ(ΔιευθΜ(α$))
Δεκαεξ Δεικτ;Δείκτης_Στο_Χαρακτήρα

Συνάρτηση ΔείκτηςΑλφ(Διεύθ_Μεταβλητής ως Μακρύς)
	Τοπική οΔείκτης ως Μακρύς
	Κάλεσε Πάρε.Μακρύ Διεύθ_Μεταβλητής, ΔιευθΜ(οΔείκτης)
	=οΔείκτης
Τέλος Συνάρτησης

Last example for BigIntegers used as List Keys:

' using Bigintegers for keys
' keys are always strings
' Bigintegers convert to Base10 strings as keys
inventory list1
z=1312_3123_0000_0000_12345u
z1=9_3123_0000_0000_12345u
? z, "&&&&"
list1(z)=1000
z++
Append List1, z:=2000, z1:=6000
z--
Return List1, z:=1500
z+=10
list1(z)=3000
z-=10
? z, "????"
Delete list1, z
z++
Print list1(z)
sort descending list1 as number
m=each(List1)
while m
	? eval$(M!), eval(M) ' key value pair
end while

sort ascending list1 as number
m=each(List1)
while m
	? eval$(M!), eval(M)
end while
' reverse iteration
m=each(List1, -1, 1)
while m
	? eval$(M!), eval(M)
end while
Print Exist(List1, z)

Version 14 Revision 41

I do plenty of work this is some of:

  1. Fix a hidden bug:
    This example now work without error in module ALFA.
MODULE ALFA {
	TRY {
		PROBLEM("GEORGE", 12123)
	}
	PRINT ERROR$
	// PROBLEM START FROM THE READ AT SUB PARAMETER LIST
	SUB PROBLEM(THAT AS VARIANT="")
		PRINT THAT
		READ THAT  ' HERE WAS THE PROBLEM
		PRINT THAT
	END SUB
}
ALFA
MODULE ALFA1 {
	PROBLEM("GEORGE", 12123)
	SUB PROBLEM()
		' NO PROBLEM BECAUSE THIS IS THE GENERIC READ
		READ THAT AS VARIANT=""
		PRINT THAT
		READ THAT  ' HERE WAS THE PROBLEM
		PRINT THAT
	END SUB
}
ALFA1

  1. Fix a problem with Continue inside then else without block - worked as restart so never go to actual block for/next
aa=0
for i=1 to 100
	if i<3 then continue else aa++
next
print aa=98

  1. Now we get true from the last print (?)
a=("aa",2,3,"hello",5)
link a to a$()
try {
	a$(0)="???"
}
? a$(0)="???"  ' true

  1. When we use Ctrl+C (copy to clipboard) in EditBox and Editor (as text editors) then we get visual message that the copy to clipboard done (sometimes I press light the C so I was thing that the copy done, but that not happen, so I insert the message to take knowledge about my difficulty...Also I have a lot this year I become 60 years old).
    Also I fix the search with F2 (up), now works as expected. (F3 down was ok).

  2. We can use STATIC SUB to inform Interpreter for subs before we use them. This it the code from INFO, TSTSUB module:

global const many=30000
form 80
print $(,10) ' 10 characters column
print "iterations per test:";many
module TestThis (UseStatic=True){
	if UseStatic then static sub TestMe,TestMe2
	aa=100
	print "TestMe - New Call without Parentheses"
	profiler
	for i=1 to many
		TestMe
	next
	print timecount
	print "TestMe() - Standard"
	profiler
	for i=1 to many
		TestMe()
	next
	print timecount
	print "TestMe() - Standard using GOSUB"
	profiler
	for i=1 to many
		gosub TestMe()
	next
	print timecount	
	print {TestMe2 "ok", 1000  - New Call without Parentheses}
	profiler
	for i=1 to many
		TestMe2 "ok", 1000
	next
	print timecount
	print {TestMe2("ok", 1000) - Standard}
	profiler
	for i=1 to many
		TestMe2("ok", 1000)	
	next
	print timecount
	print {TestMe2("ok", 1000) - Standard using GOSUB}
	profiler
	for i=1 to many
		gosub TestMe2("ok", 1000)	
	next
	print timecount
}
pen 11 {print "Using Static Sub Definition"}
TestThis
pen 11 {print "Skip Static Sub Definition"}
TestThis False
Report {
Using Static Sub Definition is faster. Also we shadowing any global module with same name.
Names like print can be used for subs (e.g. SUB print()) but to call it we have to use:
1 - print()
2- gosub print()
if we use Static Sub Print we can use Call
3 - Call Print
and (1)  and (2)

To use our Print we have to use Module Print { } as local module
This make Print as a call to local module
We can use @Print  to call the original Print in the same module where we define local module print
Inside module print statement print is the original one. 
}

sub TestMe()
	aa++
end sub
sub TestMe2(Alfa, k)
	aa+=k
end sub

  1. Use of Quaternion (we can make new UDT of Quaternions - exist in M2000.dll - this type (among other udt) made M2000.dll the need
    This is the Quat Module in Info File
oldlocale=locale
Module English_Quaternion {
	locale 1033
	Static Function DispQuat
	Declare Math Math
	q=Math=>NewQuatType(10, 30, -50, 30)
	print type$(q)="QuatType"
	Print q|w=10, q|x=30, q|y=-50, q|z=30
	Print Math=>QuatStringQuat(q)
	Print Math=>QuatStringQuat(q, "0.000")
	Print "q=";DispQuat(q)  ' (10+30i-50j+30k)
	Print "Norm of Quaternion |q|:=";Math=>NormQuat(q)
	Print "Conjugate Quaternion:=";DispQuat(Math=>NegQuat(q))  ' (10-30i+50j-30k)
	Function DispQuat(q as QuatType)
		' break for displayed better - M2000 handle any line length
		local ret="("+(q|w)+if$(q|x<0->"","+")+(q|x)+if$(q|y<0->"i","i+")
		=ret+(q|y)+if$(q|z<0->"j","j+")+(q|z)+"k)"
	End Function
}
Pen 10 {English_Quaternion}
print
Τμήμα Ελληνικά_Τετραδόνιο1 {
	Τοπικό 1032
	Στατική Συνάρτηση Δείξε_Τερταδόνιο
	Όρισε Μ Μαθηματικά
	τ=Μ=>NewQuatType(10, 30, -50, 30)
	Τύπωσε Τύπος$(τ)="QuatType"
	Τύπωσε τ|w=10, τ|x=30, τ|y=-50, τ|z=30
	Τύπωσε Μ=>QuatStringQuat(τ)
	Τύπωσε Μ=>QuatStringQuat(τ, "0.000")
	Τύπωσε "τ=";Δείξε_Τερταδόνιο(τ)  ' (10+30i-50j+30k)
	Τύπωσε "Νόρμα (μέτρο) τετραδόνιου |τ|:=";Μ=>NormQuat(τ)
	Τύπωσε "Συζυγές τετραδόνιο :=";Δείξε_Τερταδόνιο(Μ=>NegQuat(τ))  ' (10-30i+50j-30k)
	Συνάρτηση Δείξε_Τερταδόνιο(α ως QuatType)
		Τοπική επ="("+(α|w)+αν$(α|x<0->"", "+")+(α|x)+αν$(α|y<0->"i","i+")
		=επ+(α|y)+αν$(α|z<0->"j","j+")+(α|z)+"k)"
	Τέλος Συνάρτησης
}
Πένα 11 {Ελληνικά_Τετραδόνιο1}
locale oldlocale