[futurebasic] Re: [FB] app resource gets corrupted

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2003 : Group Archive : Group : All Groups

From: George Beckman <gbeckman@...>
Date: Tue, 05 Aug 2003 17:10:41 -0700
on 8/5/03 2:43 PM, MoorePrint@... at MoorePrint@... wrote:

> I'll check to see if some resources have turned up in a preferences or help
> file. This is a carbon compile and I don't have "help" anymore, but maybe the
> file exists anyway. How do you control the pG to look in another file (or
> not). I don't recall seeing much new documentation on pG in the last couple of
> years.


Bruce,

Here is the routine I am using.   It was "lifted" from the PG Help Routines
and I tweaked it to do my bidding.   It is really the old PG Help routines,
fixed for Carbon by STAZ I think.   I use it for my prefs file.   The main
ide is that I get my Prefs file in my app folder.   This was fairly
necessary for Mac Manager compatiblitiy.   So, ignlore the references to
help.   I am just 1) looking for PGGP Preferences and setting the resource
writes to it or 2) creating it if it is missing and setting the resource
writes to it.

I am thinking that part of this is built into PG.   I put this together
about a year ago and I tend to try to remember only the 10,000 things I need
to know for today.

This way I lock my app resources.  This keeps the dated from changing
everytime my app runs.   It preserves the original resources.   All new or
changed resources are stored in PGGP Preferences.

Please note that I store no actual data in resources.   These are just alias
resources for servers, folders and files, window changes, and a few little
printer nudges I store for my users.  In otherwords, I try to keep PGGP
Preferences machine specific, remembering only things that relate to the
machine, its local and printer.



LOCAL FN PGGPPrefFile
'~'
DIM resHndl&,oldRes,resRef
DIM theQuestion$,theAnswer$,prefName$
DIM lgth,t$,oldFldr,vRef

'IF gHelpResRef<>0 THEN EXIT FN

/*
     This is new for FB^3. The name of the help file was stored in the
     application's resource fork. FB^3 uses a temporary application
     when doing a "Run". When the temp application went away, so did the
     name of the help file.

     This version puts the help file name into a global called
gHelpFileName$
*/

prefName$ = "PGGP Preferences"

LONG IF LEN(prefName$)

resRef = USR OPENRFPERM(prefName$,SYSTEM(_aplVol),_fsRdWrPerm)
LONG IF resRef > 0
'gPrefFlag%=resRef
gResRef=resRef
gHelpResRef = resRef
EXIT FN
END IF

' Calc file type for help file

t$       = "PREFPGGP"
oldRes   = FN CURRESFILE
CALL USERESFILE(gResRef)
resHndl& = FN GET1RESOURCE(_"BNDL",128)
LONG IF resHndl&
BLOCKMOVE [resHndl&],@t$ + 5,4
END IF
CALL USERESFILE(oldRes)
DEF OPEN = t$

' Build and open help file

oldFldr = FOLDER("",0)
vRef    = FOLDER("",SYSTEM(_AplVol))
OPEN "R",#1,prefName$
CLOSE #1
'~':
#if carbonlib
DIM ioErr
dim prefSpec as fsSpec'FileSpec
ioErr = FN FBMakeFSSpec(vRef,0,prefName$,prefSpec)

call FSPCreateResFile(prefSpec,_"PGGP",_"PREF",_smSystemScript)

#else
FN CREATERESFILE(prefName$)
#endif
'~':
oldFldr = FOLDER("",oldFldr)

resRef = USR OPENRFPERM(prefName$,vRef,_fsRdWrPerm)
LONG IF resRef > 0
gResRef=resRef
'gPrefFlag%=resRef
gHelpResRef = resRef
END IF
END IF
END FN

-- 
Best Wishes,

George
mailto: gbeckman@...
http://www.pggp.com