[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 12:50:18 -0500
While Steve and Bernie were talking in this thread, I was playing  
with the code below.

But one question for Bernie, since he translated the header under  
discussion:

Bernie, can only one CFIndex exist at a time? I tried coding more  
than one, but the results always seem to return only information from  
the last array.

May be brain fog here.

Also, for Steve: Why reinvent the wheel? CFIndexFind as already built  
in the CFIndex.incl seems to work fine (see code below), with the  
caveat that I am having trouble building more than one indexed array.

Ken


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

dim as CFIndex testCFIndex

fn CFIndexClear( testCFIndex  )
fn CFIndex( testCFIndex, 0, "Apple pie with ice cream"          )
fn CFIndex( testCFIndex, 1, "Cheese cake with cherries"         )
fn CFIndex( testCFIndex, 2, "Banana split with pineapple"       )
fn CFIndex( testCFIndex, 3, "Fudge sundae with whipped cream"   )
fn CFIndex( testCFIndex, 4, "Chocolate cake with vanilla icing" )
fn CFIndex( testCFIndex, 5, "writing silly FB demos"            )

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

print
print "There are"; fn CFIndexGetCount( testCFIndex ); " elements in  
testCFIndex"
print
print """Cheese cake with cherries"" is the No.";¬
        fn CFIndexFind( indexOne, 0, "Cheese cake with cherries" );¬
        " element in indexOne"
print
print "The string for testCFIndex's second element is: "; fn CFIndex$ 
( testCFIndex, 2 )
print
fn CFIndexInsert( testCFIndex, 3, "Hey, here's an inserted element" )
print "Here are the testCFIndex elements with a new one inserted:"
print
for i = 0 to fn CFIndexGetCount( testCFIndex ) -1
print "  Element No."; i; " is: ";fn CFIndex$( testCFIndex, i )
next i
print
print "Whoa, I did that wrong. Let me sort the index array:"
fn CFIndexSort( testCFIndex )
print
for i = 0 to fn CFIndexGetCount( testCFIndex ) -1
print "  Element No."; i; " is: ";fn CFIndex$( testCFIndex, i )
next i
print
print "Hey, writing silly code has nothing to do with dessert. Get  
rid of it!"
fn CFIndexDelete( testCFIndex, 6 )
print
print "Now let's see our repaired index array:'
print
for i = 0 to fn CFIndexGetCount( testCFIndex ) -1
print "  Element No."; i; " is: ";fn CFIndex$( testCFIndex, i )
next i
print
print "Ah, that's better. Bye."

do
handleevents
until gFBQuit