![]() |
The
Multimedia Page |
Last month, we visited the concept of the Hyperlogo programming language and how you can easily create Hyperstudio scripts using "Click Programming". These scripts are then attached to buttons or are executed when you click on a button, enter or leave a card, enter or leave a stack, etc. The example that we worked through last month showed how easily you can attach a script to a button and have Hyperstudio read the text for you. How about something a little more advanced? If you have looked through the list of functions that are available for scripting, you'll have noticed things like RANDOM, RERANDOM, for example. In fact, you can have Hyperstudio create some components that are generated by random numbers, for example. In the card below, I've created two objects. There's a text field that I called "number". This is the place where I'd like to display a random number. In the top left corner, there's a button. When you click on the button, Hyperstudio (through Hyperlogo) generates a random number and then displays it in the text field.
How do you do it? With a litle Hyperlogo programming. The script to generate this rather simple example appears below. In the first statement, I tell Hyperlogo to generate a number between 1 and 10 and call that number "random_number". In
the second statement, I tell Hyperstudio that I want to put something
into the text field called "number". What goes there? The value that
is stored in the variable "random_number", that's what.
Now, it's time to think of the possibilities! What could we do if we could generate random content on a card at will. In this case, the random number is generated by a button. We could have had the random number generated upon arrival at the card so that it was automatically there for us. Every time you visit the card, there's a fresh random number. There's a lot that can be done. Let the imagination fly!
|