[futurebasic] Re: [FB] USERESFILE

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

From: Robert Purves <robert.purves@...>
Date: Sun, 4 Aug 2002 10:39:36 +1200
> I see one mistake I made was in my use of FSpOpenResFile
> I should have been using a FSSPEC instead of the file name.
> But this still does not work.


Your example code works for me. That is, it does retrieve a resource 
from the external file.
Perhaps you are being confused by one of the less well-known features 
below??


(1)  If FSpOpenResFile succeeds, it automatically sets the file's ResRef 
to be the top of the resource file chain. In this simplified snippet, 
you don't actually need CurResFile or UseResFile, because resH can come 
*only* from the resource file, and because CloseResFile sets the 
resource chain back the way it was before FSpOpenResFile.

dim as Handle  resH
dim as FSSpec  fs
dim as short   fileResRef
...
...
resH = _nil
fileResRef = fn FSpOpenResFile( fs, _fsRdWrPerm )
long if ( fileResRef ) // FSpOpenResFile succeeded
  resH = fn Get1Resource( _myRsrcType, _myRsrcID )
  CloseResFile( fileResRef )
end if

long if ( resH ) // Get1Resource succeeded
  ... resH was derived from the file...
xelse
  ...cope with error...
end if


(2) Normally, we expect CurResFile at app startup to be the same as the 
app's ResRef:

print "Application's ResRef = " system( _aplRes )
print "CurResFile = " fn CurResFile

In a Carbon-compiled app run under OS8/9, however, they are *not* the 
same: the value of CurResFile is the ResRef for your printer driver.


Robert P.