FANDOM


Syntax

.WRITE stremanumber bytearray size

(.WRITE streamnumber bytearray)

Explanation

.WRITE transfer data from a BYTEARRAY into a file. The first input denotes the stream number, while the second input is the BYTEARRAY where the data to be written is stored. The third input is the number of bytes to transfer. If the third input is missing, the BYTEARRAY is written completely.

The output of .WRITE is the number of bytes transferred. If an error occurs during the write, the output is the value "EOF.

If the file is open in normal mode, all line feed characters in the BYTEARRAY are converted to carriage return/line feed pairs. If the file is open in binary mode, however, all data is transferred unchanged.

See also OPEN, .SEEK and .READ.

Example

The following example opens a file for reading and fills the first 128 bytes with the ASCII equivalents of the values 0 to 127.

TO WRITE.128.BYTES :NAME

MAKE "STREAM (OPEN :NAME "WB)
MAKE "DATA BYTEARRAY 128
FOR "I 0 127 [ASET :DATA :I :I]
(.WRITE :STREAM :DATA)
CLOSE :STREAM

END

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.