Schrijver
| load filelist in array
|
prothnl msx friend Berichten: 5 | Geplaatst: 05 Januari 2006, 13:25   |
I recently started coding for MSX. I have made picture viewers for C64, atari ST, PC and recently also for MSX.
I am very fond of the MSX bload"filename.sc5",s option.
The next step I want to take is to write a small , simple (preferably basic) program that display's all the *.sc5 on a particular floppy after each other without knowing the exact file name in advance.
The program I already made loads 4 *.sc5 screen after each other Once loaded you can switch the displayed screen with F1 to F4. But the exact filenames are hardcoded, this is the first and main thing I want to change. I want to keep discriptive filesname and I don't want to rename the filenames to "1.sc5","2.sc5".
Once I can load all the filenames dynamically (in an array of strings for example) I can also program that after viewing the first 4 .sc5 images you can press F5 and it loads the next 4 .sc5 images. Or even switch the display if there is an .sc7 file on the disk. I could also make a slideshow without userinteraction witch just loads and displays every *.sc? file on floppy.
Is it possible to do something like.
10 DIM $FN[100]=files"a:*.sc5"
or
10 foreach (files"a:*.sc5"
(If there is no other option I am willing to use MSX-dos, if that doesn't do the trick either I will use assembly.)
|
|
DarQ msx professional Berichten: 836 | Geplaatst: 05 Januari 2006, 13:31   |
hmmm, i forgot how this goes in pure basic (IF it is possible)
you can also use nestor soriano's NestorBASIC (with turboBasic). it has functions to do this and it works! AND you can compile your code to make it run MUCH faster.
www.konamiman.com |
|
AuroraMSX
 msx master Berichten: 1249 | Geplaatst: 05 Januari 2006, 14:26   |
Quote:
| 10 DIM $FN[100]=files"a:*.sc5"
or
10 foreach (files"a:*.sc5" 
|
That would be a very nice feature, but helas. There is no way in standard MSX Basic to transfer a file list to a string array  I've seen programs that just execute FILES and then grab the conents from VRAM...
It's easier in MSX-DOS: There are 2 functions available (I don't have the docs at hand, so you'll need to do a little research  )
FindFirst - finds the first filename matching a given pattern
FindNext - finds the next filename matching the pattern used for 'FindFirst'
|
|
cax
 msx professional Berichten: 1017 | Geplaatst: 05 Januari 2006, 14:32   |
So, what's wrong with running FILES on black screen or showing some splashscreen and grabbing filenames from VRAM ?
Another option is writing a routine in assembly.
|
|
djh1697 msx professional Berichten: 549 | Geplaatst: 05 Januari 2006, 14:43   |
I have looked at the problem before, it is not possible unless you read the FAT into memory using DSKI$ and work out the files from the resulting string.
If you are using DOS2.xx you could switch the screen off, run do a
call"system("dir > list.txt" )"
Then load the list.txt file into basic - strip off what you need and place it into your array.
I am not sure if that will work?
I prefer the former method, since it would probably work faster!
|
|
DarQ msx professional Berichten: 836 | Geplaatst: 05 Januari 2006, 14:45   |
hmm, i still think that in basic its easier to use NestorBASIC... a LOT easier! there is even an example on his page!
10 'Search of all the filenames in drive B: (default directory)
20 F$(1)="B:":P(0)=0:P(1)=2+16 'Include directories and hidden files
30 IF USR(26)<>0 THEN PRINT:PRINT"Total found:";P(11):END
40 PRINT F$(0),CHR$(-ASC("h")*((P(1)AND2)<>0));
CHR$(-ASC("d")*((P(1)AND16)<>0));
CHR$(-ASC("a")*((P(1)AND32)<>0)):GOTO 30
this is actually more code than you need because it prints the dirlist. |
|
prothnl msx friend Berichten: 5 | Geplaatst: 05 Januari 2006, 14:46   |
I like the suggesting of grabbing from VRAM. What about typing files"a:*.sc5" outside the basic program. Then you can navigate to the END of a file name type X to tag the files you want to display. Then you bload"a:viewer.bas",r and the slideshow only shows the tagged filenames... Quick & dirty is my middle name ;-)
Another approach cloud be to uniquely prefix the discriptive filesnames with a sequence character:
A_Myfoto.sc5
B_MyWife.sc5
....
Z_MyDog.sc5
then you can construct a file name incrementing the prefix character in a loop and use wildcards:
10 for c = 1 to 100
20 $filename=asc(c) +"_*.sc5"
30 bload $filename,s
40 next c
|
|
[D-Tail]
 msx guru Berichten: 3018 | Geplaatst: 05 Januari 2006, 16:31   |
Please use the suggestion DarQ mentioned  ... NBASIC really is the bomb for handling files. |
|
NYYRIKKI msx master Berichten: 1510 | Geplaatst: 05 Januari 2006, 17:05   |
I don't think reading from VRAM is very good idea. It is not just, that KEY, WIDTH, SCREEN etc. affects, but you need also different routines for DOS1 and DOS2... and what if all the data does not fit to screen?
You can use BDOS functions to make a file list also in BASIC, if you use #F37D entrypoint. If you don't know assembler, just insert DarQ's NBASIC example to your code.
|
|
AuroraMSX
 msx master Berichten: 1249 | Geplaatst: 05 Januari 2006, 18:06   |
Quote:
| bload"a:viewer.bas",r
|
run"a:viewer.bas" probably...
Quote:
| B_MyWife.sc5
....
Z_MyDog.sc5
|
Glad to see that wife and dog appear on separate images
Quote:
| then you can construct a file name incrementing the prefix character in a loop and use wildcards:
10 for c = 1 to 100
20 $filename=asc(c) +"_*.sc5"
30 bload $filename,s
|
FS$ is as far as you can get with BASIC variabale names.
The filename to use for a BLOAD cannot contain wildcards.
|
|
djh1697 msx professional Berichten: 549 | Geplaatst: 05 Januari 2006, 20:01   |
Why do you store a picture of your self, your wife, and your dog? is there a connection?
|
|
legacy msx professional Berichten: 516 | Geplaatst: 05 Januari 2006, 22:11   |
Hm, MSXbasic can do it very well
This is the way I did it, it's a piece of a program I wrote for using a homebrew plotter and the Sony plotter.
Maybe it's not that beauty, but it works fine.
3650 '=========FILES in array=========
3660 GOSUB 3810
3670 SCREEN 0:KEYOFF:COLOR1,1:CLS
3680 X=0:Y=0:LOCATEX,Y:FILES DR$+"*"+".PLT"
3690 LOCATE X,Y:PRINT"";
3700 FOR Y=1TO20
3710 FOR X=0 TO 65STEP 13
3720 F$="":F=F+1
3730 X2=X:Y2=Y
3740 FOR X2 =XTOX+12
3750 K=VPEEK(X2+Y2*80)
3760 F$=F$+CHR$(K)
3770 NEXT X2
3780 F$(F)=F$:IF MID$(F$,1,1)=" "THEN GOTO 3800
3790 NEXT X:NEXT Y
3800 F=F-1:CLOSE #1:RETURN 110
3810 ERASE F$:DIM F$(112):RETURN
|
|
wolf_
 msx legend Berichten: 4713 | Geplaatst: 05 Januari 2006, 22:49   |
yo legacy:
<code>
code survives here :) ;)
</code>
< > = [ ] |
|
legacy msx professional Berichten: 516 | Geplaatst: 05 Januari 2006, 23:04   |
Next time, I'll do it better.
|
|
[D-Tail]
 msx guru Berichten: 3018 | Geplaatst: 05 Januari 2006, 23:55   |
legacy: that was exactly the method described before - reading the file listing from VRAM. But this doesn't work when the file list is too big to fit on screen, or you use DOS2 (first line will be the current directory display) - as stated. But hey, it's a nice approach... I used it too before I got to know NestorBASIC  |
|
|
|
|