Top
Systemwalker Operation Manager V17.0.1 Reference Guide

15.2.11 gets (Read One Line from a File)

Description

Reads a single line from a file or standard input.

Synopsis

gets channelID [varname]

Options

channelID

Specify the channel ID acquired as the return value of the open command. Specifying stdin enables reading from the standard input.

varname

Specify the name of a variable to store the content of line read. If this option is omitted, then the content of line read is returned as the return value.

Return Values

When varname is specified:

Returns the number of characters of the string it read. If it reaches the end of file without reading any character, it returns -1.

When varname is not specified:

Returns the string it read.

Caution

One line it reads indicates the location between the current reading position in the file (the beginning of file upon opening the file and, every time it reads, the current position moves correspondingly) and the end-of-line character or the end of file. The end-of-line code will not be stored in the variable given by varname.

Example

The following example reads the data of a line up to the end-of-line character from the standard input and stores it in variable buf.

gets stdin buf