[futurebasic] Re: [FB] More questions than a two year old

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2004 : Group Archive : Group : All Groups

From: Brian Stevens <brilor@...>
Date: Wed, 7 Jan 2004 21:27:01 -0700
On Jan 7, 2004, at 7:39 PM, George Beckman wrote:

> When building an app for OS X, where should I be storing my 
> preferences?

Scott gave you the best answer now that Staz has implemented GET & PUT 
Preferences. Before Staz simplified this I started using an FN that 
provides the FSSpec of different system folders (depending on what 
parameter is passed to it). The following code snippet (not a runable 
demo) illustrates this.  Using _kPreferencesFolderType with FINDFOLDER 
also returns an FSSPec to the users==>library==>preferences (which is 
the right place to put it). This FN has the flexibility to be used for 
other locations besides the preferences folder by passing a different 
value for the third parm.


LOCAL MODE
LOCAL FN FindIt(name as str255,PrefSpec AS ^FSSpec,theFolderType as int)
DIM @ vRef   AS INT
DIM @ dirID  AS LONG
LONG IF FN FindFolder(_kOnsystemdisk,theFolderType,0,vRef,dirID) = 
_noErr
FN FBMakeFSSpec(vRef,dirID,name, prefSpec )
END IF
END FN


dim filename as str255
dim myLocalSpec as FSSpec

begin Record PreferenceRec
dim this as int
dim that as boolean
dim another as rgbcolor
end record

_MyPrefsSize = sizeof(PreferenceRec)
dim MyPrefs as PreferenceRec

FN FindIt(filename,myLocalSpec,_kPreferencesFolderType)
OPEN "R",1,@myLocalSpec,_MyPrefsSize
etc.....