Capabilities: RTF editing, Graphs, flat-file database

Sarah Reichelt sarahr at genesearch.com.au
Wed Jun 9 23:44:03 EDT 2004


>>> Another very popular way is to use a single data field with one line
>>> per record, and each field in the record separated by some delimiter,
>>> usually tab. The whole field can be loaded into memory allowing very
>>> fast searching, sorting etc.
>
> Sarah, can you point me to the Rev functions you would use for this?
> Sounds like you are saying that Rev has Awk-like capabilities. This
> has the merit of simplicity. But with up to 60,000 records, I would
> have to test the speed and memory issues.
>
Supposing your complete data set is stored in a field called "Data" (or 
a text file), when you start your app, set a custom property e.g. set 
the cMyDataSet of this stack to field "Data"
Now your data is held in memory so it is faster to access.

I am assuming that your data is in a sort of spreadsheet format with 
rows & columns
e.g. firstname <tab> lastname <tab> phone <tab> email <tab> notes <cr>

How you handle it now really depends on what manipulations you want to 
do.
To sort:
put the cMyDataSet of this stack into tempVar
set the itemdelimiter to tab
sort lines of tempVar by item 2 of each  -- sorts by lastname
set the cMyDataSet of this stack to tempVar

To filter:
put the cMyDataSet of this stack into tempVar
filter tempVar with "*Smith*"  -- reduces list to only lines containing 
Smith

If you want to set & retrieve data:
put "Jones" into item 2 of line 65 of tempVar
put item 3 of line 9999 of the cMyDataSet of this stack into tPhone

If you are doing of lot of line-based access, convert the data set to 
an array using split
put the cMyDataSet of this stack into tempArray
split tempArray using cr

Then you can get tempArray[59999] which will be much faster than 
getting line 59999 of tempVar

It is difficult to be more specific without knowing exactly what format 
your data is in and how you want to manipulate it, but hopefully this 
has given you some ideas to start with.

Cheers,
Sarah



More information about the use-livecode mailing list