Reading a file

Reading a file can be done in one of five different ways:

The F8 command
The F8 command, when executed with the cursor in the text field, gives a prompt in the command line requesting a file to be read in. One may type the name of the file that is desired to be read (including path name) and follow it by a carriage return. This results in the file being read into the editor at the current position of the cursor. Whenever the command is used, the file name specified is saved so that upon the next use of the read (F8) or write (shift-F8) command, the name will be displayed automatically after the prompt. You can use the entire name again, or part of it, by means of the normal editing procedures for the command line (see command line editing p. [*]). Entering a null string or just blanks will cause no action.

Reading a file at startup
At startup time the editor may read one or more files. If the editor has been started without a command tail, the editor will simply wait for your action, showing an empty buffer.

Startup with a command tail
If the editor is started up from a shell program like in MS-DOS or in any UNIX system, it is possible to provide it with a command tail. This tail is scanned for options (p. [*]) and for the names of files that should be read. Up to eight files can be read this way. Any wildcard characters that are given to the editor are passed to the file system and if more than one file matches the pattern the various files are read in different buffers. The number of buffers is of course still limited to 8.

Several options are available when reading files this way. They should precede the name of the file as a separate parameter. They are:

-r
Read the file in the `raw' mode. This is used for binary files in which carriage returns and linefeeds are left uninterpreted.
-v
Put the buffer in which the file is read in the `view only' mode to avoid accidental writing.
-#
After reading the file is positioned at the line indicated by the number #.
-i
The following name is interpreted as the name of a macro. This macro will be executed after startup. Any parameters after the name of the macro are passed on as arguments to the macro. After the execution of the macro is finished buffer 1 is saved and the execution of stedi is halted. This is the stream editing mode, in a way comparable to sed in UNIX systems.
-x
Same as option -i.
+#
The number given indicates the number of bytes that should be skipped in the file before reading starts. This allows the user to edit a part of a very big file that won't fit in memory in its entirety.

With the R command
This command knows three varieties: In its simplest form the R is followed by either a blank space or a quote. The name that follows is then interpreted as the name of the file to be read. This command is fully equivalent to the F8 command.

The other form concerns the reading of a part of a file. The command `R name < number' reads from the file `name' starting at byte `number'+1 Again there may also be a quote between the R and `name'. This mode is very useful when processing very large files. Normally only the first part of such a file can be read and the message "Not enough memory. Buffer made View-Only." would appear, notifying the user of the inaccessibility of the tail part of the file. By reading from different positions in the file one can edit the file in several steps.

When a file is read into a buffer that doesn't have a name yet, the buffer will inherit the name of this file. Its path name will also be remembered for later writing. If the save command is issued (see below) the editor will try to overwrite the old file (usually after making a backup). More details follow in the next section.

When a file is read, all occurrences of a carriage return or a linefeed will be seen as the end of a line. If a carriage return is encountered, the editor checks whether a linefeed follows after it. If this is the case, the linefeed is skipped. If a linefeed is encountered, the editor checks whether a carriage return comes after it. If this is the case, the carriage return is skipped. The result is that <cr>, <lf>, <cr><lf> and <lf><cr> are all interpreted as a single end of line. This avoids problems with the various conventions that exist. In addition there is the raw mode in which neither <cr> nor <lf> are interpreted. They are put in the text like all the other characters. For more information about this mode, one should read the information about it in the next section.

Lines in stedi should never contain more than 255 characters. Thus in order not to lose any part of a file being read in, any line that contains more than 255 characters is split up into one or more lines during the reading in process. The user will be notified that this may be about to happen and will be asked for his permission. If this permission is denied the reading will be stopped at the offending position.

If there is not enough memory to read in a complete file that has been specified, stedi will read as much as will fit in the memory and then issue an error message. The only limitation on the size of a file being read in is the amount of memory available. Hence in marginal cases a file may still be edited if you are able to gain more memory by removing some utilities or making a ram disk a little smaller. If you are faced with such a big file that it cannot be edited in one piece, one may start with editing the part that could be read, write it to a file with a different name (!), clear the buffers and then read in a part of the file after skipping a number of bytes. When writing parts of a file they can be pasted together as can be seen in the > option of the write command.