[futurebasic] Preferences code

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1999 : Group Archive : Group : All Groups

From: Derek Smith <dereksmi@...>
Date: Sun, 12 Dec 1999 13:30:39 -1000
Tedd et all,

Here is a function I use in most of my projects. It doesn't determine the
name of the preference folder, but it does pull up the working directory
id.

The FB^3 code should be child's play to convert.

Clear Local Mode
Dim pblock;128
Dim err as int, pBlk as pointer, @ Drive as int, @ DirID as long
Dim VolRefNum as int
Local Fn FindPrefsVol
  err = Fn FindFolder-'wrapped line, fix this
    (_kOnSystemDisk,_kPreferencesFolderType,_kCreateFolder,Drive,dirID)
  Long If err = _noErr
    pBlk = @pBlock
    pBlk.ioVRefNum%    =   Drive
    pBlk.ioWDDirID&    =   DirID
    err = Fn OpenWD (pblk)
    Long If err = _noErr
      VolRefNum = pBlk.ioVrefNum%
    XElse
      VolRefNum = SYSTEM(_AplVol)
    End If
  XElse
    VolRefNum = SYSTEM(_AplVol)
  End If
End Fn = VolRefNum

And then I use it like this

vol = Fn FindPrefsVol

OPEN "O",#1,"MyPrefsName",,vol

and the file will be created in the preferences folder in the active
system folder.

-D