[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: Fri, 09 Jan 2004 00:18:15 -0500
>> 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)
> 
> I couldn't get that to work as I expected.

Actually, I cut and pasted  - here's the full routine, as I use it.

Result=FN GetSysFolderVol(_kPreferencesFolderType,_zTrue,fs)'This gets us
the Mac's preferences folder

Result=fn resolvealiasfile(@fs,_zTrue,@IsFolder,@WasAlias)

FN FBMakeFSSpec( fs.vRefNum, fs.ParID, fs.name, fs )

gLWFileRef(_Prefs)=fs.vRefNum
gLWFileID(_Prefs)=fs.ParID

'The following lines then make a "Lightwright Prefs" folder within the
general preferences folder:

FN FBMakeFSSpec( gLWFileRef(_Prefs), gLWFileID(_Prefs), "Lightwright Prefs",
fs )'Make the spec for it

gLWFileID(_Prefs)=FN GetFolderDirID( fs, _zTrue )'Make the folder, if
necessary

gLWFileRef(_Prefs)=fs.vRefNum

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

'At that point, to save to the Preferences file, I just set

myFSSpec.name="Settings"
myFsSpec.vRefnum=gLWFileRef(_Prefs)
myFsSpec.parID=gLWFileID(_Prefs)

And then use OPEN "O",1,@fs,1

To open the file and write to it.

(The gLWFileID() array is defined as a long, the others are all regular
integers. I have a whole bunch of different kinds of files, all with various
locations & weirdnesses - hence the array of info. I suppose I could use an
array of records instead, but the code pre-dates being able to use them.)


To get data from the Application Support folder, I use this chunk of code:

type&=_"asup"      '_kApplicatonsSupportFolderType
CreateIt=_false

#IF CarbonLib=0
LONG IF FN FINDFOLDER (_kOnSystemDisk,type&,CreateIt,Drive%,DirID&) = _NoErr
fs.vRefNum=Drive%
fs.ParID=DirID&
Result=_zTrue
end if
#ELSE
LONG IF FN FINDFOLDER (_kOnAppropriateDisk,type&,CreateIt,Drive%,DirID&) =
_NoErr
fs.vRefNum=Drive%
fs.ParID=DirID&
Result=_zTrue
end if
#ENDIF

I set fs.name="Lightwright Registration Info" and then use open "I",2,@fs,1
to read the actual info.

I hope this makes things a bit clearer.

- John


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