Re: [cc65] CBM LFN Question

From: <silverdr1wfmh.org.pl>
Date: 2010-10-24 20:38:21
On 2010-10-24, at 18:00, Ullrich von Bassewitz wrote:

> Logical file numbers are like file handles. The bad thing about them is, that
> they aren't assigned by the kernal (which could easily track the ones already
> used), but by the user.
> 
> If the library uses a certain lfn, it cannot prevent the user from using the
> same one in his own code.

How about "forgetting" the numbers? I mean if we use POSIX style I/O, we shouldn't care about this.

> This defeats modular programming and is the reason
> for the hassle in the library and the "be careful" statements in regard to
> mixing POSIX file I/O and CBM file I/O.
> 
> Lfns 1 and 2 are used by LOAD and SAVE if I remember correctly. This is the
> reason why the library uses lfns starting with 3. The other assumptions are
> necessary because of the way, logical file numbers work on the commodores. One
> could also write a "logical file number dispatcher" that could by used by the
> library and user code,

Some time ago - I wrote a short code that scans the file table and returns available "filehandle", unless the limit of ten concurrent files is reached. AFAIR that limit was the only thing that I had to take care of. I wrote it exactly because I felt like I 1) didn't want to hardcode any LFN numbers 2) didn't want to limit what the user might have opened prior to running my prg. Maybe something like that could go into lib? I should still have it somewhere but if memory serves, it was quite trivial.

-- 
SD!

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Oct 24 20:38:31 2010

This archive was generated by hypermail 2.1.8 : 2010-10-24 20:38:33 CEST