Logical Unit Numbers (LUNs)
PV-WAVE
Reserved Logical Unit Numbers (–2, –1, 0)
Logical Unit Numbers for General Use (1...99)
Logical Unit Numbers Used by GET_LUN/FREE_LUN (100...128)
Reserved Logical Unit Numbers (–2, –1, 0)
0, –1, and –2 are special file units that are always open within PV-WAVE:
0 (zero)—The standard input stream, which is usually the keyboard. This implies that the statement:
READ, X
is equivalent to
READF, 0, X
The user would then enter the values of X from the keyboard, as shown in the following statements:
READ, X
: 0.2, 0.4, 0.6
The line preceded with the colon (:) denotes user input.
–1 (negative 1)—The standard output stream, which is usually the workstation’s screen. This implies that the statement:
PRINT, X
is equivalent to
PRINTF, -1, X
The following command can be used to send a message to the screen:
PRINT, 'Hello World.'
The following line:
Hello World.
is sent to the workstation’s screen.
–2 (negative 2)—The standard error stream, which is usually the workstation’s screen.
Because READ and PRINT automatically use the standard input and output streams (files) by default, basic ASCII I/O is extremely simple.
Operating System Dependencies
The reserved files units have a special meaning which is operating-system dependent, as explained in the following sections:
UNIX
The reserved LUNs are equated to stdin, stdout, and stderr respectively. This means that the normal UNIX file redirection and pipe operations work with PV-WAVE. For example, the shell command:
% wave < wave.inp > wave.out &
causes PV-WAVE to execute in the background, reading its input from the file wave.inp and writing its output to the file wave.out.
Logical Unit Numbers for General Use (1...99)
These are file units for normal interactive use. When using PV-WAVE interactively, you can select any number in this range.
The following statements show how a string, “Hello World.”, could be sent to a file named hello.dat:
; Open LUN 1 for hello.dat with write access.
OPENW, 1, 'hello.dat'
; Insert the string “Hello World.” into the file hello.dat.
PRINTF, 1, 'Hello World.'
; You're done with the file, so close it.
CLOSE, 1
Logical Unit Numbers Used by GET_LUN/FREE_LUN (100...128)
These are file units that are managed by the GET_LUN and FREE_LUN
GET_LUN
Sample Usage—GET_LUN and FREE_LUN
A typical procedure that needs a file unit might be structured in the following way:
PRO demo
; Get a unique file unit and open the file.
OPENR, Unit, 'file.dat', /GET_LUN
.
. (Other commands go here.) .
; Return the file unit number. Since the file is still open,
; FREE_LUN will automatically call CLOSE.
FREE_LUN, Unit
END