Think of something that you wish Authorware could do but it doesn't? Let the our good friends at Macromedia know via the wishlist. Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed. Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list. |
Back
B7008 - What is the purpose of property lists? [Part 1] by - Joseph Ganci Property lists are
like linear lists except that you point to locations in the list not by number,
but by a property name. For instance, let's say that you have a list of patients,
students, customers, etc., and for each you are keeping track of certain items
of information, such as name, street address, phone number, city, state, and
zip (postal code for those of you outside the USA). You could set up a linear
list, such that: person[1] is where
you store the name But with property lists,
you can use the name, coupled with a pound sign, to indicate the location: person[#name] The combination of
the pound sign with the property name is called a symbol and takes up very
little room in memory, unlike a variable, since a symbol only indicates a
location in the list. This is true in Director and I assume the same is true
in Authorware. You can mix linear
list and property lists. For instance, you can have a list of property lists: persons[id number][#name] There are several functions
that deal with lists and property lists. They're all good. One that is often
obscured is the function called Symbol. It will convert any string into symbols.
This is not for novices! It's used when you want to set, reset, add to, or
look for values in a property and you want don't know ahead of time the name
of the property. For instance, let's
say you are in charge of a zoo, and you set up each animal in the zoo to have
a location in our zoo property list. The value of each one will be how many
of that animal your zoo possesses. You start with only three animals: zoo[#elephant] := 2 The above sets up our
zoo with 2 elephants, 4 tigers, and 123 slugs. Now let's say you want
the user to add a new animal. You have no idea what the user will type. You
set up a text entry interaction, then you use the Symbol and the AddProperty
functions. The user's animal will be contained in the Authorare system variable
EntryText, so it's a relatively simple matter: animal := Symbol(EntryText) You could combine the
three lines above into one: AddProperty(zoo , Symbol(EntryText)
, Random(1 , 50 , 1)) The above creates a
new location in the property list, assigns the user's entry as its property
name, and sets its value to a random number between 1 and 50. Hope this helps. |