Hi there,
there seems to be quite a lot of mixed information about how to deal with string arguments in LOAD and SAVE. I'd like to present the way I came up with:
At the beginning of either LOAD and SAVE, i call a subroutine that gets the string argument using LAB_EVEX and opens the file:
Code:
openfile:
jsr LAB_EVEX
lda Dtypef
bne @go
; not a string, trigger syntax error
ldx #$02
jsr LAB_XERR
@go:
ldy #$00
@l:
lda (ssptr_l),y
beq @open
cmp #'"'
beq @term
iny
bne @l
@term:
lda #$00
sta (ssptr_l),y
@open:
lda ssptr_l
ldx ssptr_h
jsr krn_open
bne io_error
rts
io_error:
pha
jsr krn_primm
.asciiz "io error: "
pla
jmp krn_hexout
As it seems, after calling LAB_EVEX, ssptr points to the string given as parameter including the closing ", which I overwrite with $00 to be compatible with my open routine, which expects the address of a null terminated string.
In another thread, it was suggested to pop the string from the descriptor stack using LAB_22B6, which in my case resulted in ut1_ph/l not pointing to the string, but anywhere in the area of $exxx, where my os resides. So I went for the above approach. It works, but it feels rather dirty due to the overwriting of the closing ". At this point, I am open for suggestions.
EDIT:
BTW, my first approach was to just use Bpntrl as suggested above but this way SAVE always gave me a Syntax Error after having saved the file anyway. As this gave me a really hard time to track down, I went for the somewhat oversized approach using LAB_EVEX together with a bit of dirt as described above.
/thomas