Code: Select all
REMark boot file
TK2_EXT
DATA_USE CURRENT_DRIVE$
LRESPR ext_a
LRESPR ext_b
LRESPR ext_c
LRUN main_program_bas
Code: Select all
REMark boot file
TK2_EXT
DATA_USE CURRENT_DRIVE$
LRESPR ext_a
LRESPR ext_b
LRESPR ext_c
LRUN main_program_bas
I know, but the problem is I'd like to know what the current device is, to set DATA_USE accordingly.RWAP wrote:However, if you use the PROG_USE and DATA_USE commands in Toolkit II to set up the default program and data devices, you can access them with PRINT PROGD$ and PRINT DATAD$
I thougth about that too and did some memory searches, just to take a look, but found nothing usable. The command could be "command filename", and the system would use the DATA_USE device. The extraction would have to check that.Mr_Navigator wrote: "Command ABC1_filename", if this can be put into a string, then the drive ABC1_ could be extracted
Code: Select all
let dev$=prog_device$
lrespr dev$&"ext_a_code"
lrespr dev$&"ext_b_code"
mrun dev$&"main_bas"
deffn prog_device$
loc dev_offset,number,devs$,dev$
let dev$=""
let devs$="windosflpmdv"
if not prog_found_in("")
for dev_offset=1 to len(devs$) step 3
for number=1 to 8
let dev$=devs$(dev_offset to dev_offset+2)&number&"_"
if prog_found_in(dev$):exit dev_offset
endfor number
next dev_offset
let dev$=""
endfor dev_offset
endif
ret dev$
enddef
deffn prog_found_in(device$)
loc channel
let channel=fopen(device$&"ayc_bas")
if channel>0:close #channel
return channel>0
enddef
Thank you for the idea. But I was searching for a more general solution: The first requirement is to include any drive number (e.g. dos3_, mdv4_), not only the 1, to let the user boot the program by hand at any time in any working session, whithout needing to boot the system (though it will not be the usual case). The second requirement is to use only TK2, because until the right device is guessed, no toolkit can be loaded. That's why I wrote the simple brute force search function to find the main program in any device.tofro wrote: Iterate through the list using DEVICE_STATUS (d$&"BOOT") from Turbo toolkit
You could try fetching the last line typed in by searching the system's channel definition block for #0 ... Search backwards to the start of the line; change a pointer and then use INPUT to fetch the previous line typed in. There is one small unwanted side effect: the INPUT command will print out the text again.I think the information of the last drive used somehow must be kept in the system, if only in some temporary store (at least, the last command interpreted).
Code: Select all
100 DEFine FuNction LAST_LINE$
110 LOCal Sys, ch0, TOREAD, DATstart, DATfin
120 LOCal end_p, ten, esc, up, down, p, k, Lin$(136)
130 IF VER$="JSL1" OR VER$="HBA" : Sys = VER$(-2) : ELSE Sys = 163840
140 ch0 = PEEK_L(PEEK_L(Sys+120)+4*0) : REMark address of #0
150 REMark ch0 + 112 : REMark pointer to next vacant byte
160 TOREAD = ch0 + 116 : REMark pointer to byte yet to be read by INKEY$/INPUT
170 DATstart = ch0 + 120 : REMark start of data area
180 DATfin = ch0 + 255 : REMark end of data area
190 end_p = PEEK_L(TOREAD) : ten = 10 : esc = 27 : up = 208 : down = 216
200 FOR p = end_p-2 TO DATstart STEP -1,DATfin-(end_p=DATstart) TO end_p STEP -1
210 k = PEEK(p) : SELect ON k = ten, esc, up, down : EXIT p
220 REMark ctrl_space will also terminate a line - but cannot be detected
230 END FOR p
240 IF p = DATfin : POKE_L TOREAD, DATstart : ELSE POKE_L TOREAD, p+1
250 INPUT #0, Lin$ : RETurn Lin$
260 END DEFine LAST_LINE$