User Tools

Site Tools


write

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

write [2006/08/29 16:08] (current)
Line 1: Line 1:
 +# $EPIC: write.txt,v 1.2 2006/08/20 18:32:13 sthalik Exp $
 +======Synopsis:​======
 +$__write__(<​fd>​ <​text>​) \\
 +$__writeb__(<​fd>​ <​text>​)
 +
 +======Technical:​======
 +This function writes the given text to the given file descriptor. ​ A
 +newline is automatically appended to the text.  The $__writeb__() variant
 +does the same thing, except the newline is not automatically appended.
 +
 +As a special case, a window refnum can be given as the file descriptor
 +by prefixing the refnum with a w. This provides access to the logfile
 +for that window. The reserved window refnum 0 can be used to address
 +the current window'​s logfile, and the reserved window refnum -1 actually
 +addresses the global logfile.
 +
 +======Practical:​======
 +This function is useful for saving information to an external file.  It
 +is most often used in scripts for saving configuration settings and the
 +like.  The $__writeb__() function is useful for writing to binary files, or
 +for writing lines to a file incrementally.
 +
 +======Returns:​======
 +<​file>​
 +  -1   if file descriptor does not exist
 +> -1   ​number of bytes written (text length plus newline, if applicable)
 +</​file>​
 +
 +======Examples:​======
 +<​file>​
 +$write(7 blah blah)             ​writes "blah blah" plus NL to fd "​7"​
 +$write(foo bar)                 "​foo"​ not an fd, writes nothing
 +$writeb(7 blah blah)            writes "blah blah" to fd "​7"​
 +$writeb(foo bar)                "​foo"​ not an fd, writes nothing
 +$write(w1 this is a test)       write to window refnum 1's logfile
 +$write(w0 this is a test)       write to the current window'​s logfile
 +$write(w-1 this is a test)      write to the global logfile
 +</​file>​
  
write.txt ยท Last modified: 2006/08/29 16:08 (external edit)