Blog: September 27, 2023 |
home | |
The Select-o-matic HyperCard Stack |
|
The Select-o-matic is a HyperCard stack that will select winners from a list of contestants. It's really that simple. You can type in the contetants, one per line or load them from a text file. Click the Draw! button to select a winner at random. Check the Unique Winners check box to remove contestants as they are selected to prevent the same contestant from winning twice. Select-o-matic will even warn you that you have the same contestant listed more than once. Download Select-o-matic from Macintosh Garden here: macintoshgarden.org/apps/select-o-matic |
|
This is a pretty simple HyperCard stack. It has three cards. The first card contains the application interace. The second, a help card with buttons that pop-up text boxes explaining how the application functions. The thrid, is a listing of the MIT license. When you first open the stack, and the first card is displayed, the Unique Winners checkbox is checked. Since most of the time unique winners is the likely setting, I think it was a logical assumption to make.
on openCard set hilite of card button "Unique Winners" to true end openCard Most of the action takes place when you click the Draw! button. First, a handler is called to remove blank lines from the contestants list. No point in selecting a blank line as the winner. Then, a handler is called to remove extra spaces. This removes possible near duplicates such as "Eric Miller" and "Eric Miller". Then a function to check for duplicates is called. If a duplicate is found, the user is alerted using the answer handler. If there are no duplicate contestants found, the program continues. A random winner is selected and the line number recorded. The program then animates the selection of the winner by hilighting each line of contestants and playing a note, simulating a rotation through the contestants.
on animateDraw theLineNumber repeat with x = 1 to 3 play stop repeat with y = 1 to the number of lines of card field "names" select line y of card field "names" play "harpsichord" "cx" wait 8*x if theLineNumber = y and x = 3 then exit repeat end if end repeat end repeat select empty end animateDraw The rest is file management for loading and saving the contestant list. Or resetting the winners field. The MIT license allows anyone to use, modify, or even create a commercial application from the Select-o-matic stack. My intent is to provide examples of stacks in the style I create primarily for education. However, if you can leverage the stack to create a commercial HyperCard application - more power to you! |