Finding the path of a file - How can you find the actual filepath of an application's messages file when its path has several possible answers, e.g. for !Printers, the filepath for the messages file uses Printers$Path which contains
Choices:Printers.,ADFS::HardDisc4.$.Apps.!Printers.,Resources:$.Resources.Printers.
Open the required file using SWI &0d,&41 using the filepath variable and the filename. This returns, in R0, the file handle (=0 if file not found)
Now use
SWI &09,7,fhandle,buffer,,,buflength TO ,,,,,nochrs
where buffer is reserved memory of say 1024 bytes, buflength = 1024 (max size of buffer), nochrs will equal the length of actual filepath.
This SWI will load the actual filepath in the buffer.
Now close the file.
Here is a Basic version.
REM Hint/Tip for finding actual path of a file
MODE28
DIM buf% 1024
path$=FNfindpath("Printers:","Messages",buf%,1024)
PRINT path$
END
DEF FNfindpath(p$,f$,b%,l%)
LOCAL f%,e%,a$
SYS &0D,&41,f$,p$ TO f%
IF f%>0 THEN
SYS &09,7,f%,b%,,,l% TO ,,,,,e%
SYS &0D,0,f%
b%?(l%-e%)=13
e%=INSTR($b%,f$,1)-1:b%?e%=13
a$=$b%
ELSE
ERROR 0,"File "+p$+f$+" not found"
ENDIF
=a$
|
| Source: | Archive Magazine - 14.12 - Hints and Tips |
| Publication: | Archive Magazine |
| Contributor: | Brian Pickard |