[futurebasic] Re: [FB] CFString

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

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sat, 19 Jan 2008 13:17:29 -0500
Steve wrote:

> I am not trying to reinvent anything, just adapting some prior code  
> already being used.


Steve,

I misunderstood. I thought you were trying to roll your own fn  
CFIndexFind function when one already existed. Apologies.

All (especially Bernie),

Here's a little snippet showing the problem I'm seeing with results  
being returned only from the second CFIndex array. Seems to me we  
should be able to build more than one.

Also, upon creation is there a need to clear the array as a do here?  
(I'm from the belt + suspenders school of codingmeisters).

I'm sure I will soon understand the error of my ways.

Ken


include "CFIndex.incl"
include "Tlbx CFString.incl"

dim as CFIndex brainsCFIndex, dessertCFIndex

fn CFIndexClear( brainsCFIndex  )
fn CFIndex( brainsCFIndex, 0, "Robert Purves" )
fn CFIndex( brainsCFIndex, 1, "Brian Stevens" )
fn CFIndex( brainsCFIndex, 2, "Bernie Wylde"  )
fn CFIndex( brainsCFIndex, 3, "Michele Neri"  )

fn CFIndexClear( dessertCFIndex  )
fn CFIndex( dessertCFIndex, 0, "Apple pie with ice cream"          )
fn CFIndex( dessertCFIndex, 1, "Cheese cake with cherries"         )
fn CFIndex( dessertCFIndex, 2, "Banana split with pineapple"       )
fn CFIndex( dessertCFIndex, 3, "Fudge sundae with whipped cream"   )
fn CFIndex( dessertCFIndex, 4, "Chocolate cake with vanilla icing" )
fn CFIndex( dessertCFIndex, 5, "Key lime pie with strawberries"    )

window 1,, (5, 45)-(400, 590)
dim as long i

print
print "There are"; fn CFIndexGetCount( testCFIndex );¬
" elements in brainsCFIndex"
print "[The answer should be 4]"
print
print "There are"; fn CFIndexGetCount( testCFIndex );¬
" elements in dessertCFIndex"
print"[The answer should be 6]"
print
print """Michele Neri"" is the No.";¬
         fn CFIndexFind( brainsCFIndex, 0, "Michele Neri" );¬
         " element in brainsCFIndex"
print "[The answer should be 3]"
print
print "The string for brainsCFIndex's second element is: ";¬
fn CFIndex$ ( dessertCFIndex, 2 )
print "[The answer should be: Bernie Wylde]"
print
print "The string for brainsCFIndex's fourth element is: ";¬
fn CFIndex$ ( dessertCFIndex,  2 )
print "[The answer should be: Banana split with pineapple]"

do
handleevents
until gFBQuit