This monadic function reads data from a native file. Y is a 3- or 4-element integer vector whose elements are as follows:
| [1] | negative tie number, |
| [2] | conversion code (see below), |
| [3] | count. If this value is ¯1, all of the elements defined by Y[2] are read from the position specified by Y[4] to the end of the file. This may result in the last few bytes in the file being ignored if they do not form a complete element. |
| [4] | start byte, counting from 0. If this value omitted or is ¯1, data is read starting from the current position in the file (initially 0). |
8 ⎕NINFO ⊃Y can be used to report the current position of the file pointer.
Y[2] specifies conversion to an APL internal form as follows. Note that the internal formats for character arrays differ between the Unicode and Classic Editions.
If both Y[3] and Y[4] have the value ¯1, then ⎕NREAD reads data from the current position in the file to the end of the file.
⎕NREAD can be used with any file. However, calling ⎕NREAD with at least one of Y[3 4] set to ¯1 is intended for regular files only; using on pipes, FIFOs or other special types of file is not recommended.
Table 48: Unicode Edition: Conversion Codes
| Value | Number of bytes read | Result Type | Result shape |
|---|---|---|---|
| 11 | count | 1 bit Boolean | 8 × count |
| 80 | count | 8 bits character | count |
| 821 | count | 8 bits character | count |
| 83 | count | 8 bits integer | count |
| 160 | 2 × count | 16-bits character | count |
| 163 | 2 × count | 16 bits integer | count |
| 320 | 4 × count | 32-bits character | count |
| 323 | 4 × count | 32 bits integer | count |
| 645 | 8 × count | 64 bits floating | count |
Table 49: Classic Edition: Conversion Codes
| Value | Number of bytes read | Result Type | Result shape |
|---|---|---|---|
| 11 | count | 1 bit Boolean | 8 × count |
| 82 | count | 8 bits character | count |
| 83 | count | 8 bits integer | count |
| 163 | 2 × count | 16 bits integer | count |
| 323 | 4 × count | 32 bits integer | count |
| 645 | 8 × count | 64 bits floating | count |
Note that types 80, 160 and 320 and 83 and 163 are exclusive to Dyalog APL.
DATA←⎕NREAD ¯1 160 (0.5×⎕NSIZE ¯1) 0 ⍝ Unicode
DATA←⎕NREAD ¯1 82 (⎕NSIZE ¯1) 0 ⍝ Classic
DATA←⎕NREAD ¯1 82 ¯1 0 ⍝ Shorter version