E-Book, Englisch, 256 Seiten
Holgate / W Gerdeen LiveCode Mobile Development Beginner's Guide (2nd Edition)
1. Auflage 2025
ISBN: 978-1-84969-966-2
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)
Create interactive mobile apps for Android and iOS with LiveCode
E-Book, Englisch, 256 Seiten
ISBN: 978-1-84969-966-2
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)
The ideal reader for this book would be someone who already knows LiveCode, is interested in creating mobile apps, and wants to save the many hours it took for me to track down all of the information on how to get started! Chapter 1, LiveCode Fundamentals, will help those of you who know programming but are not familiar with LiveCode. The knowledge you've acquired should be enough for you to benefit from the remainder of the book.
Autoren/Hrsg.
Fachgebiete
Weitere Infos & Material
Time for action – making the calculator buttons
Using the screenshot shown at the start of this chapter as a guide, let's build the calculator buttons (the scripts you will type are also listed if you later want to make sure you typed them correctly):
- If you're not already there, go to the second card, the currently empty one.
- Make sure the Edit button is selected in the Tools palette and drag a Push button to the card, to the position of the button.
- In the Basic Properties panel of the Inspector palette, set the Style drop-down menu to Rounded Rectangle (in real life, you would take the time to have nice graphical buttons; here, you are just matching my ugly "programmer art"!).
- Set the name of the button to and the label to .
- Select Object Script from the Object menu to see the starter script as you did with the Begin button.
- In the empty line between and , type . Note that is a new handler that needs to be defined later. When used, refers to the current object; in this case, the button pressed.
- Close and save the script.
- Select the button and make a copy of it by choosing Duplicate Objects from the Edit menu and position it where the 8 button will be. Copy/Paste and -drag are two other ways to duplicate an object.
- Set the name to , and label to .
- Repeat steps 8 and 9 for the buttons 9, 4, 5, 6, 1, 2, 3, 0, and the decimal point using the corresponding number instead of . For the decimal point, let the name be .
- Duplicate one of the buttons again, name the new button , and type for its label.
- Select for the divide button and change in the middle line to say , making the whole line .
- Duplicate the divide button three more times and set the names to , , and . Set the labels to , , and .
- Duplicate the divide button again, giving the new button a name and a label , and change the middle line of script to say .
- Duplicate the = button and set the new button's name to and label to ; then, change the middle line of script to .
- Duplicate the = button and set the new button's name to and label to ; then, change the middle line of script to be .
- Drag a Label field from the Tools palette and in the Inspector palette, choose from the drop-down menu. In the settings, choose a nice looking font, right-justified text, and a large font size. Name the field .
- Edit the script of the field. With fields, you don't get the starter script that you get with buttons, so you will need to type the lines yourself. Type these three lines in the script: , , and . DO enter the quote marks on either side of the word .
- Move all the buttons in their right spots and select the sets of buttons to then use the Align tools and make your calculator layout match the screenshot.
- Save it now!
Quite a lot just happened! We have now made all the card level objects and typed in their scripts. Most of the scripts are "calling" up to a card level handler that we will be setting up next. Before doing that, it's worth trying to understand some of the lines we just entered.
Verbosity, synonyms, and "me"
The English-like nature of the programming language in LiveCode is amazingly powerful, but rigidly so. In some other tools, you have a choice of whether you want to use verbose English-like syntax, less verbose, or what is called . The , in Adobe Director, is a good comparison.
Suppose we want to change the text inside a field, that is the first entry of a director movie's cast, we can perform the following verbose syntax:
We can perform a slightly less verbose syntax:
Or, we can perform a dot-syntax:
In LiveCode, there isn't a choice. What you type has to be in the form of:
However, you do have a choice about whether to use a long version of a word, short version, or an abbreviated form. There are also synonyms, which allow you to use a word that makes more sense to you.
Here are the two ways of saying the same thing, with the second variation using an abbreviated form of the keywords:
When you are dealing with the contents of the object that has the script running, you can use the keyword to save on some typing, and LiveCode will also try to work out what you have in mind, if possible.
Take the lines we have entered as examples:
Here, will propagate up to a card handler that we will add (soon) and will look at the Label that you have set for the object that the script is inside of:
In this case, would normally refer to the object (as is the case with ), but because we gave the extra clue of , LiveCode knows that it's the text contents of the field that have the script and not the field itself. Still, because there is potential for confusion, when reading your own code later, you could add a couple of words to make the meaning more clear:
Note
By the way, the display field script is not needed for the calculator to work. It's just there so that at any point of time, you can click on the field and have the current value copied to the clipboard in order to paste it in other applications.
You might choose to be more verbose than is needed, just for readability reasons, and in these chapters, this is going to be the case. It is easier to tell what is going to happen by using:
The following will be less verbose compared to the preceding entry, even though they are equally valid:
In either case, as it's a field, LiveCode knows what you meant.
You see in the script that we typed , what's that all about? Objects in LiveCode have a lengthy description of where they are located, for example, the button of the card ID of the stack. In the calculator application, we need only the single word that you set as the name of the button. If we asked for , it would still say "the button". To just grab the name itself, we use .
There are times when you will want to use the other variations of , including the long name and the abbreviated name, which you can read about in the LiveCode Dictionary entry for . In addition to a description of the different ways to use , there are a number of cautions you need to be aware of.
Tip
Case sensitivity
If any of you use advanced LiveCode, you may notice that in some cases, I have the casing wrong. LiveCode doesn't mind what casing you have used and so, when I incorrectly said instead of , it didn't matter. This feature isn't unique to LiveCode, but it is common among near-English programming languages to not demand that the user gets the casing exactly right before the command works.
Adding the card handlers
If you dared to go ahead and tried using the calculator buttons, you will see a lot of script errors. We need to add in the card level handlers to be at the receiving end of the calls that the buttons make. Instead of walking you through, typing a line of code at a time, it probably would be quicker to present the lines in one go and explain what each...




