HP Pascal/iX Programmer's Guide (31502-90023)

B- 14
The export section for the module
arg
is:
MODULE arg;
EXPORT
TYPE
arg_string1024 = string[1024];
arg_type = PACKED ARRAY[1..32000] OF char;
argarray = ARRAY[0..32000] OF ^argtype;
argarrayptr = ^argarray;
FUNCTION argv : argarrayptr;
FUNCTION argc : integer;
FUNCTION argn (n : integer) : arg_string1024;
IMPLEMENT
.
.
.
.
END.
Example
$STANDARD_LEVEL 'HP_MODCAL'$
PROGRAM arg_demo (input, output);
VAR
f : text;
line : string[255];
fname : string[80];
IMPORT arg;
BEGIN
IF argc > 1 THEN BEGIN {If a program argument was passed ...}
fname := argn(1); {assign it to fname ...}
reset(f,fname); {reset the file fname ...}
WHILE NOT eof(f) DO BEGIN {and list its contents.}
readln(f,line);
writeln(line);
END;
END; {IF}
END. {arg_demo}
Associating Program Header Files with Run-Time Parameters
On HP-UX, files defined in the program header are implicitly associated
with run-time parameters. For example, if the program header is:
PROGRAM myprog (input, output, file1, file2);
then when the program myprog is run with command-line arguments, file1 is
bound to the first argument, and file2 is bound to the second. The
predefined files
input
,
output
, and
stderr
are not subject to this
implicit association.
Other command-line arguments that are not subject to this implicit
association are those that begin with plus (+) and minus (-). For
example, if the compiled program produced from the above example is run
with the command:
a.out -opt1 arg1 +opt2 arg2 arg3
then file1 is bound to arg1 and file2 is bound to arg2. Therefore, if
the program executes the statement: