Problem with xbasic compiler

صفحة 3/4
1 | 2 | | 4

بواسطة freedom711

Rookie (32)

صورة freedom711

07-07-2021, 13:06

Fantastic!!!

But i want use array type string in Xbasic?

Is an example possible?
I thank you ...

بواسطة freedom711

Rookie (32)

صورة freedom711

07-07-2021, 16:57

I'm a turbo pascal fan and with msx (openmsx) i can manage arrays and other things very well and it's very fast...
This program was written in the 80's in all types of basic (commodore, sinclair, bbc, etc etc) to test the speed of the basic.
I liked to convert it to TP and it is very powerful compared to Basic.
I'm sorry I can't do these experiments with Xbasic...
Here is program for those who want to have fun with Turbo Pascal.
Very fast!!!
-------------Turbo Pascal-----------------
proram sieve of Eratosthenes algorithm;

const n =1000;
var next,j : integer;
sieve : array [1..n] of boolean;
begin
for next:=2 to n
do sieve [next]:=true;
writeln('array cleared');
for next:=2 to n
do begin
if sieve[next]
then begin
write (next:5);
j:=next;
repeat
sieve [j] := false;
j := j + next;
until j>n;
end;
end;
end.

بواسطة freedom711

Rookie (32)

صورة freedom711

07-07-2021, 16:59

I can't publish the basic version... oO

بواسطة NYYRIKKI

Enlighted (6092)

صورة NYYRIKKI

08-07-2021, 14:04

freedom711 wrote:

Fantastic!!!

But i want use array type string in Xbasic?

Is an example possible?
I thank you ...

The "correct" example depends a lot of the stuff you try to do... For your previous example maybe POKE or VPOKE with CHR$()/ASC() is good approach... or maybe integer table... or maybe smaller string table that uses longer strings & MID$()... If you really need variable length strings that change sizes "randomly" then Nestor BASIC has some functions to maintain string database, but I must say I've not ever used them.

freedom711 wrote:

I can't publish the basic version... oO

It seems that on standard MSX this speed test takes something like 14ms, but TIME is not really accurate enough to measure this small task (I left out print part from measurement as screen output speed depends of the screen mode)

10 DEFINT A-Z
20 DIM P(1000)
30 N=1000
40 CLS:TIME=0
50 FOR I=2 TO SQR(N)
60 IF P(I) THEN NEXT I
70 FOR K=I^2 TO N STEP I
80 P(K)=-1:NEXT K,I
90 PRINT TIME/60:PRINT
100 FOR I=2 TO N
110 IF P(I)=0 THEN PRINT I;
120 NEXT I

بواسطة freedom711

Rookie (32)

صورة freedom711

08-07-2021, 17:46

Perfect!

Tanks...

بواسطة freedom711

Rookie (32)

صورة freedom711

08-07-2021, 17:52

Smile

بواسطة freedom711

Rookie (32)

صورة freedom711

08-07-2021, 17:57

Smile

بواسطة freedom711

Rookie (32)

صورة freedom711

08-07-2021, 18:46

To be tested on msx 1 for parity of power with computers commodore, sinclair, bbc etc etc

بواسطة freedom711

Rookie (32)

صورة freedom711

08-07-2021, 18:47

10 L=1000:H=.5
20 DIM S(L)
30 FOR J=1 TO L:S(J)=1:NEXTJ
35 PRINT "ARRAY CLEARED"
40 FOR N=2 TO L

to be continue...

بواسطة freedom711

Rookie (32)

صورة freedom711

08-07-2021, 18:48

50 IF S(N) < H THEN GOTO 80
60 PRINT N;
70 FOR J=N TO L STEP N: S(J)=0: NEXTJ
80 NEXT N
90 END

صفحة 3/4
1 | 2 | | 4