[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:56:46 -0500
Steve asked in regard to this dimensioning:

      dim as CFIndex brainsCFIndex, dessertCFIndex

> where do you assign the values to these ?


I don't quite follow your question, but the following example shows  
how to build an array the manual way as assign it values, and the  
next shows how to assign values with CFIndex functions.

The nice thing about CFIndex, is that it provides easy functions to  
find, sort, insert, delete, append and retrieve individual array  
elements as well as the size of the array. When we roll our own, we  
have to create our own functions to do the heavy lifting.



p.s. In my mind I'm working on a scan folder function with CFIndex  
and CFStrings as I write. It works great there (in my mind). Now if I  
can get it onto paper!

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

dim as str255  dessertArray(6)
dim as CFIndex  dessertCFIndex

dessertArray(0) = "Apple pie"
dessertArray(1) = "Cheese cake"
dessertArray(2) = "Banana split"
dessertArray(3) = "Fudge sundae"
dessertArray(4) = "Chocolate cake"
dessertArray(5) = "Key lime pie"

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, 400)
dim as long i

print "These are basically two ways to skin a cat."
print "Here we do the heavy lifting and roll our own array:

for i = 0 to 5
print chr$(9); "dessertArray Element No."; i; " is: "; dessertArray(i)
next i

print "Here we let the system do the work,"
print "plus we can use all the built-in"
print "index array accessor functions."

for i = 0 to fn CFIndexGetCount( dessertCFIndex ) -1
print chr$(9); "dessertCFIndex Element No."; i; " is: "; fn CFIndex$  
( dessertCFIndex, i )
next i

until gFBQuit