Index ButtonsFields Message Variables
Ask/Answer Colour Sound Menus QuickTime

Random Numbers Stack

Random is a very useful HyperCard function. One common use is to be able to set up maths problems that present different numbers each time the problem is encountered

Make a new stack.

The stack can be small as above. Create a button and name it Random. Create a small rectangular field. You could set the text file in the field to a larger font size, say 16, and maybe a different font. Clone this field 5 times so you have 6 fields side by side. Fields are cloned by clicking on them with the field tool selected and holding the mouse down while you hold the Option key down and drag the new field to it's new position.

Cloning a field is the same as copying and pasting but faster! It also ensures that the fields are all the same size and have the same settings. Notice the fields are numbered in the order of creation

Paste the following script into your "Random" button:

This script will generate 6 unique random numbers each time you click the "Random" button.

You could make more fields for more random numbers and change the "sixes" in the script to the new number. Or you could change the 49 so that number you choose to select the random numbers from is greater ot smaller. Experiment with the script so you understand how it works. The Commas are used to separate (or delimit) the items. randNum, uniqueNum, selNum, theNum and thisOne are variables.

To clear the random numbers when you close the card put the following script in your card script

Return to top of page