Arguments of a println statement must be separated by comma symbols (,). The first statement contains 3 arguments. The arguments are:
- "A day has "
- " minutes"
The second statement contains 2 arguments. The arguments are:
- fg: /pink
Named argument fg of println statement can be used to change the foreground color.
Names of named arguments must be followed by a colon symbol (:).
When a named argument is used in a println statement, all arguments of the println statement must be enclosed inside square brackets .
Named arguments x and y of println statement change the position of text on the screen.
Named arguments must be specified before other arguments in a println statement.
Uncomment the last line of the program. To uncomment it, remove characters << at line start.
After executing the program, try adding a statement so that the program also displays the result of expression 7*8.
You can click on the 'Overview' button in the menu to see how far you have progressed.
The first argument of the clearScr function sets the default background color. The second argument sets the default foreground color.
The named argument height of println statement sets the line height.
- when a named argument is used in a println statement, all arguments must be put inside square brackets .
- The strings to be printed out must be placed after all named arguments.
After running the program, try uncommenting the erroneous lines one by one and examine the produced error messages. Then try to correct each error.
In a free form programming language, the whitespace is mostly unimportant. A program can be divided across lines and separated by blanks as one pleases.
The words of the language cannot be split up. Also, literal expressions like strings and numbers cannot be split up.
Freedom is sometimes dangerous. Badly formatted programs are hard to read, so many errors tend to creep in. That's why we won't write disorderly programs, written like the second statement of this program.
Both statements of this program are identical and produce identical results.
After executing and analyzing the program, try changing the second statement of the program so that it prints out the number of minutes required to make one week.
By default, the println statement prints text on a black background rectangle.To change the color of the background rectangle, use the named argument bg. After executing the program, try changing the last statement of the program so that the text is printed on a red background.
* * *A print statement is similar to a println statement. The only difference is that print statements don't advance the printout to the next line.
Try changing all the println statements in this program to print statements. Then try out the new program.
To print a text without the background rectangle, the named argument eff should be set to /off.
All the named arguments described in this chapter (fg, bg, x, y, height, eff) are valid only in the println and print statements.
Uncomment the last line of the source code, check it to see the error description, then correct the error. When you have corrected the error, run the program.
disc(660, 400, 150, /indigo);
Run this program first.
If some statements of this program are too long, try splitting them into two lines.
* * *
You can change the text of the animated strings in this program, and then you can send the program to your friends by using the Share button.
You will have to type in the title of the program, then enter your name as the author, and select a license.
Then, click on the "Create Link" button to create a program link. Click on the program link to see your program in action. To show your program to others, just send them the program link URL, or use the sharing buttons on the run page.
The last line of the program contains two statements. It has been commented out. It pauses the program until the Esc key is pressed. It is desirable to uncomment this line if you decide to share this program.
This program contains multiple errors. Correct all of them.
Programming languages have a very strict syntax; you are not allowed to make any mistakes because computers can't just figure out what you had in mind. All the errors in the source code have to be corrected before you are allowed to execute the program.
When reporting an error, the computer cannot always guess what exactly the error is. Therefore, you cannot assume that the error message can always tell what is the true nature of the error.
It is OK to look at the solutions after you have tried but couldn't correct the errors.
- when a named argument is used, all arguments must be put inside square brackets .
- The strings to be printed out must be placed after named arguments.
Solution for the first statement
Change the first println statement into:
println [x:370, y:300, height:100, "ZedLX"];
Solution for the second statement
Change the second println statement into:
println[x:i, y:i, height:50, "ZedLX"];
Solution for the third statement
Change the third println statement into:
Solution for the fourth statement
Change the fourth println statement into:
println[x:900-i, y:i, height:50, fg:/cyan, "Zed", "LX"];
If you couldn't solve this by yourself, you should reload the page and try again, until you can do it without solutions.
The given program begins with a multiline comment. A multiline comment begins with the symbols /* and it is ended by symbols */. The contents of multiline comments are ignored by the computer.
The rest of the program contains some unexplained features.