Holgate / W Gerdeen | LiveCode Mobile Development Beginner's Guide (2nd Edition) | E-Book | www.sack.de
E-Book

E-Book, Englisch, 256 Seiten

Holgate / W Gerdeen LiveCode Mobile Development Beginner's Guide (2nd Edition)

Create interactive mobile apps for Android and iOS with LiveCode
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.

Holgate / W Gerdeen LiveCode Mobile Development Beginner's Guide (2nd Edition) jetzt bestellen!

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):

  1. If you're not already there, go to the second card, the currently empty one.
  2. 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.
  3. 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"!).
  4. Set the name of the button to and the label to .
  5. Select Object Script from the Object menu to see the starter script as you did with the Begin button.
  6. 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.
  7. Close and save the script.
  8. 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.
  9. Set the name to , and label to .
  10. 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 .
  11. Duplicate one of the buttons again, name the new button , and type for its label.
  12. Select for the divide button and change in the middle line to say , making the whole line .
  13. Duplicate the divide button three more times and set the names to , , and . Set the labels to , , and .
  14. Duplicate the divide button again, giving the new button a name and a label , and change the middle line of script to say .
  15. Duplicate the = button and set the new button's name to and label to ; then, change the middle line of script to .
  16. Duplicate the = button and set the new button's name to and label to ; then, change the middle line of script to be .
  17. 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 .
  18. 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 .
  19. 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.
  20. 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:

put "hello world" into the text of member 1

We can perform a slightly less verbose syntax:

the text of member 1 = "hello world"

Or, we can perform a dot-syntax:

member(1).text = "hello world"

In LiveCode, there isn't a choice. What you type has to be in the form of:

put value into container

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:

put character 3 of word 2 of card field "name of field 1" into aVariable put char 3 of word 2 of fld 1 into aVariable

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:

numberPressed the label of me

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:

set the clipboarddata["TEXT"] to me

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:

set the clipboarddata["TEXT"] to the text of me

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:

put the text of me into textvariable

The following will be less verbose compared to the preceding entry, even though they are equally valid:

put me into textVariable

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...


Holgate Colin :

Colin Holgate was originally trained as a telecommunications technician in the Royal Air Force, but with the advent of the personal computer era he transitioned to working as a technical support engineer for companies that included Apple Computer UK. In 1992 he moved to the USA, to become a full time multimedia programmer, working for The Voyager Company. In that role he programmed several award winning CD-ROMs, including A Hard Day’s Night and This Is Spinal Tap. For the last 12 years Colin has worked for Funny Garbage, a New York City based web design company. In addition to using Adobe Director and Adobe Flash for online and kiosk application, he has used LiveCode for in-house production tools. At the introduction of LiveCode for Mobile at the RunRevLive Conference in 2011, Colin entered, and won a contest to create a mobile application made with LiveCode.W Gerdeen Joel :

Joel Gerdeen obtained a PhD in engineering mechanics and biomedical engineering from Iowa State University, where he started using computers in experimental research. In his first employment as a structural analyst, he developed software to assist other engineers to graphically model heavy machinery. His support of engineering computer usage transitioned into a career of software project management at FMC, Honeywell, and BAE Systems, all of which were Fortune 100 companies. Joel has experienced computing evolution from loading machine code through switches on a DEC minicomputer to booting a Raspberry Pi from a microSD card. He has worked with microprocessors, timesharing, personal computers, mainframe business systems, and latest mobile devices. After 35 years of employment, Joel ventured into mobile software development in 2010, working with a small start-up company and publishing numerous apps on both Apple and Google app stores. After working with separate iOS and Android development environments, he discovered LiveCode and was able to build on his former HyperCard experience. Joel is also active in the mobile development community in Minneapolis and has presented LiveCode at local conferences.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.