[futurebasic] [FB] Core Foundation folks (CF)

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

From: Brian Stevens <brilor@...>
Date: Tue, 24 Jan 2006 17:35:03 -0700
I'm building an FN to filter words from a pointer and return an array  
of words so I can feed the words to Apple's spellchecker. The FN  
below has several obvious flaws that will be corrected (i.e. not  
filtering out non-spaces and other items in the text pointer) and it  
is a work in progress.  Anyway, the fn itself is not my issue (yet!)

What I'm concerned about (and my reason for posting) is my use of TB  
functions that are deprecated such as UppercaseStripDiacritics   
(deprecated as of 10.4 - see TextUtils.h). TextUtils.h recommends  
using  CFStringTransform instead. This CF call does not appear (based  
on parms - but comments indicate it might)  to accept a pointer to a  
block of data (as UppercaseStripDiacritics does). So I guess my  
questions are several here:

1) Does CFStringTransform accept a pointer?

2) Does anyone have a Toolbox def and associated constants for this  
defined? I can't find one in the standard headers or the additions  
donated by RP

3) I'm dreading moving everything to CF, so please excuse my  
ignorance here. Based on the goals, are there other CF things I need  
to tackle? If so, please let me know (this is why I posted the code  
so there would  some context for my pleas and whining).

TIA  - Brian

dim as container gC

local fn FindWords( txtStart as ptr,txtLength as UInt32 )
dim as long     i
dim as str255 theWord
dim as ptr p,max
'~'<
// note: the "+ 1" is merely to skip the length byte of the string
// In real life there won't be a length byte because it will be
// a pointer to a block of data and not a string coming in to the fn

txtStart++'skip past the length byte of string
UppercaseStripDiacritics( txtStart ,txtLength , _smCurrentScript )
p   = txtStart
gC  = "" : theWord = ""
max = txtStart + txtLength
while p < max
i = 0
while p.nil`` == _" "'skip over leading spaces
p++
wend
while ( p.nil`` => _"A" and p.nil`` <= _"Z" )'find ONE word
i++  : theWord[i] = p.nil`` : p++
wend
theWord[0] = i'set string length
// just stuff in container for testing purposes
gC += theWord + chr$(13)'add word to container with carriage return
theWord = ""
wend
end fn
'~'<
dim as str255 s

s = "  this is a test of a new function  "

fn FindWords( @s,s[0] )'test using string - change to pointer to data  
later

print gC
do
handleevents
until 0