TutorialFiles




Prev | Up | Next | Back | Forward | Online Documentation Home Page

Files

External files are edited in buffers. Open reads a file into a buffer of the same name; save writes a buffer to its associated file; save-as associates a buffer with a new file name, renames the buffer accordingly, and writes the buffer to that file; close deletes a buffer and a window.

The write-permission of a buffer created by opening a file is derived from the write-protection of the file in the file system: the buffer is read-only if the file is write-protected and is read-write otherwise. Attempts to save a buffer that would overwrite an existing write-protected file in the file system are illegal.

Three file formats are supported: text, structure, and attributed. A text file contains the textual display representation of an object; it is a normal ASCII text file such as may have been written by other editors. Structure and attributed files, in contrast, are encoded internal representations labelled by descriptive headers. When a file is opened, the file format is recorded and subsequent save commands update the file in the same file format.

An argument of the open command specifies the expected syntactic category of the file being read. A text file can always be read into a TEXT buffer, and can only be read into a buffer of syntactic category p (for p not TEXT) if it is parsable as that syntactic category. Parsing may fail either because the text file contains a true syntax error, or because the editor has not been provided with a complete parsing syntax for the given syntactic category. An object written in either structure or attributed format can always be read back into a buffer of its original syntactic category.

Scripting variable sg:textual-mode can be used to control the default syntactic category for open, as described in Chapter sec-SCM-io.

The textual representation of an object saved in text format depends on several different parameters:

View. The prettyprinting of objects differs from view to view. A command to save the object saves the object in the view associated with the buffer. This view is initialized by the parameter Default File View. The command save-as can be used to save the buffer in a different view.

Width. The textual prettyprinting of an object depends on a width parameter. Regardless of the width of a window containing the object, the width of the text saved is determined by the editor parameter Absolute Right Margin.

Alternate prettyprinting schemes. Each phrase within an object may be prettyprinted according to either its principal scheme or its alternate scheme. Typically, the alternate scheme is used for elision; i.e., the phrase is displayed as ... and the detailed text of the phrase is hidden. If editor parameter Respect Elision is off, the settings of prettyprinting schemes in the object are ignored (as if the object were saved after invoking the command elision-off). If editor parameter Respect Elision is on, the settings of prettyprinting schemes in the object are respected and determine the text saved. In this case, it should be noted that the detailed text of elided phrases will be lost; i.e., the text saved will be ``...''. The default is off.

Structure files and attributed files are logically equivalent. Attributed files record both the abstract syntactic structure and the derived attributes of the object. Structure files record only abstract syntactic structure and all derived attributes are recomputed when the file is read into Ada-ASSURED. Attributed files are much longer and should not be used unless empirical evidence indicates that there is a time savings in using them. The elision modes of phrases are recorded in structure files and attributed files and are restored on input.

Commands for files are:

See also Autosave and Backup.


Forward