An example LiveCode Program

Speak

 

this page is part of the annotated examples.

What we do here

Speak reads aloud the text you type.

Specification

We place a text field and a button on the program's window.  Clicking the button will read aloud any text that was typed into the field.

Making it

Step 1:

Launch the LiveCode application, you should see:

xx
after launching LiveCode

Step 2:

Create a new main stack by selecting New Mainstack from the File menu:

xx
making a new main stack

Step 3:

Open the properties inspector to give the stack a name:

xx

Step 4:

Type "Speak" (or something else) in the name field:

xx
Giving the stack a name

Step 5:

Drag a text field from the tools palette onto the stack's window:

xx
putting a text field on the window

Step 6:

Make the text field bigger by dragging the "handles"

xx
making the text field bigger

Step 7:

Like for the field, drag a button from the tools palette to the stack's window, and also make it a little bigger.  In this case drag by the handle in the middle of the right hand side, so only the width changes:

xx
placing and resizing a button

Step 8:

Change the name of the button, using the inspector:

xx
after launching LiveCode

Step 9:

Right-click the button, and select Edit Script from the pop-up menu:

xx
after launching LiveCode

Step 10:

In the script editor window that appears, modify the script text so it looks like this:

xx
editing the script

Press the Apply button in the top left corner of the script editor's window to save the script.

Step 11:

Go to RUN mode by clicking the arrow at the top left in the tools palette:

xx

That tells LiveCode you want to make the program work.  The other arrow (the one with the cross of four little arrows at its lower right) is the editing tool, and it is what we have used until now.  It lets you change the program, whereas what we want to do now is using it.

Step 12:

Type something in the text field, then press the button and listen to the voice.

xx
running the program.

Your computer's sound may have to be switched on, and various other sound settings may have to be enabled of course, but that depends on the state of your machine, not on LiveCode.