[comp.sys.mac.programmer] SFPGetFile Question

chao@polya.Stanford.EDU (Chih-Chao Lam) (01/08/89)

I am using my own dlgHook in a SFPGetFile call.  I need to access the
vRefNum of the current file being selected in the Standard Open File
Dialog box.  I know it's file name from sfReply.fname but 
sfReply.vRefNum doesn't seem to be giving me the right information.

How can I get the vRefNum of the current file before the user chooses 
"open" or "cancel"?

Thanks in advance,
Chih Chao

bob@accuvax.nwu.edu (Bob Hablutzel) (01/09/89)

> I am using my own dlgHook in a SFPGetFile call.  I need to access the
> vRefNum of the current file being selected in the Standard Open File
> Dialog box.  I know it's file name from sfReply.fname but 
> sfReply.vRefNum doesn't seem to be giving me the right information.

> How can I get the vRefNum of the current file before the user chooses 
> "open" or "cancel"?

You can get the vRefNum from the global variable SFSaveDisk ($214, word).
Note, however, that this is a true vRefNum (actually, it's the negative
of a true vRefNum), and not a WDRefNum. To get the folder that the file
is in, you have to check another global variable, CurDirStore ($398, long),
which contains the current DirID. See the assembly language note on page
IM-72 of Inside Mac for more information.

>Thanks in advance,
>Chih Chao

No problem.

Bob Hablutzel		BOB@NUACC.ACNS.NWU.EDU

siegel@endor.harvard.edu (Rich Siegel) (01/09/89)

In article <5959@polya.Stanford.EDU> chao@polya.Stanford.EDU (Chih-Chao Lam) writes:
>I am using my own dlgHook in a SFPGetFile call.  I need to access the
>vRefNum of the current file being selected in the Standard Open File
>Dialog box.  I know it's file name from sfReply.fname but 
>sfReply.vRefNum doesn't seem to be giving me the right information.

	When your dialog hook gets called the name and file type of
the file selected are stuffed into the reply record. However, to get
the vRefNum (or WDRefNum), you need to look at two low-memory globals:
SFSaveDisk and CurDirStore.  SFSaveDisk contains the NEGATIVE of the vRefNum
of the volume being displayed, and CurDirStore contains the dirID of the
directory being displayed. You can use these two values to open a working
directory, if you need to.

	Another trick, to avoid opening WDs, is for each reply record,
copy -SFSaveDisk into the first word of the reply record (normally occupied
by "good" and "copy"), and copy CurDirStore into the longword occupied
by "vRefNum" and "version". This will give other routines access to the
same information as your hook.


		--Rich


Rich Siegel
Staff Software Developer
THINK Technologies Division, Symantec Corp.
Internet: siegel@endor.harvard.edu
UUCP: ..harvard!endor!siegel
Phone: (617) 275-4800 x305

Any opinions stated in this article do not necessarily reflect the views
or policies of Symantec Corporation or its employees.

leonardr@uxe.cso.uiuc.edu (01/09/89)

chao@polya.Stanford.EDU(Chih Chao) writes in comp.sys.mac.programmer

>I am using my own dlgHook in a SFPGetFile call.  I need to access the
>vRefNum of the current file being selected in the Standard Open File
>Dialog box.  I know it's file name from sfReply.fname but 
>sfReply.vRefNum doesn't seem to be giving me the right information.
>
	this does seem to be the case, I wish I knew why??

>How can I get the vRefNum of the current file before the user chooses 
>"open" or "cancel"?
>
	I have not tried it, but you might try checking the lowmem global,
CurDirStore and see if that has the proper value stored there..
	I would be curious to know if that works, or how you finally solve the 
problem, so please let us know!


+---------------------------------+-----------------------------------+
+                                 +  Any thing I say may be taken as  +
+   Leonard Rosenthol             +  fact, then again you might decide+
+   President, LazerWare, inc.    +  that it really isn't, so you     +
+                                 +  never know, do you??             +
+   leonardr@uxe.cso.uiuc.edu     +                                   +
+   GEnie:  MACgician             +  MacNET: MACgician                +
+   Delphi: MACgician             +  AppleLink: D0025                 +
+                                 +                                   +
+---------------------------------+-----------------------------------+