Documentation & Books
Mark Wieder
mwieder at ahsoftware.net
Wed Jul 7 17:15:01 EDT 2004
Judy-
Wednesday, July 7, 2004, 1:02:14 PM, you wrote:
Well, since I seem inadvertently to have started this off, let me take
a first stab at this:
An array is just a collection of things.
A simple example:
-- good form to declare a local variable
local strDayOfWeek
-- now let's use it as an array
on InitializeWeekDays
put "Sunday" into strDayOfWeek[1]
put "Monday" into strDayOfWeek[2]
put "Tuesday" into strDayOfWeek[3]
put "Wednesday" into strDayOfWeek[4]
put "Thursday" into strDayOfWeek[5]
put "Friday" into strDayOfWeek[6]
put "Saturday" into strDayOfWeek[7]
on InitializeWeekDays
--Then...
put strDayOfWeek[6]
--or
function DayOfWeek intDayNumber
return strDayOfWeek[intDayNumber]
end DayOfWeek
put DayOfWeek(6)
would give you "Friday"
As with anything programmatic, there are any number of ways to do a
given task - you can certainly do the above without using an array,
and using an array may not be the best approach for a given task. I
generally use arrays when I have a number of similar objects to keep
track of and I want to deal with them in a consistent way.
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list