Humanities Home page   Office of Digital Humanities
Back     BYU LiveCode Lessons Gateway

Computers & the Humanities 210

LiveCode Scripting Exercise 2

Download a copy of the stack "ScriptingWork2.rev" from the Templates folder in the DigHT 210 server. There are instructions on each card as to what you should do. If you get stuck and can't figure something out, see Scripting2Key.rev, in the Keys folder on the server, for some ideas. Make sure you understand the handlers there; don't just copy the handlers.

The calculator problem will be the most challenging. Here are the specifications for how the calculator should work:

  1. The calculator only handles calculations with two operands, no more.
  2. In the display group, the top field holds the first operand, the middle field holds the second operand, and the bottom field holds the answer.
  3. There is a field "operator" on the left side of the middle display field that holds the operator.
  4. The number keys are in a group, along with the Clear key and the Rnd key. When a number key is clicked, the label of that key goes after the current operand field.
    (What is the most efficient place for this handler?)
  5. The current operand field is determined by these rules:
    • if all the display fields are empty, number key presses are appended after the last number in the top display field.
    • if there are numbers in the top display field and an operator in the operator field, number key presses are appended after the last number in the middle display field.
    • if the number of characters in the current display field exceeds 12, nothing gets appended to the field.
  6. The C key clears all fields in the display group. (Use a repeat loop to empty out fields 1, 2, 3, and 4 of group "displayGrp".)
  7. The Rnd key adds a random number from 1 to 9 after the current operand field.
  8. Clicking any of the operator keys (+, _, *, /) in the operators group puts the label of that key in the operator field. (What is the most efficient place for this handler?)
  9. Clicking the equals key in the operators group performs the selected operation on the current operands IF there are two operands present. If one or both operands are missing, the equals key only beeps. (Where do you place the handler to prevent this key from acting just like the other keys in this group?)

Save the stack with YourName-ScriptingWork2.rev as the filename.

This assignment is due by the beginning of class on the due date specified in the class schedule. Turn in your completed assignment by dragging a copy of the stack from your data disk into the Assignment Drop folder in the DigHT 210 folder on the DigHT 210 server (hummac.byu.edu) as explained before.


Back     BYU LiveCode Lessons Gateway
Maintained by Devin Asay.
Copyright © 2005 Brigham Young University