Page 1 of 1

Open file for writing does not work after SETLFS

Posted: Thu Nov 09, 2023 2:53 pm
by unartic
Hi!

I want to open a file for writing, which works perfectly. However, if I open the command channel:
   lda #1   ; Logical Number = 1
   ldx #8   
   ldy #15   ;   15=control channel
   jsr SETLFS
to change directory first, the same code that opens the file for writing triggers error $42 (READST).

If i change the line "ldy #15" to any other number the command will fail, but opening the file for writing will work.

If I do the SETLFS but not execute the command to it, opening a file for writing also doesn't work.

Logical file number for opening the file for writing is other then #1

Opening a file for reading works in both cases.

I'm probably missing someting obious here. Please help :-)




   ;Open file for OUTPUT
   lda #2
   ldx #8  
   ldy #1   
   jsr SETLFS
   lda DestFileCnt 
   ldx #<DestFile
   ldy #>DestFile
   jsr SETNAM
   jsr OPEN

Re: Open file for writing does not work after SETLFS

Posted: Thu Nov 09, 2023 3:37 pm
by unartic
I think I've figured it out already.

It seems /mydir/myfile does not mean the first / represents the root.

Re: Open file for writing does not work after SETLFS

Posted: Thu Nov 09, 2023 4:40 pm
by DragWx
If you read the command channel after sending the command to change directories, and the directory does not exist, you will get "62, FILE NOT FOUND,00,00". It's a good idea to read the command channel after issuing a command, because if an error occurs, the activity light will flash until you do. :P

On the emulator, the activity light is a red rectangle in the top right corner of the screen, but on hardware, the activity light is usually going to be a light on the case itself.