• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 26. Using a List Database > Retrieving Values with getaProp

Retrieving Values with getaProp

Now that you have created the visual cues that will help a user navigate through the options, the next step is to use Lingo to link the user's choices to the image displayed on the stage. In this task, you will use getaProp (which you became acquainted with at the end of the last lesson), a command designed to retrieve a value from a property list variable. You will create a handler that retrieves a value from the gLocationList variable based on a user's choice and assign that value to a new variable, which you will later use to control the view shown on the stage.

1.
Rewind and play the movie, but don't click any buttons on the stage.

To complete the following steps, you'll need the property list, gLocationList, generated and in the computer's memory. Recall that the property list is created in the startMovie handler, which runs every time the movie plays, so playing the movie now generates the list and places it in memory.

You should see the Victoria north view.

2.
Open the Message window, type the line shown here, and then press Enter (Windows) or Return (Macintosh).

You can add spaces to the command to make it more readable, as shown here.

put getaProp(gLocationList, "white nile")

This command returns "wnile".

3.
Type put getaProp(gLocationList, "victoria") and then press Enter (Windows) or Return (Macintosh).

This command returns "vict".

These are the codes you associated with the location names in the previous lesson. Next you will create a variable to retrieve the same values.

4.
TypenewView = getaProp(gLocationList, "white nile")in the Message window and then press Enter (Windows) or Return (Macintosh).

This creates a variable called newView and assigns it a value based on the getaProp command. Nothing is returned in the Message window because you are creating a variable, not displaying its value. To get a variable value, you type put followed by the variable name.

5.
Typeput newView and then press Enter (Windows) or Return (Macintosh).

This command returns "wnile", the code assigned to "white nile" in the gLocationList property list.

6.
Type newView = getaProp(gLocationList, "blue nile") and then press Enter (Windows) or Return (Macintosh).

7.
Type put newView and then press Enter (Windows) or Return (Macintosh).

This command returns "bnile", the code assigned to "blue nile" in the gLocationList property list. Now the value of newView is bnile.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint