+3 how to detect if a file exist ?
Need help.
I am making a generic menu to my compilations over the spectrum +3.
Exist some way programatically to detect if some file exists on the disk ?
we can do a 'cat' but, how to detect if exist programatically sounds hard, if is possible !
thx in advance
I am making a generic menu to my compilations over the spectrum +3.
Exist some way programatically to detect if some file exists on the disk ?
we can do a 'cat' but, how to detect if exist programatically sounds hard, if is possible !
thx in advance
Post edited by arfgh on
Comments
The +3 manual has details of how to read the directory.
there are some clued up folks who know about ASM and the +3..
so it's a case of parsing the filenames and putting em onscreen.
I did look thru the +3 disk images on here.. and one is MIA , a menu maker..
but in basic prolly too much of an ask..
i never thought in this way. The trick works fine, but.. exist some way to hide the cat text result ?
thx in advance
but if you have the ROM-call to CAT you can see if the value of BC is different on returning to BASIC. If so you can check on that value.
Your code should make a call to a seperate piece of code that scans the name on stack and then make the call to CAT and returning with the right BC value.
Something like this
LET A=USR yourcodeaddress+VAL A$+0 : REM A$ holds namevalue, also string allowed, +0 needed to end return to BASIC OK
ORG yourcodeaddress
RST 20; skip ;
RST 20 ; skip VAL
CALL scanning
JP cat-routine
After running A holds the value of BC if this value is fixed when false then you know when a file is false
BTW : ANY value can be transferred to BC before returning, so ALL registers are possible as check (even a FLAG)
open a channel for writing, write the CAT to the channel check content of the file, delete file???
Nothing on screen
How were you thinking of hiding it? With white ink on white paper it should still work, since the screen bytes will still be there for SCREEN$ to read.
True,
but I think they mean use the screen for other purposes (i.e. a menu that doesn't alter due to reading files)
and how is the sintaxis to do this ?
The reasson to hide the cat result is to not have to repaint the whole menu.
Talking IF 1 here, don't know if +3 can do thge same.
By default you write to screen (channel 0 or 2).
Writing to a printer is done by setting channel 3.
Other channels can be used to handle filetransfer.
Something like this (I don't have the manual at hand here):
OPEN #4;"t";"output"
CAT #4;"Name"
CLOSE #4
OPEN #4;"t";"output"
INPUT #4;A$
CLOSE #4
Then I tried using CAT #1 to put the output in the lower screen area (to use SCREEN$ as suggested earlier), but four lines have to be reserved otherwise the screen will scroll, and the output still has to be visible; eg.: (Line 6 is to open up the bottom four lines, and line 10 is just to show that the screen is not scrolling.)
Really, the only neat way is to use a bit of machine code. I would use DOS OPEN at 0106h, described on pages 224-6 of the manual.
The way to implement a machine code is obscure to me. Can you show a little example ?
thx in advance
That's what I meant. I understood "hiding" as "not printing". Like redirecting a linux command to /dev/nul.
I could write something, but it won't be today - maybe this weekend - if I don't fall off the roof while I'm doing some repairs.
lol !!!! ok
The m/code intro & outro segments (lines 30/32 & 35/37) are from the manual; I wrote lines 31 & 36 (plus the BASIC, of course). It uses file number 3 for its test; if that number is already in use then it will return an error; it can be changed to use a different file number (4-15) if it is known that will not be used by anything else (otherwise it would need additional error handling to check if a file number is already in use and then use a different one). The two relevant lines are the LD B,3 before each ROM call.
as i see you know a lot about the CM !
what tools to program like this ?
Correct me if I'm wrong, but wouldn't such a low CLEAR leave virtually no space for anything else than the BASIC MC loader? Why not put such code just below the UDG area, and leave the whole RAM for the BASIC program?
As I mentioned, I'd taken some of the code from an example in the manual, which used ORG $7000 (=28672). As I'd never done any +3 DOS coding before I decided to play safe and keep the same start point - which is why I pointed out that it was relocatable.
Where to put this code would be tricky as I believe the +3DOS routines do some page ins and outs... Maybe just below $C000 would be a good place.
What about the printerbuffer?
Wouldn't it be one of the worst parts to put it? AFAIK the 128k BASIC uses that area during interrupts, and any game loading code there after the screen needs to be loaded in 48k mode because of this, or it will crash.
I think i can answer this. the CLEAR Its a bit low, but you still have to reduce the ramtop, cos the second thing the program does is to select page 7 (The dos scratchpad) into $C000-$FFFF, so you need to keep the machine code portion of the program and stack below 49152 or immedately after that the program dissappears from memory :smile:
This is battle bunny's code modified slightly for the new ramtop:
(Note, this isnt tested)
This could probably be moved up a hundred bytes or so, I just simply moved the numbers from $7000 to $BF00