Redim an array in MSX basic

Door smart duck

Master (152)

afbeelding van smart duck

29-08-2020, 20:30

Hi,

I'm trying to create a simple file browser to select and open a file for reading.
I found the example to read the file names from disk from NYYRIKKI.
https://www.msx.org/forum/development/msx-development/displa...
It works great, thanks NYYRIKKI! :)

The number of files is variable so I have to use a dynamic array or work around.
Is it possible to redim an array in MSX basic?

Aangemeld of registreer om reacties te plaatsen

Van smart duck

Master (152)

afbeelding van smart duck

29-08-2020, 21:39

Here is an example/test of what i'm trying.

10 COLOR 14,1,1 : SCREEN 2
20 OPEN "grp:" FOR OUTPUT AS#1
30 DIM FA$(15)
40 DEFINT I:DEFINT U:DEFINT P:C=0
50 FM$="????????.???"
60 DA$="0E11110E12C51100C10E1ACD7DF3C11180C0CD7DF332F8F7C9"
70 AD=&HC080:POKE AD,0'Drive: 0=Default, 1=A: 2=B: ... 8=H
80 FOR I=1 TO 12:AD=AD-(I<>10):POKE AD,ASC(MID$(FM$,I,1)): NEXT I
90 FOR I=&HC08C TO &HC0C0: POKE I,0:NEXT I
100 FOR I=0 TO 25:POKE &HC000+I,VAL("&H"+MID$(DA$,I*2+1,2)):NEXT I
110 DEFUSR=&HC000:DEFUSR1=&HC003
120 IF USR(0)>0 THEN END
130 F$=""
140 FOR I=1 TO 12:F$=F$+CHR$(PEEK(&HC100+I))
150 IF I=8 THEN F$=F$+"."
160 NEXT I: FA$(C) = F$: C=C+1
170 IF USR1(0)=0 THEN 130
180 LINE (64,64)-(192,142),14,BF
190 P=0 : U = 0
200 LINE (65,65)-(191,141),1,BF
210 FOR I=0 TO 5
220 PSET (86,76 + (I*10)),1 : PRINT#1, FA$(I+P)
230 NEXT I
240 PSET(76,76+(U*10)),1 : PRINT #1, ">"
250 K$=INKEY$
260 IF K$="" GOTO 250
270 LINE(76,76 + (U*10))-(85, 86+(U*10)),1,BF
280 IF K$=CHR$(30) THEN U=U-1
290 IF K$=CHR$(31) THEN U=U+1
300 IF K$=CHR$(27) GOTO 380
310 V=P
320 IF U>5 THEN U=5 : P=P+1
330 IF U<0 THEN U=0 : P=P-1
340 IF P>14 THEN P=14
350 IF P<0 THEN P=0
360 IF V<>P THEN V=P : GOTO 200
370 GOTO 240
380 CLOSE #1
390 COLOR 15,4,4:END

Van mohai

Paladin (930)

afbeelding van mohai

29-08-2020, 23:52

Just an idea: do a DIM to a different variable, after new dimension is found out, then chnage the pointers with VARPTR.

Van smart duck

Master (152)

afbeelding van smart duck

30-08-2020, 00:38

Thanks for the tip! I will check it out.