How Output Commands Output the Results of Your Program
When you run a program, you would like to view the result (output) of the program. In this section, we describe the LOGO Output Commands. These commands enable you to view the results of the program you wrote.
The Output commands are:
- OUTPUT
- SHOW
- TYPE
Ouput Commands Description
When you write and run your LOGO program, it will create an output. How do we view this output? In this section, we will see what commands are available to view the program’s output. The table below lists the commands that you can use to view the results of the programs.
Note: “thing
” referenced in the table below can be any LOGO word, list, etc.
LOGO Output Commands
COMMAND | DESCRIPTION | EXAMPLE |
---|---|---|
OUTPUT value OP value | OUTPUT command can be used only in a procedure (inside the TO procedure). OUTPUT command ends the running of the procedure in which it appears. The value input may be any LOGO thing (word, list, etc.). You return a value by using the OUTPUT keyword. | TO MYPROGRAM OUTPUT [This is the output] END SHOW MYPROGRAM [This is the output] |
SHOW thing (SHOW thing1 thing2 .. ) | Prints the input or inputs, just like the PRINT command, except that if an input is a list, it is printed inside square brackets. The PRINT command, on the other hand, prints the list without the square brackets. If the input is not a list, SHOW command prints the inputs without the square brackets. | SHOW 5 5 SHOW [1 2 3] [1 2 3] PRINT [1 2 3] 1 2 3 |
PRINT thing Or PR thing thing1 thing2 ... ) Or (PR thing1 thing2 ... ) PR is the abbreviation of PRINT. | Prints the input or inputs to the screen. All the inputs are printed on a single line, separated by spaces, ending with a newline. If PRINT command has a single argument (as in Example: PRINT “Hello, it outputs the argument to screen. If the PRINT command is a list or a sentence as in the example PRINT [Hello World!!] or in the example PRINT [1 2 3], the list is printed with brackets removed. Note the SHOW command prints the list with square brackets. | PRINT “Hello Hello PRINT [Hello World!!] Hello World!! PRINT [1 2 3] 1 2 3 |
(TYPE thing1 thing2 ... ) | TYPE command prints the input or inputs like PRINT command, except that no new line character is printed at the end and multiple inputs are not separated by spaces. | TYPE “I TYPE “Like TYPE “Playing Print “Soccer ILikePlayingSoccer |
Lput thing list | Lput command outputs a list with thing added as the last item. In the example thing ‘4’ is appended to the list [1 2 3] | SHOW LPUT 4 [1 2 3] [1 2 3 4] |
Copyright © 2019 – 2024 softwareprogramming4kids.com
All Rights Reserved2