InputOutput Command Summary

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 9.  Working with Files and Programs


Input/Output Command Summary

The following sections describe how to open, read, and write files. The basic model is that you open a file, read or write it, then close the file. Network sockets also use the commands described here. Socket programming is discussed in Chapter 17, and more advanced event-driven I/O is described in Chapter 16. Table 9-5 lists the basic commands associated with file I/O:

Table 9-5. Tcl commands used for file access.
open what ?access? ?permissions?Returns channel ID for a file or pipeline.
puts ?-nonewline? ?channel? stringWrites a string.
gets channel ?varname?Reads a line.
read channel ?numBytes?Reads numBytes bytes, or all data.
read -nonewline channelReads all bytes and discard the last \n.
tell channelReturns the seek offset.
seek channel offset ?origin?Sets the seek offset. origin is one of start, current, or end.
eof channelQueries end-of-file status.
flush channelWrites buffers of a channel.
close channelCloses an I/O channel.


       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net