BYU Home pageBRIGHAM YOUNG UNIVERSITY
  Humanities Technology and Research Support Center
Back     CHum Revolution Gateway

Array Exercise—Dictionary array

  1. Create a stack, and place two fields on the card, named "keyword" and "definition".

  2. Create a button called "addToArray". Write a mouseUp handler for the button that puts the definition field into an array, using the keyword field as the key. For example:
  3. put fld "definition" into dictionary[fld "keyword"]
  4. Remember that you will want to declare the dictionary variable as global, because you'll want to have access to it in other scripts.

  5. Now enter a few keyword and definition pairs.

  6. Once you have several pairs saved, create a way to look up the definitions. Make a button called "lookup". In the mouseUp handler, ask the user to type in a word to look up. (Don't forget to declare the dictionary variable as global here, too!) You might use:
  7. ask "What word do you want to look up?"
  8. During a lookup operation, the user should enter a keyword and the definition should be returned. That might look something like this:
  9. answer dictionary[it]
  10. Think about ways to make your lookup program a better user experience. For example, what will happen if the user cancels the ask dialog? One of the hallmarks of well-written software is its ability to robustly handle all user inputs.

  11. Figure out a way to display a list of the available keywords to look up? By clicking on a word in the list you could display the definition the word. The keys function will help you here.

  12. Once this clickable list was working, how could you make sure it always has the most up-to-date list of keywords in it? Modify your stack to do this.

Once your stack is working the way you want, turn it in to the Homework Drop folder on the server.


Back     CHum Revolution Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University