Routines (alphabetical) > Routines: S > SKIP_LUN

# SKIP_LUN

The SKIP_LUN procedure reads data in an open file and moves the file pointer. It is useful in situations where it is necessary to skip over a known amount of data in a file without the requirement of having the data available in an IDL variable. SKIP_LUN can skip over a fixed amount of data, specified in bytes or lines of text, or can skip over the remainder of the input file from the current position to end of file. Since SKIP_LUN actually performs an input operation to advance the file pointer, it is not as efficient as POINT_LUN for skipping over a fixed number of bytes in a disk file. For that reason, use of POINT_LUN is preferred when possible. SKIP_LUN is especially useful in situations such as:

- Skipping over a fixed number of lines of text. Since lines of text can have variable length, it can be difficult to use POINT_LUN to skip them.
- Skipping data from a file that is not a regular disk file (for example, data from an internet socket).

## Examples

Skip the next 8 lines of text from a file:

SKIP_LUN, FromUnit, 8, /LINES

Skip the remainder of the data in a file, and use the TRANSFER_COUNT keyword to determine how much data was skipped:

SKIP_LUN, FromUnit, /EOF, TRANSFER_COUNT=n

Skip the remainder of the text lines in a file, and use the TRANSFER_COUNT keyword to determine how many lines were skipped:

SKIP_LUN, FromUnit, /EOF, /LINES, TRANSFER_COUNT=n

## Syntax

SKIP_LUN, FromUnit, [, Num] [, /EOF] [, /LINES] [, /TRANSFER_COUNT=variable]

## Arguments

### FromUnit

An integer that specifies the file unit for the file in which the file pointer is to be moved. Data in FromUnit is skipped, starting at the current position of the file pointer. The file pointer is advanced as data is read and skipped. The file specified by FromUnit must be open, and must not have been opened with the RAWIO keyword to OPEN.

### Num

The amount of data to skip. This value is specified in bytes, unless the LINES keyword is specified, in which case it is taken to be the number of text lines. If Num is not specified, SKIP_LUN acts as if the EOF keyword has been set, and skips all data in FromUnit (the source file) from the current position of the file pointer to the end of the file.

If Num is specified and the source file comes to end of file before the specified amount of data is skipped, SKIP_LUN issues an end-of-file error. The EOF keyword alters this behavior.

## Keywords

### EOF

Set this keyword to ignore the value given by Num (if present) and instead skip all data from the current position of the file pointer in FromUnit and the end of the file.

Note: If EOF is set, no end-of-file error is issued even if the amount of data skipped does not match the amount specified by Num. The TRANSFER_COUNT keyword can be used with EOF to determine how much data was skipped.

### LINES

Set this keyword to indicate that the Num argument specifies the number of lines of text to be skipped. By default, the Num argument specifies the number of bytes of data to skip.

### TRANSFER_COUNT

Set this keyword equal to a named variable that will contain the amount of data skipped. If LINES is specified, this value is the number of lines of text. Otherwise, it is the number of bytes. TRANSFER_COUNT is primarily useful in conjunction with the EOF keyword. If EOF is not specified, TRANSFER_COUNT will be the same as the value specified for Num.

## Version History

5.6 | Introduced

## See Also

CLOSE, COPY_LUN, EOF, FILE_COPY, FILE_LINK, FILE_MOVE, OPENR/OPENU/OPENW, POINT_LUN, READ/READF, WRITEU