[comp.sys.mac.programmer] Clarification of question 2

lietb@killer.DALLAS.TX.US (Tjeng-Bo Lie) (06/10/89)

My thanks to Earle Horton's reply...

killer.DALLAS.TX.US
<        (Tjeng-Bo Lie) writes:
<>
<>Two questions to the net...
<...
<>2.  How do I get the name of the application running?  I'm trying to save
<>    some default parms in my application's Data Fork...
<
<     GetAppParms will get you the name, and a GetVol in your
<initialization code will get you the location of your application
<file.  Unless these default parameters are read-only, however, this
<scheme will generate problems in some environments (e.g. file
<servers).
<
<     Do not write to your open application file, either fork, from
<within the application.  Use a separate configuration file if you must
<save information between invocations of your program.
<
<Earle R. Horton
<
<"People forget how fast you did a job, but they remember how well you
<did it."  Salada Tag Lines

...and it works, when the application is a finished, stand-alone application.

Let me clarify what I'm trying to do with question #2 above...

I'm using LSC to write a program that get some of its startup information from
the data fork of the current resource file.  The information is written there 
by another application.  So, application A writes to B.rsrc, and application B 
is trying to read the data fork of B.rsrc (when in LSC, and B itself, when 
standalone.)  Thus my problem is to keep it consistent whether I'm running an 
LSC project or the standalone application later.

I've tried using CurResFile() to get the ioRefNum of B.rsrc, then passing it
(along with vRefNum and the neccessary stuff) to PBGetFCBInfo(), which comes
back with an OSErr of -38, File not open...

Well, if anybody has any suggestion... I'm game to try anything.

-- 
*******************************************************************************
* Compu$erve:  76344,3361        * UUCP:  killer!lietb                        *
* Delphi:  TBLie                 * USnail:  P.O. Box 740483, Dallas, Tx 75374 *
*******************************************************************************

wdh@well.UUCP (Bill Hofmann) (06/13/89)

What I've done to deal with THINK C projects vs built applications is this:
	GetAppParms(apName,&apRefNum,&signature);
	if (signature = GetResource(ApplCreator,0))
	{	/* this way we can use Lightspeed C */
		apRefNum = fb.ioRefNum = HomeResFile(signature);
		ReleaseResource(signature);
	}
	else
		fb.ioRefNum = apRefNum;

This way, if we want to add data to either fork of the current app 
if it's built or to the rsrc file if it's running with a project, 
we're covered.  Here, I assume that there is a signature resource defined
by ApplCreator.  If we're running from the project, it's in the .rsrc file,
and if we're running in a built app, it's in the app.  If it isn't there,
we have the apRefNum anyway, so we're covered (in the case of running from
the project, we'll write into the project file, not such a good idea, but
if you do this early on in the app, you ought to have enough memory, and 
as long as you remember to put the signature resource in there, you'll be
ok).  Yes, I know this is not the way to add preferences.  This is how
one might personalize an application.  BTW, fb is a param block later
passed to PBGetFCBInfo.

-Bill Hofmann