Hello World

Often the first thing you learn to do in a new language is to display "Hello World", this lesson will show you how to do this in LiveCode.

The mouseUp message

The mouseUp message is sent when the user clicks an object. When the mouseUp message is sent an object it triggers a mouseUp handler.

All message handlers begin with the word on and the name of the message (which is also the handler's name), and all handlers end with the word end and the name of the handler.

An example stack

An example stack

For this example we will create a new main stack from the File Menu.

Adding a button to the stack

Adding a button to the stack

We will the add a button to the stack by dragging it from the Tools Palette(1). Select the button by choosing the edit tool (2) and selecting the button (3).

The open the Object Inspector from the Object Menu and name the button "Say Hello" (4)

Adding code to the button

The mouseUp handler for the button contains only one line

on mouseUp
	answer "Hello World!"
end mouseUp

The answer command displays a dialog box with the text you specify. When you click the button, LiveCode sends a mouseUp message to it. The message triggers the mouseUp handler, which displays a dialog box that says "Hello world!"

Open the script editor for the button by selecting Object Script from the Object menu. Then add the above handler into the button script and try it by clicking the button.


You can display a message in a variety of ways. For example, in the LiveCode development environment, you can use the Message Box to show a message using the put command.

on mouseUp
	put "Hello World!"
end mouseUp

You can also use the put command to put text into any field object:

on mouseUp
	put "Hello World!" into field "Message"
end mouseUp





thanks. i needed this to start. just forgot my turbobasic skills from the 80's.


this is very useful advice as i have just starting using live code thank you for this post


bene, vedo che potrò recuperare le mie conoscenze di Hypercard

well, is similar to Hypercard, it's very nice

Add your comment

E-Mail me when someone replies to this comment