write, writec, pretty_write, pretty_writec

write, writec, pretty_write, pretty_writec --  write an expression to a file.

Syntax

write (file, s_exp...)
writec (file, s_exp...)
pretty_write (file, s_exp...)
pretty_writec (file, s_exp...)

		

Arguments

file

A file pointer to a previously opened file. This may be either a file in the file system, or a string opened for read and write.

s_exp

Any Gamma or Lisp expression.

Returns

t on success, otherwise nil.

Description

Writes the given expressions to the file using the same format as print. See print for more information.

writec produces the same format as princ; pretty_write produces the same format as pretty_print; and pretty_writec produces the same format as pretty_printc. Any contents written to the file before it was opened will be deleted when any of these write functions are used.

Example

    Gamma> fw = open("mywritefile.dat", "w");
    #<File:"mywritefile.dat">
    Gamma> write(fw,"This is on \n one line.");
    t
    Gamma> writec(fw,"This finishes on \n another line.");
    t
    Gamma> close(fw);
    t
    Gamma> fr = open("mywritefile.dat", "r", nil);
    #<File:"mywritefile.dat">
    Gamma> read_line(fr);
    "\"This is on \n one line.\"This finishes on "
    Gamma> read_line(fr);
    " another line."
    Gamma> 
    		

See the GTK: Preparing Plots section of the Log Functions chapter in the Cogent Tools Demo and Tutorials book for an example of this function used in context.

See Also

print

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.