[aus.mac] Setting a Default Directory

JON@wehi.dn.mu.oz (Jon Eaves) (08/11/90)

G'day People,
	Well, Wit's End is looming fast on the horizon.  I have been trying
a (seemingly) simple task and have been failing dismally.  I want to set
the default volume and directory using a 'STR ' resource containing the
full pathname.
	I've read most of IM IV Ch 14, and IM II Ch 4 but they have 
provided no joy.
	Extracting the 'STR ' stuff was a gimmie, I have the Pascal format
string stored in a Str255 waiting to be used.  The string is of the format
'DriveName:FolderName'  I have tried numerous calls to SetVol and PBHSetVol,
none of which to do any good, but return noErr.
	What's the answer? I'm reasonably sure it's pretty trivial, but I
have been unable to track down what I am doing wrong.

	On a similar vein, how can I use BootDrive to set the volume to 
that 'value'.

	Yours in much confusion.
--------------------------------------------------------------------------------
  Jon Eaves         
               I'm in it for the glory of $cience.

ACSnet    ( jon@wehi.dn.mu.oz )    
UUCP      ( uunet!munnari!wehi.dn.mu.oz!jon )
Internet  ( jon%wehi.dn.mu.oz@uunet.uu.net )
--------------------------------------------------------------------------------

jackiw@cs.swarthmore.edu (Nick Jackiw) (08/13/90)

JON@wehi.dn.mu.oz (Jon Eaves) writes:
> I want to set
> the default volume and directory using a 'STR ' resource containing the
> full pathname.
> 	I've read most of IM IV Ch 14, and IM II Ch 4 but they have 
> provided no joy.
> 	Extracting the 'STR ' stuff was a gimmie, I have the Pascal format
> string stored in a Str255 waiting to be used.  The string is of the format
> 'DriveName:FolderName'  I have tried numerous calls to SetVol and PBHSetVol,
> none of which to do any good, but return noErr.

Try:

var aStr:StringHandle;

begin
 aStr:=GetString(stringID);
 if aStr<>nil then 
  begin
   if SetVol(aStr^,0)=noErr then
    begin
    ...
    end else error 
  end else error
end;

If this doesn't work, try taking a colon on the end of the STR in your
resource file.

Perhaps you're being bitten by an assumption that got me the first time
I tried this.  The default directory is *not* the directory which appears
by default when you do SFGetFile or SFPutFile.  There are low-memory
globals which deal with this;  ask for details if this is the case.

>   Jon Eaves         

-- 
+-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+
|  nicholas jackiw  | jackiw%campus.swarthmore.edu@swarthmr.bitnet           |
+-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+
"Ah...I've got this CHRONIC pain."                             _True Believer_

JON@wehi.dn.mu.oz (Jon Eaves) (08/14/90)

In article <BVYNVM@cs.swarthmore.edu>, jackiw@cs.swarthmore.edu (Nick Jackiw) writes:
> JON@wehi.dn.mu.oz (Jon Eaves) writes:
[ My Stuff Hacked out ]
> begin
>  aStr:=GetString(stringID);
>  if aStr<>nil then 
>   begin
>    if SetVol(aStr^,0)=noErr then
>     begin
>     ...
>     end else error 
>   end else error
> end;
> 
> If this doesn't work, try taking a colon on the end of the STR in your
> resource file.
> 
> Perhaps you're being bitten by an assumption that got me the first time
> I tried this.  The default directory is *not* the directory which appears
> by default when you do SFGetFile or SFPutFile.  There are low-memory
> globals which deal with this;  ask for details if this is the case.
AAAARGH, This is what I want.  I want SFGetFile to open up on a specific
folder. I presumed (incorrectly obviously) that they opened up to the
default directory.  How do I set this up then?
> +-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+
> |  nicholas jackiw  | jackiw%campus.swarthmore.edu@swarthmr.bitnet           |
> +-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+
--------------------------------------------------------------------------------
  Jon Eaves         
               Whatever you do, don't mention the war. - Basil Fawlty.

ACSnet    ( jon@wehi.dn.mu.oz )    
UUCP      ( uunet!munnari!wehi.dn.mu.oz!jon )
Internet  ( jon%wehi.dn.mu.oz@uunet.uu.net )
--------------------------------------------------------------------------------

russotto@eng.umd.edu (Matthew T. Russotto) (08/14/90)

In article <11319@wehi.dn.mu.oz> JON@wehi.dn.mu.oz (Jon Eaves) writes:
>In article <BVYNVM@cs.swarthmore.edu>, jackiw@cs.swarthmore.edu (Nick Jackiw) writes:
>> 
>> Perhaps you're being bitten by an assumption that got me the first time
>> I tried this.  The default directory is *not* the directory which appears
>> by default when you do SFGetFile or SFPutFile.  There are low-memory
>> globals which deal with this;  ask for details if this is the case.

>AAAARGH, This is what I want.  I want SFGetFile to open up on a specific
>folder. I presumed (incorrectly obviously) that they opened up to the
>default directory.  How do I set this up then?

Set CurDirStore to the directory ID of the folder you want to open (2 for the
root), and set SFSaveDisk to the NEGATIVE of the VREFNUM (not WDRefNum) of the
volume the folder is on.

CurDirStore = $0398 (long)
SFSaveDisk  = $0214 (word)
(BTW, in later versions of MultiFinder, these globals are application-specific,
so each application has it's own CurDirStore and SFSaveDisk)
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?

rcfische@polyslo.CalPoly.EDU (Ray Fischer) (09/23/90)

JON@wehi.dn.mu.oz (Jon Eaves) writes ...
>G'day People,
>	Well, Wit's End is looming fast on the horizon.  I have been trying
>a (seemingly) simple task and have been failing dismally.  I want to set
>the default volume and directory using a 'STR ' resource containing the
>full pathname.
>	What's the answer? I'm reasonably sure it's pretty trivial, but I
>have been unable to track down what I am doing wrong.

Trivial?  No, not particularly.  Without going into TOO much detail, I believe
you want to create a new working directory ID and then do a SetVol to
that ID.  Look at the section titled Working Directory Routines starting in
IM IV-158.  Also, pages IV-98 and IV-100 have interesting and pertinent
information.

If you need more info, send me email.

Ray Fischer
rcfische@polyslo.calpoly.edu