[futurebasic] CFStringToHandle

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2007 : Group Archive : Group : All Groups

From: Bernie <fb.mailing.list@...>
Date: Mon, 12 Feb 2007 20:41:48 +0100
I've never been able to get to grips with handles and pointers.

How do we copy a CFString to a handle? I thought I'd done it a while  
back but can't find it.

This bombs.

'----------
toolbox fn CFStringGetBytes( CFStringRef theString, ¬
CFIndex rangeLocation, CFIndex rangeLength, ¬
CFStringEncoding encoding, UInt8 lossByte, ¬
Boolean isExternalRepresentation, UInt8 *buffer, ¬
CFIndex maxBufLen, CFIndex *usedBufLen ) = CFIndex

local mode
local fn CFStringToHandle( string )
'~'1
dim as Handle @ h
dim as CFIndex size

size = fn CFStringGetLength( string )
h = fn NewHandle( size )
long if ( fn CFStringGetBytes( string, 0, size,  
_kCFStringEncodingMacRoman, 0, _false, @h, size, #0 ) )
DisposeHandle( h )
h = 0
end if
end fn = h

dim as Handle h

h = fn CFStringToHandle( fn CFSTR( "The vandals took the handles" ) )

do
HandleEvents
until 0
'----------

Bernie