Time for action – making cards and navigating between them
A calculator doesn't really need a title screen, but we'll make one anyway in order to practice adding scripts and to do some basic navigation. Start a new Mainstack from the File menu and open the Inspector palette.
- In the Inspector palette, enter the
Simple Calculator
stack name in the Name field. - Select New Card from the Object menu.
- Use the View menu to either go to the previous card (Go Prev) or first card (Go First).
- Make sure you have the Edit tool selected in the Tools palette and drag a Label field to the middle of the card window. In this case, you can easily see which one is the Label field (it says Label: in the icon), but as a general tip, you can point to controls in the Tools Palette and see the help tip that shows what kind of control it is.
- In the Basic Properties section of the Inspector palette, uncheck the Don't wrap checkbox.
- Type
title
into the Name entry field. - Choose Contents from the Inspector drop-down menu and replace the initial text that says Label: by entering
Simple Calculator
into the Contents entry field. - Choose Text Formatting from the drop-down menu and click on the Align text center button, the middle of the three Align buttons.
- Change the font, size, and style options to make a nice looking title, resizing the field itself until you like how it looks:
- Drag a Push button (the second icon from the top-left corner of the Tools palette) from the Tools palette and place it below the title field.
- In the Inspector palette, choose Basic Properties from the drop-down menu (it's the menu that says Text Formatting in the preceding screenshot) and enter
Begin
in the Name entry field. LiveCode will automatically show the same text as the button's label even though you didn't type it in the Label entry field. - You can go into the Text Formatting options for buttons too, if you wish!
- Mentally prepare yourself; we're about to type in our first script!
- With the button selected, choose Object Script from the Object menu. You can also right-click on the button itself and select Edit Script.
- The script window will appear and show a starter script of
on mouseUp
, blank line, andend mouseUp
, as shown in the following screenshot:
Complete the script by typing go next
into the blank line to give you this final script:
on mouseup go next end mouseup
Now, perform the following steps:
- Close the script window and click on Yes when asked whether you want to save the changes.
- Choose the Browse tool from the Tools palette (the upper leftmost tool that looks like a regular cursor arrow) and click on the Begin button that you just made. All being well, you're now looking at a blank card. Don't worry, you didn't just delete the title field and button! You're now on the second of the two cards that you made earlier. Use the View menu again to go back to the first card to try the button again.
- Save! from the File menu, choose Save and save the stack with the
Simple Calculator
name somewhere you can easily find it later. Perhaps, you could make a folder to hold the several stacks you will make while reading this book.
What just happened?
These may have seemed like a lot of steps, but we did create the two cards we needed, laid out a nice looking title field, and a begin button with its own script. In reality, these steps take well under two minutes and will be even quicker to carry out as you gain experience in LiveCode.
Pop quiz – selecting the best name?
If you want to make it big in the multimedia authoring tool world, which of these names would be a bad choice?
- Henry
- Bill
- Bob
- Kevin
Answer: 1
In the early days of multimedia, it seemed like everyone had one of just a few popular names. There was Bill Atkinson, who created HyperCard, and Bill Appleton, who created SuperCard. Kevin Calhoun was the lead HyperCard programmer for a while and Kevin Miller is the head of LiveCode. Bob Stein was one of the founders of The Voyager Company and along with Bob Abel who was one of the pioneers in visual effects. Dan was another good choice as there was Dan Winkler, the author of the HyperTalk language, and Danny Goodman, the author of many famous programming books. Henry would be a good name if you wanted to make motorcars or marry lots of queens.