In last build before this one, m2000.dll was from revision 16. So now is ok, and readme says "new build".
How to Go Basic
Some ideas to use M2000 as a Basic Interpreter.
For i=10 to 5 step 1 {
Print "never enter"
}
Dim A(5)
\\ 6 elements if we use +DIM
For i=0 to 5 : Print A(I) : Next I
\\ Prepare Data using Flush
Flush
Data 10, 30,80,150,300,650,1640
\\ only Long needed to declare for numbers
\\ else is a double, or can be integer using % as last char.
Long M, S
While IsNum {
M+=Number
S++
}
\\ we can use = or == (double = use rounding before perform compare)
Print Round(M/S,3), Int(M/S)==408, Round(M/S,0)==409
Print Type$(M), Type$(S) \\ Long
Data 10, 30,80,150,300,650,1640
Sum%=0
Items%=0
Repeat {
Read A%
Sum%+=A%
Items%++
} Until Empty
Print Round(Sum%/Items%,3), Int(Sum%/Items%)==408, Round(Sum%/Items%,0)==409
Print Type$(Sum%), Type$(Items%) \\ Double internal.
Print Eval("Sum%/Items%")
\\ Simply data inline code
Data "George", 51, "Alexander", 27, "Sofia", 24, "Fotini", 19
Min=1000 : Max=0
While not Empty {
Read Name$, Age
Print Name$, Age
Min=Min.data(Min, Age)
Max=Max.data(Max, Age)
}
Print Format$("Ages are form {0} to {1}", Min, Max)
\\ USING NO NESTED IF WITHOUT USING BLOCK OF CODES
If Ask("Choose 1 or 2","make your choise","1", "2")=1 Then Print "No good" : Print "if true only"
Else.If rnd>.5 then Print "Else.If" : Print "Only in else.if"
Else Print "Good" : Print "if else only"
\\ We have to use blocks
If true Then {
If false Then {
\\ nothing
} Else.If false Then {
\\ nothing
} Else {
Print "ok"
}
}
100 N=100 ' N is double by default
110 Print N
120 N-=10
130 IF N>10 THEN 110 ' NO NEED TO WRITE GOTO 100
140 GOSUB ALFA(N)
150 GOSUB ALFA(N/2)
160 GOTO 200
170 SUB ALFA(X)
180 PRINT FORMAT$("{0:2:-10} | {0:2:10}", X)
190 END SUB
200 B=10
210 INPUT "Z=", Z
220 PRINT $("#0.000"),B*Z, B**2+Z, B^2+Z, $(""),,
230 DEF K(X)=X**2
240 PRINT K(Z)
245 REM ' TRY FILES
250 OPEN "FILE1" FOR OUTPUT AS M
260 WRITE #M, 100,200,300,400,500
270 CLOSE #M
280 OPEN "FILE1" FOR INPUT AS M
290 FOR I=1 TO 5 : INPUT #M, Z : PRINT Z: NEXT I
300 CLOSE #M
305 REM 'USE A STANDARD ROUTINE
310 M=10
320 GOSUB 350
330 IF M>0 THEN 320
340 END
350 M--
360 PRINT M
370 RETURN
How to Go Basic
Some ideas to use M2000 as a Basic Interpreter.
\\
prepare M2000 to run close to basic
set switches "+FOR +DIM"
\\ using -FOR we enter loop 6 times.
set switches "+FOR +DIM"
\\ using -FOR we enter loop 6 times.
For i=10 to 5 step 1 {
Print "never enter"
}
Dim A(5)
\\ 6 elements if we use +DIM
For i=0 to 5 : Print A(I) : Next I
\\ Prepare Data using Flush
Flush
Data 10, 30,80,150,300,650,1640
\\ only Long needed to declare for numbers
\\ else is a double, or can be integer using % as last char.
Long M, S
While IsNum {
M+=Number
S++
}
\\ we can use = or == (double = use rounding before perform compare)
Print Round(M/S,3), Int(M/S)==408, Round(M/S,0)==409
Print Type$(M), Type$(S) \\ Long
Data 10, 30,80,150,300,650,1640
Sum%=0
Items%=0
Repeat {
Read A%
Sum%+=A%
Items%++
} Until Empty
Print Round(Sum%/Items%,3), Int(Sum%/Items%)==408, Round(Sum%/Items%,0)==409
Print Type$(Sum%), Type$(Items%) \\ Double internal.
Print Eval("Sum%/Items%")
\\ Simply data inline code
Data "George", 51, "Alexander", 27, "Sofia", 24, "Fotini", 19
Min=1000 : Max=0
While not Empty {
Read Name$, Age
Print Name$, Age
Min=Min.data(Min, Age)
Max=Max.data(Max, Age)
}
Print Format$("Ages are form {0} to {1}", Min, Max)
\\ USING NO NESTED IF WITHOUT USING BLOCK OF CODES
If Ask("Choose 1 or 2","make your choise","1", "2")=1 Then Print "No good" : Print "if true only"
Else.If rnd>.5 then Print "Else.If" : Print "Only in else.if"
Else Print "Good" : Print "if else only"
\\ We have to use blocks
If true Then {
If false Then {
\\ nothing
} Else.If false Then {
\\ nothing
} Else {
Print "ok"
}
}
100 N=100 ' N is double by default
110 Print N
120 N-=10
130 IF N>10 THEN 110 ' NO NEED TO WRITE GOTO 100
140 GOSUB ALFA(N)
150 GOSUB ALFA(N/2)
160 GOTO 200
170 SUB ALFA(X)
180 PRINT FORMAT$("{0:2:-10} | {0:2:10}", X)
190 END SUB
200 B=10
210 INPUT "Z=", Z
220 PRINT $("#0.000"),B*Z, B**2+Z, B^2+Z, $(""),,
230 DEF K(X)=X**2
240 PRINT K(Z)
245 REM ' TRY FILES
250 OPEN "FILE1" FOR OUTPUT AS M
260 WRITE #M, 100,200,300,400,500
270 CLOSE #M
280 OPEN "FILE1" FOR INPUT AS M
290 FOR I=1 TO 5 : INPUT #M, Z : PRINT Z: NEXT I
300 CLOSE #M
305 REM 'USE A STANDARD ROUTINE
310 M=10
320 GOSUB 350
330 IF M>0 THEN 320
340 END
350 M--
360 PRINT M
370 RETURN
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.