Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Repeat SetVol query Message-ID: <8891@hoptoad.uucp> Date: 2 Nov 89 06:47:55 GMT References: <3260@carthage.cs.swarthmore.edu> <2802@hub.UUCP> <3273@carthage.cs.swarthmore.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 60 From article <3260@carthage.cs.swarthmore.edu>, by jackiw@cs.swarthmore.edu (Nick Jackiw): > You can't SetVol(...) to the working directory returned by SFGetFile > under HFS. In article <2802@hub.UUCP> 6600pete@hub.UUCP writes: > Sure you can. I've done it lots. What error code are you getting back? In article <3273@carthage.cs.swarthmore.edu> jackiw@carthage (Nick Jackiw) writes: >No error. Just no results. Seems to me the following program, which >calls SFGetFile thrice, should on the last instance bring up the GetFile >dialog in the same directory/volume as a file was chosen in on the first >instance. Got that? Ah-hah! This once again goes to show how important it is to list your symptoms in detail. If you'd said this, you would have been besieged by messages pointing out that Standard File and the current HFS directory have almost nothing to do with each other. If you have to set the directory for Standard File (and this *is* sometimes a valid operation, though indiscriminate use can confuse the user -- remember that power users in particularly frequently "blind type" to Standard File and expect it to work predictably) you do it with a pair of low-memory globals called SFSaveDisk (negative of volume reference number) and CurDirStore (directory id). I demonstrated this technique in the code I just posted on hacking Standard File to select folders. It's more or less documented in Inside Mac IV, chapter 15. Set these globals to the necessary values before your call to Standard File. To do this with a working directory reference number, like the one you get from Standard File, you have to convert the working directory into a volume/folder pair. You do this like so: SFVolDir(wd, volume, folder) short wd, *volume; long *folder; { WDPBRec pb; char name[72]; pb.ioNamePtr = (StringPtr)name; pb.ioVRefNum = wd; pb.ioWDIndex = 0; pb.ioWDProcID = 0; pb.ioWDVRefNum = 0; PBGetWDInfo(&pb, false); if (pb.ioResult) return pb.ioResult; *volume = pb.ioWDVRefNum; *folder = pb.ioWDDirID; return noErr; } -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Now hear a plain fact: Swedenborg has not written one new truth: Now hear another: he has written all the old falshoods. And now hear the reason. He conversed with Angels who are all religious, & conversed not with Devils who all hate religion..." - Blake, "The Marriage of Heaven and Hell"