Of course, programs need to do several things. We can put any number of instructions
between the curly brackets, as in:
The printLine instruction is like the print instruction: it prints the text between
quotes, but then moves to the start of the next line below. Paste in the example and run it.
You will see that the text is shown on two lines:
Hello
World
In fact, the 2 instructions are obeyed (executed) in sequence, working downwards.
Output with alert
Because the printing happens so quickly, we will illustrate the sequence by using an alert pop-up, as in:
Copy and paste the code - note that 2 pop-up boxes appear, and you have to click the OK button
to confirm that you have seen the message.
When an alert has been closed, the program progresses downwards to
the next instuction.
Compilation errors
Often, you will make mistakes in entering the program - such as missing out a semicolon, or mis-spelling a word.
These errors are checked for (when you click Run) by a program known as a compiler. In other words, you can
get compilation errors. You need to fix these before the program
will be allowed to run. An error message will show the error, but such messages cannot always pin down the
exact source of the error. Look at the line it suggests, but look at other parts of the program as well.
problems
on alert, printLine
Write a program which does these tasks in sequence.
Displays your name in the Results area.
Displays your name in an alert.
Displays your address (on several lines) in the Results area.