FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Switch folders using aliases


This should do it. Because I think I see where you are going and this took me (With Rick and Andy G. holding my hand) months to get this right, I am including a routine to switch folders after you get the alias. This has been working very solidly for me across zones on a wide area networks. The only catch is in the setting the folders (second routine). If you do not switch folders the next GetFiles Open Dialog will be set to the old folder, but... If you have Last Folder Used by the application set in General Settings, the Finder really fights you on this one. Other settings, it works great.

I think these is about the best two routines I have as it allows me to throw an alias in resources and have my users access a virtual Mac volume on a main frame without them even knowing went across zones or mounted a volume. For them the GetFile just comes up, they select their file and everything is switched back. I got ooohs and aaaahs on this one. In the case I am including, it simply opens the last file used and sets that directory so they can work in the folder the file resides in.

_myProcID = _"PGGP" {You need your app's signature here}
'-------------------------------------------------
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% {This is the puppy you want}

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

And here is how I used it...

CLEAR LOCAL
DIM osErr
DIM useAlias
DIM RECORD fsSpec
DIM fsVrefNum%
DIM fsParID&
DIM 63 fsName$
DIM END RECORD .fsSpec

DIM myFSSpec.fsSpec

LOCAL FN SeeAboutAQuickOpen

osErr=FN useAlias(1003,myFSSpec)
LONG IF osErr=0
gFileVol=FN GetWDRefNum(myFSSpec.fsVrefNum%,myFSSpec.fsParID&,@OSErr)
gSaveVol=gFileVol
gSaveName$=myFSSpec.fsName$

FN MyOpen {Which includes switching the folder}

'etc...
.

I hope this gets you going...

George