Reference Guide > P Routines > POINT_LUN Procedure
  

POINT_LUN Procedure
Allows the current position of the specified file to be set to any arbitrary point in the file.
Usage
POINT_LUN, unit, position
Input Parameters
unit — The file unit (logical unit number) for which the file position will be set. This keyword can be set to either unit or –unit. If –unit is specified, the current position of the file pointer is returned in the output parameter position.
position — A positive integer specifying the position of the file pointer as a byte offset from the start of the file.
Output Parameters
position — If –unit is specified, the current position of the file pointer (in bytes) is returned in the position parameter. See the Example section.
Keywords
None.
Discussion
POINT_LUN is for the PV-WAVE programmer who wants explicit control over positioning for reading or writing within a given file. It is seldom used for general file I/O operations.
OPENR, 1, 'File.dat', /Block 
POINT_LUN, 1, 25B 
 
Example
In this example, POINT_LUN is used to move about within an unformatted file of integers.
; Create integer vector of length 100 initialized to values
; of its one-dimensional subscripts. 
a = INDGEN(100)
; Open a file called ptlun.dat for writing.
OPENW, unit, 'ptlun.dat', /Get_Lun
; Write 100-element integer vector as unformatted binary data
; to the file ptlun.dat.
WRITEU, unit, a
POINT_LUN, -unit, pos
; Retrieve and display the current position within ptlun.dat.
PRINT, 'Current offset into ptlun.dat is', pos, ' bytes.'
; PV-WAVE prints: Current offset into ptlun.dat is 200 bytes.
; Rewind the file to the beginning.
POINT_LUN, unit, 0
; Read two integers from beginning of the file into a two-element
; integer array, b.
b = INTARR(2)
READU, unit, b
PRINT, b
; PV-WAVE prints: 0       1
; Since two integers were just read, each of length 2 bytes, the
; current position within the file should be 4 bytes offset from
; beginning. Retrieve current position.
POINT_LUN, -unit, pos
PRINT, 'Current offset into ptlun.dat is ', $
   STRTRIM(pos, 2), ' bytes.'
; PV-WAVE prints: Current offset into ptlun.dat is 4 bytes.
; Close the file and free the file unit number.
FREE_LUN, unit
See Also
FREE_LUN, FSTAT, GET_LUN, OPEN (UNIX), OPEN (Windows), READ, WRITEU, LFPOINT_LUN
For more information, see the section Positioning File Pointers in Chapter 8 of the PV‑WAVE Programmer’s Guide.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.