Subsections

- Transput modes
- Standard channels
- Standard files
- Opening files
- Closing files
- Transput routines
  - Straightening
  - Formatless transput
  - Binary transput
  - Other procedures
- Interrogating files
- File properties
- Event routines
- Conversion routines
- Layout routines

# Transput

If you are unclear about the working of Algol 68 transput, consult chapter 9. The function of this section is to document all the transput declarations so that you can use it as a reference manual.

The declarations will be covered in the following order:-

1. Modes
2. Standard channels
3. Standard files
4. Opening files
5. Closing files
6. Transput routines
7. Interrogating files
8. File properties
9. Event routines
10. Conversion routines
11. Layout routines

In the sequel, transput errors are mentioned using identifiers whose values appear in the following table:-

Identifiers for transput errors
`physical file end not mended` | 255
`logical file end not mended` | 254
`stand in redirected` | 253
`environment string unset` | 252
`environment string estab err` | 251
`estab invalid parameters` | 250
`open invalid parameters` | 249
`no program args` | 248
`value error not mended` | 247

## Transput modes

Only five modes are available:-

`FILE`
  A structure containing details of a a book accessed by the program.
`CHANNEL`
  A structure containing procedures for accessing books.
`SIMPLIN`
  A union of names of all plain modes, rows of plain modes, structures of plain modes and their combinations.
`SIMPLOUT`
  A union of all plain modes, rows of plain modes, structures of plain modes and their combinations.
`BUFFER`
  A synonym for `RVC`. It is used as the yield of the procedure `file buffer` (see section 13.7.7).

The mode `NUMBER` is used as a parameter of the procedures `whole`, `fixed` and `float`, but because it is the union of all number modes, it is unnecessary to specify it and so has not been made available for general use.

## Standard channels

For each channel in this section, the general properties are first given, followed by a table giving the properties of books opened on the channel and then a list of specific properties for the following procedures where applicable:-

establish
open
create
close
lock
scratch
set
logical end
reidf

1. `CHANNEL stand in channel`
   `CHANNEL stand out channel`
   `CHANNEL stand back channel`
   These three channels have similar properties because they use the same access procedures. The standard buffered input channel is `stand in channel`. Books on this channel have the following properties:-

   stand in channel
   bin possible | `TRUE`
   put possible | `FALSE`
   get possible | `TRUE`
   set possible | `TRUE`
   reidf possible | `FALSE`

   and are available as the `stand in book`.

The `stand out channel` is the standard buffered output channel. Books on this channel have the following properties:-

stand out channel
bin possible | `TRUE`
put possible | `TRUE`
get possible | `FALSE`
set possible | `TRUE`
reidf possible | `FALSE`

and are available as the `stand out book`.

The `stand back channel` is the standard buffered input/output channel. Books on this channel have the following properties:-

stand back channel
bin possible | `TRUE`
put possible | `TRUE`
get possible | `TRUE`
set possible | `TRUE`
reidf possible | `TRUE`

and are available as the `stand back book`.

The channels have the following properties:-

`establish`
  You must have write access to the file. If it already exists, it will be truncated to zero length. The default mode is `8r644`. If the file cannot be established, the routine will return the value `errno` (the system error name) refers to.
`open`
  the file will be opened with a default mode of `8r444`. If the file cannot be opened, the routine will return the value `errno` refers to.
`create`
  A zero length file with a unique identification will be created using the default mode of `8r644`.
`close`
  The file will be closed. For the `stand out channel` and the `stand back channel`, the buffer will be flushed.
`lock`
  The file will be closed and then all permissions will be removed from the file provided you have write access to the directory containing the file.
`scratch`
  The file will be closed and then unlinked.
`set`
  The current position will be set to any legal position in the book (non-negative positions only). If the position is set beyond the current logical end, a sparse file will be created.
`logical end`
  The position will be set to just beyond the last byte in the file.
`reidf`
  For the `stand back channel` only. When the file is closed, it will be renamed. If the rename fails (an already existing file with that name, for example), an error message will be output on the `stand error` file giving a description of the error and identifying the file.

- `CHANNEL arg channel`
  The `arg channel` gives access to the program arguments including the actual call of the program which precedes the program arguments. Arguments are separated by a single space. A name of mode `REF FILE` opened with this channel has `blank` as the string terminator. The arguments, as a book, have the following properties:-

  arg channel
  bin possible | `FALSE`
  put possible | `FALSE`
  get possible | `TRUE`
  set possible | `TRUE`
  reidf possible | `FALSE`

  The channel has the following properties:-
  `establish`
    Same as `open`.
  `open`
    The program arguments will be made available. If the arguments are unavailable, the routine will return `no program args`.
  `create`
    Same as `open`.
  `close`
    No action.
  `lock`
    No action.
  `scratch`
    No action.
  `set`
    Provided that the required position lies between the beginning and the end of the arguments, the position will be set accordingly.
  `logical end`
    The position will be set to just beyond the last character of the last argument.
  `reidf`
    Inapplicable.
  The procedure `make term` can be used to set the string delimiter to any required value to facilitate searching for quote-delimited or otherwise delimited arguments.
- `CHANNEL env channel`
  The `env channel` gives read-only access to environment strings (which Linux documentation calls "environment variables"). The environment string, as a book, has the following properties:-

  env channel
  bin possible | `FALSE`
  put possible | `FALSE`
  get possible | `TRUE`
  set possible | `TRUE`
  reidf possible | `FALSE`

  The channel has the following properties:-
  `establish`
    Yields an error of value
    `environment string estab err`.
  `open`
    If the environment string is the null string or is unset, `open` yields an error of value
    `environment string unset`. Otherwise, the string is available as a book.
  `create`
    Yields an error of value
    `environment string estab err`.
  `close`
    No action.
  `lock`
    The routine will attempt to remove all permissions from a file of the same identification as the environment string identification.
  `scratch`
    The routine will attempt to unlink a file of the given identification.
  `set`
    Provided that the required position lies between the beginning and the end of the string, the position will be set accordingly.
  `logical end`
    The position will be set to just beyond the last character.
  `reidf`
    Inapplicable.
  The default string terminator is `nul ch`. You should set the string terminator using `make term` .
- `CHANNEL kbd channel`
  The `kbd channel` provides access to unechoed keystrokes (also referred to as "non-canonical input"). Be warned that if a file opened with this channel is not closed and the program ends prematurely, none of your keystrokes will be echoed! You can reset to canonical input using the command

         stty sane

  The keyboard is made available as a book having the following properties:-

  kbd channel
  bin possible | `TRUE`
  put possible | `FALSE`
  get possible | `TRUE`
  set possible | `FALSE`
  reidf possible | `FALSE`

  The channel is usually used to access the characters input by control and function keys as well as normal keystrokes, so it is advisable to use `get bin` rather than `get`. The channel has the following properties:-
  `establish`
    Same as `open`.
  `open`
    You should use the null string `""` for the identification. The routine checks to see whether stand in has been redirected and yields the error `stand in redirected` if so. Otherwise, the characteristics of `stand in` are changed to wait for a single character with no minimum waiting time and with no echo of the input.
  `create`
    Same as `open`.
  `close`
    The routine resets `stand in` to the condition it was in previously.
  `lock`
    Same as `close`.
  `scratch`
    Same as `close`.
  `set`
    Inapplicable.
  `logical end`
    Inapplicable.
  `reidf`
    Inapplicable.
- `CHANNEL mem channel`
  The `mem channel` provides a memory buffer with access to all transput facilities. It is similar to the standard Algol 68 `associate` except that binary transput is also allowed. The buffer behaves as a book with the following properties:-

  mem channel
  bin possible | `TRUE`
  put possible | `TRUE`
  get possible | `TRUE`
  set possible | `TRUE`
  reidf possible | `FALSE`

  The channel has the following properties:-
  `establish`
    If the values of `p` and `l` are both `1` and the value of `c` is a positive integer then `c` is taken to be the size of the buffer. Otherwise, the routine yields `estab invalid parameters` as error value. The identification should be `""`.
  `open`
    The routine should be called with an identification of mode `RVC` (see section 2b). The identification will be used as the memory buffer.
  `create`
    The value `estab invalid parameters` will be returned.
  `close`
    No action.
  `lock`
    Inapplicable.
  `scratch`
    Inapplicable.
  `set`
    Provided the position lies in or just beyond the end of the buffer, the position will be set.
  `logical end`
    The position will be set to just beyond the end of the buffer.
  `reidf`
    Inapplicable.
  The channel can be used to access individual characters of integers and reals. `make term` can also be used.
- `CHANNEL client socket channel`
  `CHANNEL server socket channel`
  These channels provide UNIX- or Internet-type sockets in the form of standard Algol 68 files. Sockets behave as books with the following properties:-

  client/server socket channel
  bin possible | `TRUE`
  put possible | `TRUE`
  get possible | `TRUE`
  set possible | `FALSE`
  reidf possible | `FALSE`

  The channels have the following properties:-
  `establish`
    The `p` should be the family of socket (either `af unix` or `af inet`). If the latter, the `l` should be the port. The `c` should be the MTU (maximum transport unit). This governs the size of the buffer associated with the socket. No checks are performed on its value. If `p` is neither `af unix` nor `af inet`, the routine returns `estab invalid parameters` as error value. The server socket should be established before the client socket.
  `open`
    Yields an error of `open invalid parameters` for both channels.
  `create`
    Inapplicable.
  `close`
    The buffer is flushed and the socket closed.
  `lock`
    The buffer is flushed, the socket closed and then all access permissions removed (provided that write access is available to the directory containing the socket).
  `scratch`
    The buffer is flushed, the socket closed and then unlinked.
  `set`
    Inapplicable.
  `logical end`
    Inapplicable.
  `reidf`
    Inapplicable.
  An extra procedure `accept`, which mirrors the C library procedure, has the following header

         PROC accept = (REF FILE socket)REF FILE:

  and is used by the server to accept a `client socket`, thereby yielding a `REF FILE` name which can be used to communicate with the client. The example programs `client1`, `server1`, `client2` and `server2` (whose source can be found in the `examples` directory) demonstrate simple use of sockets.

## Standard files

Four standard files are provided:-

1. `REF FILE stand in`
   This file corresponds to the C `stdin`. Books connected via `stand in` differ from those connected via the channel `stand in channel`: `set possible` returns `FALSE`. Thus this file must be regarded as a simple stream of bytes. When the `kbd channel` is being used, `stand in` is unavailable.
2. `REF FILE stand out`
   This file corresponds to the C `stdout`. Books connected via `stand out` differ from those connected via the channel `stand out channel`: `set possible` returns `FALSE`. Thus this file must be regarded as a simple stream of bytes.
3. `REF FILE stand error`
   This file corresponds to the C `stderr` and behaves like the file `stand out`.
4. `REF FILE stand back`
   This file accesses a workbook which is deleted on termination of the program. All kinds of transput are allowed on this file.

## Opening files

Three procedures are available for opening files:-

1. `PROC establish=`
   `(REF FILE f,STRING idf,`
   `CHANNEL chann,INT p,l,c)INT:`
   In standard Algol 68, this procedure creates a new file with `p` pages, each page containing `l` lines, each line containing `c` characters. In the QAD standard prelude, the `mem channel` (see section 5) takes notice of `p`, `l` and `c` and both `p` and `l` must be `1`. The socket channels (see section 6) use `p` for the socket family, `l` for the port if the family is `af inet` and `c` for the size of the MTU. For other channels, the values of `p`, `l` and `c` are ignored. The procedure yields zero on success, otherwise an integer denoting an error (see section 13.7.2).
2. `PROC open=(REF FILE f,`
   `UNION(CHAR,STRING,RVC) idf,`
   `CHANNEL chann)INT`
   In standard Algol 68, the second parameter of this procedure has mode `STRING`. The above union ensures that an `RVC` parameter can be used to open an existing memory buffer with the memory channel. This is particularly useful for performing transput on buffers obtained from C library routines. The procedure yields zero on success, otherwise an integer denoting an error (see section 13.7.2).
3. `PROC create=(REF FILE f,CHANNEL chann)INT:`
   Creates a work file with a unique identification in the directory `/tmp` using the given channel.

## Closing files

Three procedures are provided:-

1. `PROC close=(REF FILE f)VOID:`
   This is the standard procedure for closing a file. It is standard practice to close every opened file. The procedure checks to see whether the file is open. If the `reidf` procedure has been called, after closing the file, the procedure renames the file to the identification given in the `reidf` field.
2. `PROC lock=(REF FILE f)VOID:`
   The Algol 68 Revised Report requires that the file be closed in such a manner that some system action is required before it can be reopened. In this case, the file is closed and then all access permissions removed. Before the file can be reopened, the user will have to use `chmod`.
3. `PROC scratch=(REF FILE f)VOID:`
   The file is closed and then unlinked.

## Transput routines

The procedures in this section are responsible for the transput of actual values. Firstly, formatless transput is covered and then binary transput. The a68toc compiler does not support formatted transput. In each section, the shorthand `L` is used for the various precisions of numbers and bits values.

### Straightening

The term straightening is used in Algol 68 to mean the process whereby a complex mode is separated into its constituent modes. For example, the mode

       MODE X=STRUCT(INT a,
                     CHAR b,
                     UNION(REAL,VOID) u)

would be straightened into values of the following modes:-

- `INT`
- `CHAR`
- `UNION(REAL,VOID)`

The mode `REF[]X` would be straightened into a number of values each having the mode `REF X`, and then each such value would be further straightened into values having the modes

- `REF INT`
- `REF CHAR`
- `REF UNION(REAL,VOID)`

However, a value of mode `COMPL` is not straightened into two values both of mode `REAL`. Instead, the real part is transput, then an `"I"` read or written followed by the imaginary part.

### Formatless transput

Formatless transput converts internal values into strings of characters or strings of characters into internal values.

1. `PROC write=([]UNION(SIMPLOUT,`
   `PROC(REF FILE)VOID) x)VOID:`
   This is equivalent to `put(stand out,x)` (synonym `print`).
2. `PROC put=(REF FILE f,`
   `[]UNION(SIMPLOUT,`
   `PROC(REF FILE)VOID) x)VOID:`
   The parameter `x` is straightened and the resulting values are output. Each plain mode is output as follows:-
   `CHAR`
     Output a character to the next logical position in the file. For `[]CHAR`, output all the characters on the current line.
   `BOOL`
     Output `flip` or `flop` for `TRUE` or `FALSE` respectively. For `[]BOOL`, output `flip` or `flop` for each `BOOL`.
   `L BITS`
     Output `flip` for each bit equal to one and `flop` for each bit equal to zero. `l bits width` characters are output in all. No newline or newpage is output. For `[]L BITS`, each `BITS` value is output as above with no intervening spaces.
   `L INT`
     Output a space character if the logical position is not at the start of a line. Then output the integer using the call

            whole(i,1+l int width)

     which will right-justify the integer in

            1+l int width

     positions with a preceding sign. For `[]L INT`, each integer is output as described above, preceded by a space if it is not at the beginning of the line. No newlines or newpages are output.
   `L REAL`
     A space is output if the logical position is not at the start of a line and then the number is output space-filled right-justified in

            l real width+l exp width+3

     positions in floating-point format and preceded by a sign. For a value of mode `[]L REAL`, each `REAL` value is output as described above.
   `L COMPL`
     The complex value is output as two real numbers in floating-point format separated by `i` . For `[]L COMPL`, each complex value is output as described above.
   `PROC(REF FILE)VOID:`
     An `lf` character is output if the routine is `newline` and an `ff` character if the routine is `newpage`. User-defined routines with this mode can be used.
3. `PROC read=([]UNION(SIMPLIN,`
   `PROC(REF FILE)VOID) x)VOID:`
   This is equivalent to `get(stand in,`...`)`.
4. `PROC get=(REF FILE f,`
   `[]UNION(SIMPLIN,`
   `PROC(REF FILE)VOID x)VOID:`
   This procedure converts strings of characters into internal values. Inputting data is covered for each plain mode and `REF STRING`. In each case, if the end of the file is detected while reading characters, the logical file end procedure is called:-
   `REF CHAR`
     Any characters `c` where `c < blank` are skipped and the next character is assigned to the name. If a `REF[]CHAR` is given, then the above action occurs for each of the required characters of the multiple.
   `REF STRING`
     All characters, including any control characters, are assigned to the name until any character in the character set specified by the `string term` field of `f` is read. The file is then backspaced so that the string terminator will be available for the next `get`.
   `REF BOOL`
     The next non-space character is read and, if it is neither `flip` nor `flop`, the char error procedure is called with `flop` as the suggestion. For `REF[]BOOL`, each `\texttt{REF BOOL}` name is assigned a value as described above.
   `REF L BITS`
     The action for `REF BOOL` is repeated for each bit in the name. For `REF[]L BITS`, each `REF L BITS` name is assigned a value as described above.
   `REF L INT`
     If the next non-control character (ie, a character which is neither a space, a tab character, a newline or newpage character or other control character) is not a decimal digit, then the char error procedure is called with `"0"` as the suggestion. Reading of decimal digits continues until a character which is not a decimal digit is encountered when the file is backspaced. If during the reading of decimal digits, the value of `l max int` would be exceeded, reading continues, but the input value is not increased. For `REF[]L INT`, each integer is read as described above.
   `REF L REAL`
     A real number consists of 3 parts:-
     - an optional sign possibly followed by spaces
     - an optional integral part
     - a `"."` followed by any number of control characters (such as newline or tab characters) and the fractional part
     - an optional exponent preceded by a character in the set `"Ee\"`. The exponent may have a sign. Absence of a sign is taken to mean a positive exponent
     The number may be preceded by any number of control characters or spaces. For `REF[]L REAL`, each `REAL` value is read as described above.
   `REF L COMPL`
     Two real numbers separated by `"i"` are read from the file. Newlines or newpages or other control characters can precede each real. The first number is regarded as the real part and the second the imaginary part. For `REF[]L COMPL`, each `REF L COMPL` is read as described above.

### Binary transput

Binary transput performs no conversion on internal values, thus providing a means of storing internal values in a compact form in books or reading such values into a program.

1. `PROC write bin=([]SIMPLOUT x)VOID:`
   This is equivalent to `put bin(stand back,x)`.
2. `PROC put bin=(REF FILE f,`
   `[]SIMPLOUT x)VOID:`
   This procedure outputs internal values in a compact form. Then external size is the same as the internal size.
3. `PROC read bin=([]SIMPLIN x)VOID:`
   This procedure is equivalent to

             get bin(stand back,x)

4. `PROC get bin=(REF FILE f,[]SIMPLIN x)VOID:`
   This procedure transfers external values in a compact form directly into internal values.

In all the above procedures, the transput is direct with no code conversion. It should also be noted that the procedure `make term`, although usually used with formatless transput, can also be used with binary transput in the QAD standard prelude for inputting a `STRING` terminated by any of a number of characters. You should note that if set possible for the channel concerned, then the terminator (which will always include the lf character) will not have been read when get bin returns. However, if not `set possible` for the channel (and neither `stand in` nor `stand out` can be set), then no backspace is possible for binary transput and so the terminating character will have been read.

### Other procedures

A number of miscellaneous procedures fall into this category.

1. `PROC file buffer = (REF FILE f)BUFFER:`
   Yields the buffer of a `REF FILE` value.
2. `PROC flush buffer = (REF FILE f) VOID:`
   This procedures empties the buffer if it has been changed by a `put` or a `put bin`.
3. `PROC no file end=(REF FILE f)BOOL:`
   One of the default procedures in `default io procs`.
4. `PROC ignore value error = (REF FILE f)BOOL:`
   One of the default procedures in `default io procs`.
5. `PROC ignore char error = (REF FILE f, REF CHAR ch)BOOL:`
   One of the default procedures in `default io procs`.

## Interrogating files

A number of procedures are available for interrogating the properties of files:-

1. Properties of the book:-
   1. `PROC bin possible=(REF FILE f)BOOL:`
      Yields `TRUE` if binary transput is possible.
   2. `PROC put possible=(REF FILE f)BOOL:`
      Yields `TRUE` if data can be sent to the book.
   3. `PROC get possible=(REF FILE f)BOOL:`
      Yields `TRUE` if data can be got from the book.
   4. `PROC set possible=(REF FILE f)BOOL:`
      Yields `TRUE` if the book can be browsed: that is, if the position in the book for further transput can be set.
   5. `PROC reidf possible=(REF FILE f)BOOL:`
      Yields `TRUE` if the identification of the book can be changed.
2. `PROC current pos=(REF FILE f)INT:`
   The standard Algol 68 procedure yields a triple giving the page, line and character number. However, the QAD standard prelude does not use pages, lines and characters, so this procedure yields the current character position within the book for the next transput operation.
3. `PROC file buffer=(REF FILE f)BUFFER:`
   Yields the memory buffer associated with the file `f`.
4. `PROC idf=(REF FILE f)RVC:`
   Yields the current identification of the book.
5. `PROC logical end=(REF FILE f)INT:`
   The current length of the book connected to `f`.

## File properties

Three procedures are provided for altering the properties of files:-

1. `PROC make term=(REF FILE f,`
   `STRING term)VOID:`
   Makes `term` the current string terminator.
2. `PROC reidf=(REF FILE f,STRING new idf)VOID:`
   Changes the `reidf` field of `f` to the given value so that when the file is closed, the book will be renamed.
3. `PROC set flush after put=(REF FILE f)VOID:`
   Ensures that the buffer of a file is flushed whenever data is written to the file.

## Event routines

Four event routines are provided. For each routine, the default behaviour will be described. In each case, if the user routine yields `FALSE`, the default action will be elaborated. If it yields `TRUE`, the action depends on the event.

1. `PROC on char error=(REF FILE f,`
   `PROC(REF FILE,`
   `REF CHAR)BOOL p)VOID:`
   This procedure assigns the procedure `p`, which may be an identifier or an anonymous procedure, to the `char error mended` field of `f`. The actions on character error are:-
   Default action
     Use the default character for the particular situation.
   User action
     A character may be assigned to the `REF CHAR` parameter and will be used if it is in the particular character set involved.

   The relevant situations are:-

   1. When reading an integer of any precision, first character, possibly following an optional sign with following spaces, is not a digit. Any decimal digit can be substituted. The default is `"0"`.
   2. When reading a real of any precision, the first non-space character, optionally preceded by a decimal point `"."`, is not a digit. Any decimal digit can be substituted. The default is `"0"`.
   3. When reading a real of any precision, an exponent is present (the character `"e"` or `"E"` or `"\"` has been read), and the first non-space character is not a digit. Any decimal digit can be substituted. The default is `"0"`.
   4. When reading a complex number, the first non-space character following the first real is not in the set `iI`. The default is `"i"`.
2. `PROC on logical file end=`
   `(REF FILE f,PROC(REF FILE)BOOL p)VOID:`
   This procedure assigns the procedure `p`, which may be an identifier or an anonymous procedure, to the `logical file mended` field of `f`. The actions on logical file end are:-
   Default action
     The default action is elaborated if the procedure `p` yields `FALSE`. If it yields `TRUE` then it is presumed that the end of the file has been attended to and transput is resumed. On any channel, if the end of the file has been reached or, in unformatted character transput, an `eof char` is read then the error message `logical file end not mended` will be issued and the program terminated with the exit value `logical file end not mended`.
   User action
     Any action as specified. Care should be taken if transput is performed on the file in question as an infinite loop could occur.
3. `PROC on physical file end=`
   `(REF FILE f,PROC(REF FILE)BOOL p)VOID:`
   This procedure assigns the procedure `p`, whether an identifier or an anonymous procedure, to the

          physical file mended

   field of `f`. The actions on physical file end are:-
   Default action
     If the procedure `p` yields `FALSE` then the default action is elaborated, If `p` yields `TRUE` then the ending of the file is presumed to be attended to and transput is then re-attempted. On any channel, if there is no more room on the physical medium, the program issues the error message

            physical file end not mended

     and then terminates the program with the exit value `physical file end not mended`.
   User action
     Any action as specified. Care should be taken if transput is performed on the file in question as an infinite loop could occur.
4. `PROC on value error=`

          (REF FILE f,PROC(REF FILE)BOOL p)VOID:

   This procedure assigns procedure `p` to the `value error mended` field of `f`. The actions taken on a value error are:-
   Default action
     The program issues the error message `value error not mended` and then terminates with the same exit value.
   User action
     Transput continues.
   The error occurs in the following situations:-
   1. When an integer on input exceeds `max int` for the precision concerned.
   2. The size of the exponent of a real number exceeds `max int`.
   3. An input real number is ± ∞ or greater than `max real` or is less than `min real` for the precision concerned.

## Conversion routines

The conversion routines consist of three procedures converting numbers to strings of characters, one operator and the procedure `char in string`. All the procedures `whole`, `fixed` and `float` will return a string of `error char` if the number to be converted is too large for the given width, or, if the number is a real, if it is infinite or otherwise invalid.

1. `PROC char in string=`
   `(CHAR c,REF INT p,STRING s)BOOL:`
   If the character `c` occurs in the string `s`, its index is assigned to `p` and the procedure yields `TRUE`, otherwise no value is assigned to `p` and the procedure yields `FALSE`.
2. `PROC whole=(NUMBER v,INT width)STRING:`
   The procedure converts integer values. Leading zeros are replaced by spaces and a sign is included if `width>0`. If `width` is zero, the shortest possible string is yielded. If a real number is supplied for the parameter `v`, then the call `fixed(v, width, 0)` is elaborated.
3. `PROC fixed=(NUMBER v,`
   `INT width,after)STRING:`
   The procedure converts real numbers to fixed point form, that is, without an exponent. The total number of characters in the converted value is given by the parameter `width` whose sign controls the presence of a sign in the converted value as for `whole`. The parameter `after` specifies the number of required digits after the decimal point. From the values of `width` and `after`, the number of digits in front of the decimal point can be calculated. If the space left in front of the decimal point is insufficient to contain the integral part of the value being converted, digits after the decimal point are sacrificed.
4. `PROC float=(NUMBER v,`
   `INT width,after,exp)STRING:`
   The procedure converts reals to floating-point form ("scientific notation"). The total number of characters in the converted value is given by the parameter `width` whose sign controls the presence of a sign in the converted value as for `whole`. Likewise, the sign of `exp` controls the presence of a preceding sign for the exponent. If `exp` is zero, then the exponent is expressed in a string of minimum length. In this case, the value of `width` must not be zero. Note that `float` always leaves a position for the sign. If there is no sign, a blank is produced instead. The values of `width`, `after` and `exp` determine how many digits are available before the decimal point and, therefore, the value of the exponent. The latter value has to fit into the width specified by `exp` and so, if it cannot fit, decimal places are sacrificed one by one until either it fits or there are no more decimal places (and no decimal point). If it still doesn't fit, digits before the decimal place are also sacrificed. If no space for digits remains, the whole string is filled with `error char`.
5. `OP HEX=(L BITS v)[]CHAR:`
   The operator `HEX` converts a value of mode `L BITS` into a row of hexadecimal digits. The total number of digits equals `l bits width OVER 4`. For example, `HEX 4r3` yields `00000003`.

## Layout routines

These routines provide formatting capability on both input and output.

1. `PROC space=(REF FILE f)VOID:`
   The procedure advances the position in file `f` by 1 byte. It does not read or write a blank.
2. `PROC backspace=(REF FILE f)VOID:`
   The procedure advances the position in file `f` by -1 bytes. It does not read or write a backspace. Note that not every channel permits backspacing more than once consecutively.
3. `PROC newline=(REF FILE f)VOID:`
   On input, skips any remaining characters on the current line and positions the file at the beginning of the next line. This means that all characters on input are skipped until a linefeed character `lf` is read. On output, emits a linefeed character. This is non-standard behaviour.
4. `PROC newpage=(REF FILE f)VOID:`
   On input, skips any remaining characters on the current page and positions the file at the beginning of the next page. This means that all characters on input are skipped until a formfeed character `ff` is read. Note that if the character following a number is a formfeed character, then that character will have been read during the read of the number. Hence, the skip to formfeed character will skip the whole of the following page. On output, a formfeed character is emitted immediately.
5. `PROC skip terminators=(REF FILE f)VOID:`
   Any `STRING` terminators are skipped on input and the file positioned at the next non-terminating character. The procedure is usually called after a `STRING` has been read.