The command used to display output to your terminal screen has appeared many times in the examples in this section, and takes the form:
PRINT something
someting
can be a constant, variable, or expression. PRINT
evaluates something
and displays the result on the screen. It begins from the cursor's current position (wherever it was left by the last PRINT
statement) and, by default, leaves the cursor at the beginning of the next row.
To suppress this default behaviour and leave the cursor at the end of the string it has just printed, add a trailing colon to the end of the PRINT
statement, so:
PRINT something:
If you PRINT
often enough, you will reach the point where your next PRINT
will cause the screen to scroll up to make room for the new output. At this point, UniVerse will automatically display the prompt Press RETURN to continue...
, so that information is not removed from the screen before the user has had a chance to read it. This is the same system which causes RetrieVe to pause at the end of each screenful: and as at the RetrieVe prompt, the user has the option of pressing RETURN, pressing Q to abandon the program, or pressing N to suppress further prompts.
To position the cursor to the point at which you wish your output to appear, use the function @(column, row)
. The column
is a number between 0 (the left of your screen) and the width of your screen (usually 80) less 1. Similarly, the row may range from 0 (the top of your screen) to the screen's depth less 1. The function evaluates to whichever escape sequence the user's terminal requires to position the cursor appropriately: so in order to work the terminal type must first have been selected using the SET.TERM.TYPE
command (see Terminal Commands).
You will see the @
function most commonly in statements like this one:
PRINT @(2,2) : INVOICE.VALUE :
However, @
is not a part of the syntax of the PRINT
statement, but an independent function. One advantage to this is that you can build a string which contains an entire screen image which you can then print, and reprint (after, say, displaying a help screen), using one command:
SCREEN = @(0, 0) : 'Invoice Screen' SCREEN := @(0, 1, bits_menu, computers_menu, universe_menu) : 'Number: ' : INVOICE.NUMBER SCREEN := @(0, 3) : 'Value : ' : INVOICE.VALUE * Further fields go here. PRINT SCREEN:
One side effect of using the @
function is that UniVerse assumes that you are using a 'forms based' rather than a 'scroll based' interface in your program, and the Press RETURN to continue...
prompts are suppressed from the point it was first used. Even if you do not need the @
function, you can achieve this effect by including a statement like:
DUMMY = @(0, 0)
The @
function can also be used with a single coordinate to specify a column number of the current row.
If the single parameter is negative, it takes on a special meaning according to its value:
-1 | Clear screen | -8 | End 'protect' |
-2 | Cursor 'home' | -9 | Backspace |
-3 | Clear from cursor | -10 | Move up a row |
-4 | Clear rest of line | -11 | Begin faded |
-5 | Begin flashing | -12 | End faded |
-6 | End flashing | -13 | Begin inverse |
-7 | Begin 'protect' | -14 | End inverse |
You can find the full list in the UniVerse documentation: it extends to about 70 items.
To capture input from the keyboard, use the INPUT
statement, the simplest form of which is:
INPUT variable
This will read a character string from the keyboard until the user hits RETURN, and assign it to variable
. To limit the number of characters accepted, you may add a maximum length of input, as in:
INPUT INVOICE.NUMBER, 10
This will assign a maximum of 10 characters to the variable INVOICE.NUMBER
. The user may hit RETURN before entering his tenth character, but once he has entered the tenth character, the ten characters will be assigned to INVOICE.NUMBER automatically and the program will proceed to its next statement. To force the user to enter a RETURN even when the length of the input length is limited, add an underscore:
INPUT INVOICE.NUMBER, 10_
Normally, INPUT
will echo the characters entered beginning at the current cursor position. You can position the cursor with a PRINT @(X,Y):
type statement, or achieve the same effect by using an @
clause in the input statement again, as in:
INPUT @(2,2): INVOICE.NUMBER, 10_