Hello World
Top  Previous  Next


Description
This is a step-by-step tutorial for creating a Movie displaying the words "Hello World" in the Debug Panel.

Aim
This Movie introduces the method of entering scripts, explains use of the onLoad() Event and demonstrates the use of the trace command and Debug Panel.

.swi file
"helloworld.swi"


1.   Start with a new project (File | New) and save the file as "myhelloworld.swi"

2.   Select the 'Script' Panel, then enter an onLoad() Event for Scene 1, as shown below.
scripttute1_1

The 'Script' Panel should now look like this:  
scripttute1_2

3. Add a trace command to the onLoad() Event by selecting the onLoad() function, as shown above. Press the 'Add Script' button then select
Debugging | trace(...) from the menu as shown below:
scripttute1_3
Note: It is possible to append a Scripting command by right-clicking on the command you want the new command to appear after, then selecting the Add Script Menu item. Sections of script can also be duplicated and moved using the Cut and Paste Menu options

The 'Script' Panel should now look like this.  
scripttute1_4
Note: The function and trace statement are shown in red. This is because the trace statement is currently incomplete

4.Complete the trace statement by adding the string "Hello World" (including the quotation marks). Select the trace statement in the top half of the 'Script' Panel. The bottom half of the Panel should have the heading trace(); as shown in the image above. Click the bottom section of the Panel (the section with the "trace();" heading) and enter the text "Hello World". Once the second quotation mark has been entered, the text should turn blue. Click anywhere outside of the Panel you have just entered the text into. This will cause the script to be re-validated. The entire script function should turn black indicating that it contains syntactically correct script.  
 
The Panels should now look like this:  
scripttute1_5

Note: If you are confident in the use of command syntax, you can enter commands directly using the Statements | evaluate; Menu option, as shown below

scripttute1_5a

This will result in the following window:

scripttute1_5b
The semi colon ';' will be added for you

5.Select the Debug tab amongst the panels displayed on the right hand side. Check your script by pressing the 'Play' button to run your Movie. The 'Debug' Panel should show the following:  

scripttute1_6
6.Save your Movie  

Analysis
When the 'Play' button is pressed, the Movie loads. This causes the script in the onLoad() Event Handling Function to be executed.
The trace statement containing the string "Hello World" is then executed, causing the string to be displayed in the Debug Panel.