Time for action – making and navigating between cards
A calculator doesn't really need a title screen, but we'll make one anyway, in order to practice adding scripts and doing some basic navigation. You can either take your cleared-out stack from earlier, or start a New Mainstack from the File menu.
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 a help tip that shows what kind of control it is.
In the Basic Properties section of the Inspector palette, uncheck the Don't wrap check box.
Type
title
into the Name entry field.Choose Contents from the Inspector drop-down menu, and replace the initial text that says Label: by typing
Simple
Calculator
into the contents entry field.Choose Text Formatting from the drop-down menu, and click on the align text center button, which is 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-hand side in the Tools palette) from the Tools palette, and place it below the title field.
In the Inspector, choose Basic Properties from the drop-down menu (it's the menu that says Text Formatting in the screen shot above), type in
Begin
into the Name entry field. LiveCode will automatically show the same text as the button's label, even though you didn't type it into 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 will show a starter script, of
on mouseUp
, (empty line), andend mouseUp
as shown in the following screenshot:Complete the script by typing in
go next
into the blank line to give you this final script:on mouseUp go next end mouseUp
Close the script window, and click on Yes when asked if you want to save the changes.
Choose the Browse tool from the Tools palette (the upper left-most 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 name
Simple Calculator
, somewhere you can easily find later. Perhaps you could make a folder to hold the stacks you will make while reading this book.
What just happened?
That may have seemed like a lot of steps, but we did create the two cards we need, laid out a nice looking title field, and created a Begin button with its own script. In reality those steps take under two minutes, and even less as you gain experience in LiveCode.
Pop quiz – 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