Handle Base File Access Change
A while back I discovered a problem with my ANS/ISO File system not selecting properly from one file handle to another file handle.
This is required for example if you wanted to copy data from one file to another file.
The files opened correctly, the code was selecting the correct PAB for each open file, but I was not changing the O/S address >8356
(which is called DSRNAM from what I can discover)
I did a kludge fix that involved string processing (yuk!) but the real fix meant adding a new field to the standard PAB.
Per the E/A Manual the standard PAB in CAMEL99 Forth is:
byte : opcode
byte : flag/status
cell : data buffer address
byte : record length
byte : character count (read or written)
cell : record number
byte : screen offset (unused)
string: filename (byte counted string) MAX length in CAMEL99=32 bytes
CAMEL99 now has this new field
The magic number that the O/S needs in DRSNAM to "select" a file, is the VDP address of the filename string after the '.' character.
I was doing that correctly when I created the PAB, but the number was not stored anywhere for fast retrieval.
In version 2.0.23 I have added a DSRNAM field to the PAB after the file name buffer.
When selecting via file handle it is now very simple.
The word SELECT takes the handle and "selects" the correct VDP PAB address from an array of PABs.
Now it also reaches into the PAB to retrieve the DSR name and put it into >8356
Here is the new code for SELECT with extra comments.
: SELECT ( hndl -- )
DUP ?FILES \ test if hndl<= max files
]PTAB @ DUP 0= ABORT" Cannot select hndl 0" \ ]PTAB is array of PAB addresses
^PAB ! \ store correct PAB in pab pointer
[PAB DSRNAM] V@ DSRNAM ! ; \ fetch dsrnam from VDP ram, store in CPU ram
Once I made the decision to alter the PAB structure the rest went quickly.
It will get up on GITHUB this weekend.