array info request
Jan Schenkel
janschenkel at yahoo.com
Mon Jul 25 17:50:54 EDT 2005
--- keith <keith at vortex.co.uk> wrote:
> Okay, in my state of blissful ignorance I had
> assumed that arrays
> were effectively arranged in a spreadsheet-like
> manner. The array
> name is the spreadsheet (in this way of thinking),
> the keys are like
> a set of column headings, and the elements are the
> bits of data in
> each cell. I hope I'm not too off-target here! <g>
> Anyway, an example of data in this layout, assuming
> it isn't just bonkers:
>
> Record Title ISBN Author Editor Comments
> 1 ABC 123 Tim Tom Lots of blahblah...
> 2 House 345 Mick Mark Different
> blahblah...
>
> Can I extract every record number and title in order
> to search for
> just titles? (I'm imagining that I'd need to know
> which record ID a
> found item was in to be able to pull the full
> record.)
>
You can store your data into an array (or if you want
to sve it more permanently, use a custompropertyset)
and retrieve the data as:
--
put "ABC" into tBooksArray["1,title"]
put "123" into tBooksArray["2,ISBN"]
--
Here's a trick to get a list of all the ID's:
--
put the keys of tBooksArray into tKeys
## limit the keys to those that link to "title"
filter tKeys with "*,title"
## now extract the ID's for each title
repeat for each line tKey in tKeys
put item 1 of tKey & return after tIDList
end repeat
## now do whatever you want with the ID list
--
>
> The rough idea in my head right now is to store the
> data in an array
> in a project:
>
> * People read it, showing one record at a time by
> either clicking
> through sequentially or by searching for specific
> things. The
> elements from that record are retrieved from the
> array and put into
> the right fields as each record is shown.
>
> * If someone wants to edit a record a flag is set in
> its part of the
> array so others can't do the same to that record.
> When editing is
> done, the different fields are written back to their
> respective
> elements in the array.
>
> * New records are made by writing new 'lines' in the
> array. They are
> then available for others to come across as they
> browse the data
> collection.
>
> In the opinion of those that have tried this sort of
> thing and/or
> worked with arrays, is this a moderately sensible
> approach?
>
> the ever-learning k
>
This is a sensible approach, though for storing the
data, I suggest either using custom properties, ro
saving the data into an SQL database.
The latter will definitely help if you want to apply
this in a multi-user situation. Then your editor
stacks can leave the central storage up to the
database.
Hope this helped,
Jan Schenkel.
Quartam - Tools for Revolution
<http://www.quartam.com>
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the use-livecode
mailing list