[futurebasic] Re: [FB] CFIndexRead using FSRef

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2008 : Group Archive : Group : All Groups

From: Brian Stevens <bstevens33@...>
Date: Fri, 25 Jan 2008 13:45:40 -0700
On Jan 25, 2008, at 1:06 PM, Steve wrote:

>
> On Jan 25, 2008, at 2:51 PM, Alain Pastor wrote:
>
>> Steve a écrit :
>>> Bernie,
>>> What do I replace in CFIndexRead to read the XML data using a  
>>> FSRef instead of a FSSpec ?
>>> I created fn CFReadXML shown below and it fails where marked in red.
>>> #if def _FBtoC
>>> local mode
>>> local fn CFReadXML( indexID as CFIndex, sRef as ^FSRef )
>>> '~'1
>>> dim as CFMutableArrayRef     array
>>> dim as CFDataRef           @ dataRef
>>> dim as CFURLRef              url
>>> dim as CFIndex count
>>> array = fn CFIndexGetArray_priv( indexID )
>>> long if ( array == 0 )
>>> url = fn CFURLCreateFromFSRef( 0, sRef )
>>>
>> Not sure, but the above line should read:
>>
>> url = fn CFURLCreateFromFSRef( 0, #sRef )
>>
>> No?
>
>
> Thanks,  that is now creating a URL reference.
>
> I am never sure when to use @ ^ # or nothing at all.

To figure it out, look closely at the parameters and the requirements  
of the call. In this case CFURLCreateFromFSRef requires a pointer to  
an FSRef in the second parm.  Next step: how do I pass a pointer to  
CFURLCreateFromFSRef? Well, there is already have a pointer to an  
FSRef in sRef, so that can be used. Next step: how do I tell FB to  
pass a pointer?   In this case case using the "#" tells FB to leave  
it alone and just pass as is since we already have a pointer to an  
FSRef. Without the "#" FB tries to be helpful and pass an address of  
the pointer (which is NOT what we want).