[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: John McKernon <misc@...>
Date: Wed, 07 Jan 2004 23:19:27 -0500
> apps which
> seem to be built by smarter folks than me, are storing files in the
> Users/*currentlogin*/library/application support

Actually, you can store preferences in either library/application support or
in library/preferences. Storing them in /application support makes them
accessible by all users, storing them in /preferences makes them unique to
each user. I put serial# and other registration information in /application
support and most other preferences in /preferences.

If all you want is to put it in /preferences, then you can use FB's "Get
Preferences" and "Put Preferences" routines. If you need more, then read on
-- this is useful for lots of other things, too.

Here's the code I use, I'm using FSSpec's and only in OSX, so if you're
programming for OS9 & OSX you'll probably need to make some adjustments. It
works in both Jaguar and Panther.

Most of the code came from the FB^3 CD and bits with help from generous
folks here online:

------------------------------------------------------------
'       Available Folder types....      Where
'       -----------------------------------------------
'       _kSystemFolderType              System
'       _kDesktopFolderType             DeskTop
'       _kTrashFolderType               Trash Can
'       _kWhereToEmptyTrashFolderType   ???
'       _kPrintMonitorDocsFolderType    Print Doc's
'       _kStartupFolderType             Startup
'       _kAppleMenuFolderType           Apple menu items
'       _kControlPanelFolderType        Control Panels
'       _kExtensionFolderType           Extensions
'       _kPreferencesFolderType         Preferences
'       _kTemporaryFolderType           Temporary
'       
CLEAR LOCAL
LOCAL FN GetSysFolderVol(type&,CreateIt,fs as .FSSpec)
DIM Vref%
DIM Drive%
DIM DirID&
DIM Result

Result=_false

LONG IF FN FINDFOLDER (_kOnAppropriateDisk,type&,CreateIt,Drive%,DirID&) =
_NoErr

   fs.vRefNum=Drive%

   fs.ParID=DirID&

   Result=_zTrue

END IF

END FN=Result

------------------------------------------------------------

'Here's the part that gets you the folder, using the above function:

DIM fs as FSSpec
Dim Result

Result=FN GetSysFolderVol(_kPreferencesFolderType,_zTrue,fs)

FN FBMakeFSSpec( fs.vRefNum, fs.ParID, fs.name, fs )
'(I don't know if the above line is strictly necessary, but it doesn't hurt)

'At this point, fs.vRefNum and fs.ParID point to the preferences folder
'Set fs.name to the filename you want to use for your preferences file, and
away you go!


Hope this helps --

- John

------------------
John McKernon
misc@...