1. Home
  2. SKIP directive

SKIP directive

Skips lines in input or output files.

Options

CHANNEL = scalar Channel number of file; default current channel of the specified type
FILETYPE = string token Type of the file concerned (input, output); default inpu
STYLE = string token Style to use when skipping output (plaintext, formatted); default * uses the current style of the channel

Parameter

    identifiers How many lines to skip; for input files, a text means skip until the contents of the text have been found, further input is then taken from the following line

Description

SKIP can be used with either input or output files. The FILETYPE and CHANNEL options indicate which file is to be skipped. By default this is the current input channel.

For input files you can skip over unwanted lines, which might be comments describing the data that is to follow, or might be some statements that you do not want to use in your current job. You can skip a specified number of lines, n say, by setting the parameter to a scalar containing the value n. Alternatively, you can skip everything up to and including a particular string of characters by setting the parameter to a text containing that string. For example,

SKIP [CHANNEL=2] 'Section 2'

will skip the contents of the input file on channel 2 from the current position until the string Section 2 is found. The next line to be read from channel 2 will then be the one immediately after the line containing Section 2.

For output files you can use SKIP to print blank lines to separate one section of output from another. You might want to do this if you had set the PRINT option SQUASH=yes to suppress the automatic blank lines within a section of output. For example,

PRINT [CHANNEL=2; IPRINT=*; SQUASH=yes] Heading

SKIP [CHANNEL=2; FILETYPE=output] 2

PRINT [CHANNEL=2; IPRINT=*; SQUASH=yes] Table

places two blank lines between Heading and Table when printing their values to channel 2.

For an output file that has been opened in a style other than plain text (see OPEN), you can use the STYLE option to control whether the skipping is done in formatted or plain-text styles. If STYLE is not set, the default is to use the current style (as controlled by the OUTPUT directive).

Options: CHANNEL, FILETYPE, STYLE.

Parameter: unnamed.

See also

Directives: PAGE, READ, PRINT, CAPTION.

Commands for: Input and output.

Example

" Example READ-1: Reading parallel free-format data"

" Open a data file on the second channel for input."
OPEN '%gendir%/examples/READ-1.DAT'; CHANNEL=2; FILETYPE=input

" Ignore the first three lines, and then read values of six variates,
  recorded in parallel (the default) in free format  -  allowing one error,
  (known to be harmless), which READ reports in a warning."
SKIP [CHANNEL=2] 3
READ [CHANNEL=2; PRINT=data,error; ERROR=1] QQ[1...6]
PRINT QQ[]

" If you continue reading from the same file attached to a channel,
  you can read further data recorded after the first end-of-data marker."
READ [CHANNEL=2; PRINT=data,error] ZZ
PRINT ZZ

" It is good practice to close files after you have finished with them."
CLOSE 2

" The data can be recorded in the file with the commands:
  in this case, it must follow the READ command, or the end
  of a FOR loop if READ is in a loop, or the invocation of
  a procedure is the READ command is in a procedure."

TEXT Text
READ [PRINT=data,errors] Numbers,Text
23 Apples
22 Pears
31 Oranges
10 Bananas
4 Peaches :
PRINT Numbers,Text
Updated on June 18, 2019

Was this article helpful?