I have a "Open Last File" feature on a couple of my apps. I use an alias to
keep track of where things are.
Unfortunately I have never done this in FB^3 so my technique may be
unproven. Also, please realize in this example, the app is actually a file
conversion utility that is moving files from one server to another while
converting. I use the alias to mount the servers and set the working
directory so the user will have the correct locations when they Open or
Save.
When I save, I make sure I do this:
makeAlias=FN makeAlias(MyName$,gmyVol,1003)
You will find FN makeALias and UseAlias in the PG libraries.. HFS
Thanks to Rick Brown of this one
CLEAR LOCAL
DIM iopb.52
DIM OSErr
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%
Thanks to Andy G for this one
CLEAR LOCAL MODE
DIM pBlock.128
DIM Noerr&
LOCAL FN SetFilesFolder(Vref%)
pBlock.ioVRefNum% = Vref%
LONG IF FN GETCATINFO(@pBlock) = _NoErr
& _CurDirStore , pBlock.ioDirID&
pBlock.ioWDProcID& = 0
pBlock.ioWDVRefNum% = 0
LONG IF FN GETWDINFO(@pBlock) = _NoErr
% _SFSaveDisk , -pBlock.ioWDVRefNum%
END IF
NoErr&=FN FLUSHVOL(@pBlock)
END IF
END FN
Here is where I use them to get the volRef which is actually a working
directory. It is the one you use in an Open Statement.
CLEAR LOCAL
DIM osErr
DIM useAlias
DIM RECORD fsSpec
DIM fsVrefNum%
DIM fsParID&
DIM 63 fsName$
DIM END RECORD .fsSpec
DIM myFSSpec.fsSpec
DIM test
LOCAL FN SeeAboutAQuickOpen
osErr=FN useAlias(1003,myFSSpec)
LONG IF osErr=0
gSaveVol=FN GetWDRefNum(myFSSpec.fsVrefNum%,myFSSpec.fsParID&,@OSErr)
END IF
IF gSaveVol<>0 THEN FN SetFilesFolder(gSaveVol)
Right here, you are ready to open, using gSaveVol as the volume
gFileName$=myFSSpec.fsName$ would give you the file name.
END FN
Let me know if I left anything out or was too confusing. Sorta rushed
through this...my Website is down.
--
Best Wishes,
George
<mailto: gbeckman@...>