Scrolling list fields

Marielle Lange M.Lange at ed.ac.uk
Thu Jul 7 18:17:06 EDT 2005


>I am a Rev newbie. Two weeks ago I posted a message about creating an
application
>that would calculate distance between schools using two scrolling list fields.
>The first scrolling list field is from a school and the second  scrolling list
>field is to a school. It was suggested that I use custom properties. It was
>also suggested that the schools be numbered for each scrolling list field. For
>example School A would be 1, School B would be 2, etc. I have 80 schools and
>the distances for each of the schools to other schools. My question is how do I
>get the schools listed in numerical order or give them numbers in a scrolling
>list field?

Dear Charles,

If you need sorting, then you can opt for a scrolling list with
Why do you opt for scrolling fields rather than a neat table presentation, as
found on maps:
   1 2 3 4 5 6
1  x y z
2
3
4

Granted, 80 entries is too long for such a representation. [note however that
you could consider having your table data inside a scrolling field with hbar
and vbar and the title bars outside of this scrolling field (eventually with ,
as an equivalent of the "freeze field" in excel].

For a solution based on two vertical scrolling fields, storing your data like
this, on a card not shown to the user makes the values very easy to retrieve.
You create the table, you create a small script to read the first line of the
table and use it to populate your scrolling field for from and your scrolling
field for to. At the same time, you use it to populate an array converting tab
position into a numerical identifier, with numID["school"], numID["school]

I really recommend creating the numID on the fly and using the table storage,
simply because it minimizes the possibility for errors if you happen to need to
add an extra school or remove one from the list (you can easily cut and paste
your distance data from an excel table, and in excel add a column of data or
remove one).

After that, you call to the data with

set itemDelimiter to tab
put the selectedline of field "fromSchool" into tFrom
put the selectedline of field "toSchool" into tTo
put item (numID[tFrom]) of line (numID[tTo]) into tDistance.

And it's done.

Hope this helps,
Marielle





More information about the use-livecode mailing list