System Function Native Files
|
||||
L is an arbitrary (but simple homogeneous) array. | ||||
R is a numeric scalar or one- or two-element numeric vector. | ||||
Z is a numeric scalar of the offset in the file of the next byte after the data just appended. |
The first item in R is the file tie number; the optional second element is the conversion code used to convert the data in L before writing it to the file. The File and Workspace conversion codes are as follows:
Code | Name | Datatype | File(F) or Workspace(W) |
110 | 'bool' | Boolean | FW |
811 | 'char8' | 8-bit character | F |
1611 | 'char16' | 16-bit character | FW |
3211 | 'char32' | 32-bit character | F |
812 | 'int8' | 8-bit integer | F |
1612 | 'int16' | 16-bit integer | F |
3212 | 'int32' | 32-bit integer | F |
6412 | 'int64' | 64-bit integer | FW |
6413 | 'flt64' | 64-bit float | FW |
If the file conversion code is omitted, then the file conversion code specified implicitly or explicitly when the file was most recently created or opened is used.
For example:
tn←'C:\foo' ⎕ncreate 0 ⍝ Implicit file conversion code of 'char8' and workspace conversion code of 'char16'
'Now is the time' ⎕nappend tn
After which the file data consists of
0 1 2 3 4 5 6 7 8 9 A B C D E F |4E|6F|77|20|69|73|20|74|68|65|20|74|69|6D|65|20| Now is the time
'Now is the time' ⎕nappend tn 'char16'
After which the file data consists of
0 1 2 3 4 5 6 7 8 9 A B C D E F |4E|6F|77|20|69|73|20|74|68|65|20|74|69|6D|65|20| Now is the time |4E|00|6F|00|77|00|20|00|69|00|73|00|20|00|74|00| N o w i s t |68|00|65|00|20|00|74|00|69|00|6D|00|65|00|20|00| h e t i m e
If the workspace data (in L) is wider than the width specified by the file conversion code, then a DOMAIN ERROR is signalled. For example, if the data in L is character ('char16') and the file conversion code is one of 'char8', 'int8', or 'bool', then enough of the high-order bits of each character in L must be zero so that the actual value fits without truncation.
For example:
'⊤○⍵ ⍳⌈ ∼∆∊ ∼⍳⍦∊ ' ⎕nappend tn
DOMAIN ERROR
'⊤○⍵ ⍳⌈ ∼∆∊ ∼⍳⍦∊ ' ⎕nappend tn
∧