UpAboutMore


Build-a-Calculator

Wizard Card  -  Volume 17  -  Mr. Wizard Number 1  -  Sat, Nov 24, 1990 3:06 AM




These Mr. Wizard stacks just keep getting better and better! For some time now I have been searching for a way of demonstrating what it is like to create a HyperCard stack from start to finish. Although this stack takes only a few minutes to run through, I think it does a fine job of conveying the overall process.

WHAT IT DOES

This tutorial stack teaches you how to build a working four-function calculator in nine easy steps. As you push the forward button to advance to each new step, an invisible hand moves the cursor, pulls down menus, opens dialog boxes, and clicks on buttons. On the left half of each screen, the calculator takes shape and begins to function correctly. The right half of the screen provides commentary which explains each step.

On the first and last screens you will notice a home button being struck by a lightning bolt. In this and all future Mr. Wizard stacks, pushing this button will return you to the Mr. Wizard card which opened the stack for you in the first place. If you open the stack directly, this button will simply pop you back to your Home stack. In this way the Wizard stacks can be conveniently linked to cards like this but can also function as stand-alone stacks.

So push the Push Me button to experience this wonderful tutorial and push the house/lightning button to return to this card...

HOW IT WORKS

By the time you finish the tutorial you should have a pretty good idea how the calculator works. But how did I simulate the cursor pushing buttons and summoning HyperCard dialog boxes?

This was an order of magnitude more challenging. The cursor is actually a transparent icon button and the clicking sound is a pair of castanets. Each dialog box is actually a bitmap picture captured with a screen capturing gizmo. In each case, some of the buttons in the dialog boxes were left as mere pictures of buttons and others were replaced with actual working buttons.

Some short and sweet background handlers dramatically simplify the workings of this demo. Typewriter types text with typewriter sound effects and with a human-like uneven tempo. Point handles the animation of the cursor, moving to a specified location at a given speed. And flashmenu simulates a flashing menu selection.

The script of the forward button employs a new HyperCard 2.0 feature: marked cards...

on mouseUp
  if the optionkey is up then
    nextstep
  else
    go to next marked card
  end if
end mouseUp

If you simply press the forward arrow (without holding down the option key) this script invoked a nextstep handler which in most cases resides on the card level. It is this handler which performs all the special effects at each step.

But if you hold down the option key, the button will jump directly to the next step screen, skipping the intervening cards with their annimation. This was done with a single command by "marking" each step screen card. All my script had to do was "go to next marked card".

The stack took two or three sessions to complete. The voice, incidentally, is none other than Bill Atkinson, the inventor of HyperCard. Enjoy!




UpAboutMore