Some Foolish questions

Ken Ray kray at sonsothunder.com
Sun Oct 23 15:58:41 EDT 2005


On 10/20/05 3:04 PM, "Fred Giannetto" <fgiannet at hotmail.com> wrote:

> Hello Sir,
> 
> You stated previously
> 
>> You should be able to use 'revDB_moveprev' in order to move back one record
>> at a time. Rather than using a cursor (recordset), it may be more efficient
>> (if there's not a ton of data) to retrieve all the data at once into a
>> variable (or array) and then walk though that. If you need help in doing
>> this, please let us know
> 
> Please advise me on how you would setup the array or variable and be able to
> walk through it (there is not a ton of data).

Well, you'd use 'revdb_querylist' to retrieve your data, like:

  put "SELECT * FROM Entities" into tQuery
  put revdb_queryList("","",tDBRef,tQuery) into tData

and now tData has every record in the Entities table, where each line is a
record, and each field is tab-delimited. So suppose I had three records in
the Entities table, and three fields in the table (First, Last, Phone)...
tData might look like this (-> means 'tab'):

  Ken -> Ray -> 555-1212
  John -> Smith -> 555-1313
  Harry -> Gruber -> 555-1414

So you could use normal repeat loops, etc. to go through this to get what
you need, or do lineOffset() to search for the proper line, like this:

put lineOffset("Ken" & tab,tData) into tLine
if tLine <> 0 then
  set the itemDel to tab
  put item 2 of line tLine of tData into tLastName
  put item 3 of line tLine of tData into tPhone
end if
answer tLastName,tPhone

--> Answers "Ray,555-1212"

If you wanted to take the data and put it into an array, that's a bit more
difficult because the simple act of "split" will cause the first item of
each line to be the 'key', so if you did:

  split tData with return and tab

You'd have this:

  tData["Ken"]  --> "Ray,555-1212"

So that may not work very well for you without a lot of manipulation to get
it right. So perhaps just sticking with a tab-and-return-delimited chunk of
data (what you get back from revdb_queryList) would be best.

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the use-livecode mailing list