The paramstr function

Description

The paramstr function returns one of the arguments passed to the program. The parameter passed to this function is the number of the argument to return. The type of the value returned by this function is always string.

Parameter

The paramstr function's only parameter is the expression of integral type whose value is the number of the program argument to return (i.e. if the parameter is N then this function will return the Nth program argument). If there is no Nth program argument then an empty string is returned. If the value of the parameter is zero then the name of the program is returned. If the value of the parameter is minus 1 (i.e. -1) then the name of the interpreter is returned, unless the program is an .EXE executable in which case an empty string is returned.

Example

For example, the following is a simple program args2.pas, that uses the paramstr, and paramcount functions to display all of the arguments passed to it.

   program args2(output);
   var
      i : integer;
   begin
      for i := -1 to paramcount do
         writeln('Program argument #', i:1, ' is ', '"', paramstr(i), '"')
   end.

If you run this program as as follow:

    ivm args2 this is a test

then the program will display

    Program argument #-1 is "ivm"
    Program argument #0 is "args2"
    Program argument #1 is "this"
    Program argument #2 is "is"
    Program argument #3 is "a"
    Program argument #4 is "test"

Portability

Operating Systems: All
Standard Pascal: No