FB II Compiler
Create and use alias
Hold it right there, young feller.
The volrefnum (actually a working directory refnum) is a _temporary_ number. It's generated on demand when you call the FILES$ function, and it is only valid until you quit the program (or you call CLOSE FOLDER, whichever occurs first). It is not meant to be a permanent ID number for identifying the folder.
If you need to track a file or folder over time (between runs of your program), then create an alias record for it. Aliases are specifically designed for that purpose.
To store and use an alias, I suggest Staz's PG functions, MakeAlias and UseAlias. They are in the HFS Util.FLTR. Even if you didn't use PG, you could make a quick one window project and click the HFS button to generate the code, and then snip it.
The resolve alias (Part of UseAlias) toolbox call seems to give you a volRefNum that you want but alas that is not quite true. It actually is giving you the VolumID. To get the one you want use the following, which Rick Brown so generously gave me. The second parameter will be given to you by the UseAlias. You will need to set up this little puppy for the FN using UseAlias:
then you are ready to use this guy...
DIM RECORD fsSpec
DIM 63 fsName$
DIM END RECORD .fsSpec
LOCAL FN SeeAboutAQuickOpen 'the name of my FN
osErr=FN useAlias(1003,myFSSpec) ' This will fill the record above.
_myProcID = _"PGGP"and wdRefNum, the FN result, is the magic number you want. It works for me on alias records created months before. I use it to set the working directory...the folder that is displayed in GetFile or SaveFile.
LOCAL FN GetWDRefNum(volumeID, dirID&,OSErrAddr&)
'Call as follows:
' wdRefNum = FN GetWDRefNum(volumeID, dirID&, @OSErr)
'Returns a Working Directory Reference Number, given a
'_true_ volume reference number (volumeID) and a directory
'ID (dirID&). The wdRefNum should be used in most places
'where FB documentation talks about a "volume reference number".
iopb.ioCompletion& = 0
iopb.ioNamePtr& = 0
iopb.ioVRefNum% = volumeID
iopb.ioWDDirID& = dirID&
iopb.ioWDProcID& = _myProcID
OSErr = FN OPENWD(@iopb)
POKE WORD OSErrAddr&, OSErr
END FN = iopb.ioVRefNum%
I hope this gets you where you are going,