The PRINT statement has the form
PRINT device:index,line-number,modifier,modifier...; control character;item:format...;item:format,item:format...
and, where a PRINT statement has less than three semicolons, the arguments assumed to be omitted are, first, the first set of item:format entries, separated by commas, then the device, line-number, and modifiers, and then the control character, leaving the second set of item:format entries to be present if there are no semicolons.
Within each semicolon-marked division, and each comma-marked division, the later items are the ones assumed omitted.
Recommended @-comments if used:
device @AT: index @USING, line-number @WITH, modifier @AND, modifier... @FEED; control-character @PROTECTING; item @AS: format... @THIS; item @AS: format...
with all but ON, AND, and WITH usable in &'...' substitutes; note
also that the appropriate comment or
substitute is determined by what follows the special character
where items are omitted. Also, USING and
AS can substitute for each other. @WITH, may be replaced by
&'UNDER' (and, of course, @UNDER,`). &'TO'
(or &'FROM' in INPUT and READ) can act as null substitutes replacing
the full comment @
As the entries are largely common to the PRINT, WRITE, INPUT, and READ statements, although some of the items, and some values for some of the items (i.e., the END= modifier) are applicable only to some of those statements, they will be discussed after all four statements have been noted.
Where a FORMAT statement is not specified, and format clauses are not given, PRINT attempts to print the values of expressions in a legible form, separated from each other by one or more spaces. Also, the attempt is made to impose a uniform field-width for each type of numeric variable. This width depends on such things as the internal precision of single and double precision real numbers, and is therefore installation dependent.
The following description of the items in a PRINT statement also applies to the WRITE, INPUT, and READ statements which will be described in subsequent sections. While the PRINT statement only performs output, aspects of the parameters applicable to the statements which perform input are also given here.
The item entries are the variables, constants, or expressions whose values are to be printed or read.
The control character is usually a one-character constant. The possible values for it are somewhat system-dependent, but some recommended values are:
|' '||start printing on a new line (the default)|
|'+'||print on top of the previous line|
|'1'||start at the top of a new page (or clear screen before printing)|
|'2' through '9' and 'A' through 'C'||move to next position on a page indicated by channels 2 through 11 of the control tape of a line printer, or to form positions otherwise preset in other printers|
|'U' through 'V'||select output bin 1 or 2 of a unit-record output device (i.e., a card punch)|
|'P' through 'R'||go to the top of a new page, placing that page in output bin 1 through 3 of a page printing device or any other printer that handles cut sheets|
|'&'||cause the next line to continue printing at the end of this line if its control character is '`'.|
|'*'||set up for printing next line with special character sets (each character in this line indicating which character set is to be used for each character in the next line, instead of this line being printed: it is recommended, but not mandatory, that the blank shall be the character which indicates that the corresponding character is to be printed normally)|
|'#'||acts as *, except that the last character output under it selects the shifted character set to be used until further notice.|
|'?'||as +, except that, in the case of a printer generating proportionally-spaced output, each character to be printed is to be centered directly over the character numerically corresponding to it on the preceding line (for printing of accent marks). Multiple '?' lines do not change positioning, but a '+' line starts fresh.|
|'_'||any underline character in this line indicates that the corresponding character in the next line to be printed is to be underlined. This allows use of 'underline mode' on printers that have it, which allows variable-width underlining for proportional-spacing devices. In addition to underscore, characters for overlining, double underlining, and so on, may also be so affected, and translation (= to double underscore) is allowed, but system-dependent. Other characters are printed as if they were in a line with a '?' control character following the next line printed.|
|'!'||set tab stops: any position containing a non-blank character in a line printed with this control character is a 'tab stop'. These positions do not affect printing on fixed-space (ordinary typewriter-like) output devices, but on a proportional-spacing device, they cause the character in that position to print in the equivalent of that position without regard to the width of the characters that preceded it; this is done by expanding or contracting the rightmost space that precedes that character. Thus, in addition to ordinary tabs, decimal tabs can be handled with this code.|
|'.'||print this line at the end of the previous line, subject to word wrap. Also, retain the line spacing established for the previous line (' ': single spacing, '0': double spacing, etc.). '.', '+', '1' as well as '_', '*', and '/' are not considered to establish a spacing. '+' will not work properly after '.', even on a fixed-spacing device in the sense that the printing it invokes will bear no fixed positional relation to that done previously with '.'; '?' is only guaranteed to work after '.' if the overprinted text is on the most recent physical line printed; thus, overprinting of justified text requires that the overprinted section be printed a word at a time. This does not apply to '_' and '*', as they precede the line they affect.|
|'/'||set left and right margins for use with the '.' control character: they can be in the form n1,n2 where n1 is the left margin, n2 the right margin, and either margin being negative indicates that that margin is ragged, or in the form of a line containing two non-blank characters, . indicating a ragged margin, and ! a justified one. Both margins ragged will cause centering.|
Note that all but the last nine control character values given in the table above refer to previously-established standards.
For an INPUT or READ statement, the control character is only used when obtaining input from a terminal, in which case it might be desired to space in a non-default manner before prompting for input.
When the first set of item:format entries is present in an INPUT (or READ) statement, they indicate items to be printed, not read, when input/output is performed with a terminal device. These items serve as a prompt for input, replacing the default prompt for terminal input to a user program.
With some special terminals, prompts are printed in a special mode; thus, the first set of item:format parameters can be specified in a PRINT (or WRITE) statement to indicate a part of the line to be printed in that mode.
Many terminals have 'cursor keys' that let you move the place where the words you type appear on the screen. Often, terminals and computers with such keys don't let you use them all the time, but only when running special programs such as word processors. Some BASIC interpreters let you use these keys half the time, when writing programs, but not when running them.
What happens is that when a BASIC program asks for input, it prints a question mark, then stops to let you type in your number or text. If you want to type in the same entry in answer to another input prompt, and try moving the cursor up to that line and hitting RETURN, what often happens is that the computer thinks you have typed in everything on that line, including the question mark at the start!
Some computers, however, avoid this problem. To distinguish prompt characters (like the ? in BASIC, or the A> in two major microcomputer operating systems) from user entries, which usually are what people want to type in again a second time, they print the prompts in a different color (perhaps simply with reduced brightness) and keep track of which letters on the screen are which color. Often, the prompts can't be disturbed at all by the user, and are called 'protected fields'.
The first set of item:format entries is printed in the prompt mode, if any, of the output device. One application might be a text editor program: when it lists some lines in the file, complete with their line numbers, then the line numbers should be marked as prompts, since it is most likely just the text that the user might wish to modify and re-enter.
The device is a number indicating the file or device with which input/output is to be performed. On many systems, 6 indicates the usual output device; a line printer for batch jobs, or the user's terminal for programs being operated in interactive mode. 7 tends to be used for a card or paper tape punch, and the low numbers are usually used for disk files. An expression can be used here. If a CHARACTER, STRING, or FIXED_STRING variable (or, for input, an expression) appears here, the statement does not cause any actual input/output, but instead places text in the device parameter, or reads text from it, using the same format conversions that would be used for input/output.
Some disk files allow 'random access': that is, instead of just adding information to the end of a file, you can select any record in the file, and read or replace the contents of that record. The index is used to select the desired record.
In this manual, 'index' refers to a value that can be used to select a file record which is not considered to be part of that record, while 'key' refer to a value performing the function of an index, but also forming part of the data within the record. FALCON provides normally for accessing files which may have at most one index, but multiple keys, and which have at least one index if they have any keys.
An index may be:
a record number, for 'direct access' type files where every record is the same length, and the physical disk address of a record can be determined from its number by simple arithmetic;
a hidden key, for ISAM files used to simulate a direct access file with variable length records and fractional line numbers; or
a physical disk address, for ISAM files which have no hidden keys, only keys which are part of the record, and which are thus referred to as keys in this manual.
In the third case, the index parameter, when used, will usually have the form _IND(keyname,value) or _IND(keyname:value). If separated from value by a colon, keyname is a string parameter; by a comma, it is a TEXT parameter, not requiring quotes.
The line-number is the line number of a FORMAT statement describing how the items in the PRINT statement are to be printed.
The modifiers are (EQUATE) arguments, and include:
CHARACTER=_T causes character-oriented I/O to be performed with the given device in the statement in which it appears. For terminal devices, alternating between character and record input is likely to cause clearing of buffers and loss of data; also, note that in some operating systems the changeover from one type of input to another cannot be performed without opening the physical device as two logical devices, one for each type; thus, terminal devices are to be initially opened as two operating-system logical devices in such a case.
On input, character-oriented I/O means that the computer will not wait for a carriage return when accepting input; for non-terminal devices, FALCON can buffer data to achieve this effect, but for a terminal, it is necessary to disable editing features usually supplied by operating systems even for the simplest terminals (backspace deleting last character, for example). On output, it has the same effect as an '&' control character, allowing its effect to be combined with that of other control characters by using the other control character with a CHARACTER=_T specification.
Unlike ECHO, below, the effect of CHARACTER=_T is the same for terminal input and interactive input from communicating processes.
The FORTRAN 77 modifiers UNIT= and FORMAT= are not available, as omission of the device and line-number arguments preceding the modifiers must be explicitly indicated in FALCON to avoid ambiguity. REC=index is allowed, however, to replace the index parameter.
The format clauses are (TEXT) arguments. Their possible values are shown in the description of the FORMAT statement. Note that it is possible to omit the item part of an item:format pair by placing a colon immediately after the preceding separator; this is useful, as some FORTRAN 77-derived format clauses not referring to items are useful in input/output statements as well. Note that nH..., depending on the contents of the text area, may not be properly interpreted as a TEXT argument, since such objects are not accepted in FALCON expressions and are therefore not handled by normal FALCON scanning, which is applied to the TEXT type arguments of functions and other statements.
A group of item:format clauses can be enclosed in brackets of the form ?F(...)`. The closing parenthesis may be ?F) or )`; the use of the longer form can assist in interpreting mismatched parenthesis errors, but is not obligatory. (It will also assist should a single-character substitute for ?F( be established, as a matching closing bracket would be desired.) This creates a clause which may look like this:
and has the form
and has the function of an implied DO in FORTRAN; allowing looping within an input/output statement. With an invalid start/end/increment set, it will cause the items under its control to be used no times, like a FOR statement in FALCON with an included sequence argument.
On input, a ?V( clause is also allowed; it has the same form as the ?F( clause, but in this case, instead of end being an expression the value of which determines how many times the loop is executed, end is a variable, and indicates the number of times the item:format items in the list could be satisfied from the available input.
Where an item has an array as its value, all the elements in that array are input or output in default order. (FORTRAN performs input/output in storage order, and stores arrays with the first subscript varying the most rapidly; for arrays, FALCON has the opposite default.) The results for arrays of MUTABLE can be unexpected.