This excerpt is from “The Quebec Link” column in the Sinc-Link Newsletter from the Toronto T/S Users Group.
Default device on the QL
Say you are writting a program and it is important to know from which device the user is running it. What can you do?
If the user’s QL is equipped with TOOLKIT II, then it is possible to set the default devices for the program and the data and retrieve them with the functions PROGD$ and DATAD$. But if the user doesn’t set default devices then we are out of luck.
One solution to this problem is to look in the system variable area to determine from which device the QL was booted. The following function, BOOT_DEVICE$, will retrieve that information.
DEFine FuNction BOOT_DEVICE$
pointer1=PEEK_L(164096)+16
pointer2=PEEK_L(pointer1)+36
length=PEEK_W(pointer2)
b$=""
FOR i=0 TO length
b$=b$&CHR$(PEEK(i+length+pointer2))
END FOR i
RETurn b$&"1_"
END DEFine
The first variable, POINTER1, contains SV_FSDEF which gives us the address of the file system physical definition. From this address, we read the variable POINTER2, called FS.NMLEN in the QL Technical Guide. This word gives us the length of the boot device name. From that point, all we have to do is to read the device name with the PEEK function.
Type in the function BOOT_DEVICE$ and try the following command to test it:
PRINT "QL booted from ";BOOT_DEVICE$
For example, the BOOT_DEVICE$ function can be used in a menu program to detect from which device the QL was booted from.