Tcl Powered!NeoWebScript

Home
 
Download
User Info
New User FAQ
Tutorials
Demos
Commands
Variables
Troubleshooting
Sysop Info
Sysop FAQ
Theory
Installation
Management
Tests
Troubleshooting
Feedback
Resources
Release Notes
Credits
Disclaimer
LGETS - Extended TCL
Synopsis * Description * Keywords

Reads a list from a file

Synopsis

  • lgets fileId ?varName?

Description

Reads the next Tcl list from the file given by fileId and discards the terminating newline charac- ter. This command differs from the gets command, in that it reads Tcl lists rather than lines. If the list contains newlines or binary data, then that newline or bytes of zero will be returned as part of the result. Only a newline not quoted as part of the list indicates the end of the list. There is no corresponding command for outputting lists, as puts will do this correctly.

If varName is specified, then the line is placed in the variable by that name and the return value is a count of the number of characters read (not includ- ing the newline). If the end of the file is reached before reading any characters then -1 is returned and varName is set to an empty string. If varName is specified and an error occurs, what ever data was read will be returned in the variable, however the resulting string may not be a valid list.

If varName is not specified then the return value will be the line (minus the newline character) or an empty string if the end of the file is reached before reading any characters. An empty string will also be returned if a line contains no charac- ters except the newline, so eof may have to be used to determine what really happened.

The lgets command maybe used to read and write lists containing binary data, however translation must be set to lf or the data maybe corrupted.

If lgets is currently supported on non-blocking files.

Keywords

file, list, input

Copyright © 1995-1999 NeoSoft Inc., 1770 St. James Place, Suite 500, Houston, TX 77056 USA. All Rights Reserved