Notes on the PTH (path) driver.  August 1991 PA Borman This adds a new device driver to Qdos, giving extra devices or directories (paths) to search for a file when opening, loading, execing etc. Because it is implemented at device driver level, it's transparent to the program using it, although it does involve a slight (almost un-noticeable) time penalty on IO operations. The open call can take a significant amount of time depending on several factors. The driver returns as soon as a successful match is found, so the earlier the correct path is in the path list, the sooner it's found. The more paths there are, the longer it takes to search them for a non- existent file before giving up. If a path involves reading the network, there can be a few seconds delay before returning. If a path involves reading a drive which does not contain a disc, there will be a delay until the real driver notices there isn't a disc. In spite of all this, on my QL with 8 paths set up in my usual 'boot' (not including network), trying to load a non-existent file returns in about a tenth of a second. There are several new keywords associated with the driver: PTH_LIST [#n] list all currently defined paths in the order they will be searched to #1, or another specified channel. PTH$(n) a function to return the nth path in the list. Returns an empty string if past end of list. PTH_USE [name] change the name of the PTH device. PTH_USE by itself resets to PTH. Useful for emulation of FLP etc. PTH_USE$ function to return current name of PTH device. PTH_ADD [n,]name add a new path to the list at position n if given, or at the end of the list if n is not supplied. Entries in the list after n are moved down to make room for the new path. PTH_RMV n remove the nth item in the list. May be extended later to allow PTH_RMV \name. There are also two 'special' paths. *d is the current data default, and *p is the current program default. The driver only checks the first letter after the '*', so you can use *Data_default or similar to make things more readable. Examples.. My usual setup is: 100 PTH_ADD win1_:rem always try here first 110 PTH_ADD flp1_:rem look here if not found on WIN1_ 120 PTH_ADD sub1_:rem SUB is another new driver wot i rote 130 PTH_ADD 'sub2' 140 PTH_ADD win1_temp_ 150 PTH_ADD 'win1_asm_temp_' 160 PTH_ADD win1_bas_prg_ 170 PTH_ADD win1_sys 180 DATA_USE pth1_:rem set the toolkit 2 defaults to use the new device 190 PROG_USE pth1_ If I then do PTH_LIST, I get: 0 win1_ 1 flp1_ 2 sub1_ 3 sub2_ 4 win1_temp_ etc. Notice how (as an example) some of the paths are strings, some names. Some include an underscore on the end, others don't. The PTH_ADD command sorts them out automatically. If I then try to load 'demo_bas', the system searches 7 paths, and eventually finds it in 'win1_bas_prg_' less than a tenth of a second later. If I load 'boot', which is on win1_, the load occurs about as fast as normal. If I load 'fred', which doesn't exist, the system searches all 8 paths before reporting 'Not Found'. There are some pitfalls in the use of drivers of this type, mainly because you never know where the file you opened is. This is OK for load and exec, since you (probably) don't care too much, but save will save to the first path it finds room on. For writing, it's probably best to name the device explicitly. Reading you can leave to the path device. If you want to check where the open file is located, while it's open you can use QRAM or QPAC2's channels menu to list the open channels. These channels appear twice, once as PTH1_filename, and a second time with the real drive name. Points to note... It's best to allocate all the paths you need in a block, and as early as possible, like the example above. This reduces heap fragmentation. If you need to remove all the paths... for f=1 to n:pth_rmv 0 where n is the number of paths set, or if you don't know how many paths are set... rep loop:if pth$(0)='':exit loop:else:pth_rmv 0 There's only one path list used for all 8 PTH devices, PTH1 to PTH8. It's best to refer to only one device (I always use PTH1_) as the QL only allows references to 16 'drives'. With 2 floppies, a couple of ram discs, 2 microdrives, a network device or two, a hard disc and some SUB devices, you can see there may not be room for 8 PTH devices too. There's no advantage in using more than one anyway. If (for some reason I haven't thought of) you really need more than one list, you can rename the first PTH device with PTH_USE, and then load a second copy. If you have any problems with this device, find any bugs, or would like to know more about how it works, please contact me.