## Õ File write

Õ writes data to a file. The left argument is the data. The right argument identifies where it's to go. If the file specified as the destination already exists, the data is put in it. If it doesn't exist, Õ causes it to be created first. A component may only be written within the range of existing components (either by replacement or insertion), or be appended to the end of the file.

The full form of Õ is as follows ({} means optional)

                 R „ A Õ {[LIBRARY]} FILE,COMPONENT {,USER,PASSWORD}

A is any APL variable.

R (the result) is an empty vector with display potential off.

LIBRARY number identifies the library volume number to which the file is to be written. If you omit the library number, library 0 is assumed. If included, the library number is put in square brackets. (See also ŒMOUNT for a discussion on alteration of library numbers.)

FILE number identifies the file the data is to be written to (an integer).

COMPONENT number is the identifying number which shows the way in which the variable is to be put into the file:

C=0 Append a new component to the end of the file

C=integer Replace an existing component, unless the number is 1 past the end of the file when it is appended

C=fraction Insert the component between the two integers on either side of C. Again append if C is less than 1 after the end of file

If C is omitted, it defaults to 0.

USER number and PASSWORD are used for file security in shared file applications; the defaults are 1†ŒAI and 0 respectively if omitted.

                 1 3 7 Õ 6 2             (The vector 1 3 7 becomes component 2 of
                                          file 6 on library 0. If component 2
                                          already exists it's overwritten.)

                 VARÕ[2]506 3 1075       (VAR is written to component 3 of file
                                          506 belonging to user 1075 on library 2)

                 (0 ŒOV ŒNL 3)Õ12 5      (All the functions in the workspace are
                                          filed as an overlay, into file 12
                                          component 5 - see also ŒNL, ŒOV)

A variant of Õ is used for updating the file access matrix. Here the negative of the file number is used and the left argument is the new access matrix.

Note:

Writing an access matrix to a non-existent file is a way to create an empty file.

                 A Õ {[LIBRARY]} -FILE {,COMPONENT,USER,PASSWORD}

                 (1 2½1000 ¯1)Õ[3]¯9     (File 9 on library 3 is set to FULL access
                                          for the owner)

Topic: APLX Help : Help on APL language : APL Primitives : Õ File write

[ Previous | Next | Contents | Index ]