|REBOL 3 Docs||Guide||Concepts||Functions||Datatypes||Errors|
|TOC < Back Next >||Updated: 3-Aug-2010 Edit History|
Writes to a file, URL, or other port - auto-converts text strings.
destination [port! file! url! block!]
data [binary! string! block!] - Data to write (non-binary converts to UTF-8)
/part - Partial write a given number of units
/seek - Write at a specific position
/append - Write data at end of file
/allow - Specifies protection attributes
/lines - Write each value in a block as a separate line
WRITE is typically used to write a file to disk, but many other operations, such as writing data to URLs and ports, are possible.
Normally a string or binary value is provided to this function, but other types of data such as a number or a time can be written. They will be converted to text.
The /BINARY refinement will write out data as its exact representation. This is good for writing image, sound and other binary data.
The /STRING refinement translates line terminators to the operating system's line terminator. This behavior is default.
The /APPEND refinement is useful logging purposes, as it won't overwrite existing data.
The /LINES refinement can take a block of values and will write each value to a line. By default, WRITE will write the block of values as a concatonated string of formed values.
The /PART refinement will read the specified number of elements from the data being written. The /WITH refinement converts characters, or strings, specified into line terminators.
See the User's Guide for more detailed explanation of using READ and its refinements.
write %junkme.txt "This is a junk file." write
write %datetime.txt now write
write/binary %data compress "this is compressed data" write %rebol-test-file.r "some text" print read %rebol-test-file.r read
write/append %rebol-test-file.r "some more text" print read %rebol-test-file.r write %rebol-test-file.r reduce ["the time is:" form now/time] print read %rebol-test-file.r read
write/lines %rebol-test-file.r reduce ["time is:" form now/time] print read %rebol-test-file.r write/part %rebol-test-file.r "this is the day!" 7 print read %rebol-test-file.r
|TOC < Back Next >||REBOL.com - WIP Wiki||Feedback Admin|