GBeckman@... wrote: > I would like to add to Mike's questions as I share much of his perplexity > about vrefnums. > > 6. How can I resolve an alias (PGs useAlias) and then find out what the > vrefNum of the new file (in my case often on a server) is? UseAlias and the > tool box call resolve alias appear as if they are going to give you refnum, > but it ain't so. This is a common source of confusion: UseAlias returns an "fsSpec" record containing 3 fields which are called "vRefNum", "parID" and "name". The "vRefNum" that is in an fsSpec record _is_ in fact a true volume reference number (like -1, -2, etc.), but the thing that's usually called "vRefNum" in FB documentation is _not_ a true volume reference number; it's a "working directory reference number," which is another thing altogether. >I want to use it in Andy's example on the STAZ site: > > 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 > > The above fn allows my users to use the finder (or an alias on the > desktop) to log onto a server, open a file and have the next open (or save of > a new document) from within my app. be set to the folder in which the file > just opened resides. Trouble is, use alias gives -1, -2, etc. and those are > not the actual volRefNum. Actually, UseAlias is saving you a step, so it's unnecessary even to use FN SetFilesFolder as written. FN SetFilesFolder expects a working directory reference number (Vref%), which it then resolves into a (true) volume reference number and directory ID number, which it then uses to set globals CurDirStore and SFSaveDisk. But UseAlias _already_ gives you the (true) volume reference number and directory ID you need, because they're part of the returned fsSpec record. All you should need to do is this: DIM RECORD fsSpec DIM fsVRefNum% DIM fsParID& DIM 63 fsName$ DIM END RECORD .fsSpec : DIM myFSSpec.fsSpec : OSErr = FN UseAlias(resID, @myFSSpec) % _SFSaveDisk , -myFSSpec.fsVRefNum% & _CurDirStore, myFSSpec.fsParID& Hope this helps. - Rick