[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 14:16:50 +1200
On Sunday, August 4, 2002, at 12:08  PM, Rich Love - Carnation Software 
wrote:

> The plot thickens. It works under OS 9 but fails under OS X.
> Here is your same code with a FILES$ statement so you can select the
> Test.RSRC file to test. It works perfect under OS 9 but with OS X it 
> returns
> a -1 for the fileResRef in fn FSpOpenResFile instead of a good 
> fileResRef .


long if ( fileResRef ) // FSpOpenResFile succeeded
should be:
long if ( fileResRef > 0 ) // FSpOpenResFile succeeded

That little mistake apart, the code works for me in everything from 68K 
to OS X (10.1.5).
Two suggestions:
   Try _fsRdPerm instead of _fsRdWrPerm
   Restart your computer, in case OS X has been hosed.

If neither of those works, then the plot will have become impossibly 
thick.

Robert P.



> 'works under OS 9 But fails in OS X        8/3/02
>
> dim as Handle  resH
> dim as FSSpec  fs
> dim as short   fileResRef
> dim FileName$
>
> window 1
>
>
> resH = _nil
>
> FileName$ = FILES$(_FSSpecOpen,,"Open a resource file", fs)
> print "We just got the file spec for ";fs.name
> print
>
> fileResRef = fn FSpOpenResFile( fs, _fsRdWrPerm )
>
> long if ( fileResRef ) // FSpOpenResFile succeeded
> Print "We got an external file ref of ";fileResRef
>   resH = fn Get1Resource( _"STR#",128 )
>   CloseResFile( fileResRef )
> end if
>
> long if ( resH ) // Get1Resource succeeded
> print "resH is ";resH
> xelse
>  print "Got no Res handle"
> end if
>
> do
> until fn button