Name

ParamStr Function

Syntax

function ParamStr(Number: Integer): string;

Description

The ParamStr function returns the Numberth command-line parameter. ParamStr is a real function.

Tips and Tricks

  • Parameter number zero is the application pathname.

  • Parameters are numbered from 1 to ParamCount. If Number is invalid, ParamStr returns an empty string.

  • When breaking a command line into parameters, Delphi uses white space characters as separators. Use double quotes around text that contains space characters to include the spaces as part of the parameter (e.g., long filenames).

  • To look for command-line switches, call the FindCmdLineSwitch function from the SysUtils unit.

Example

program Echo;
// Echo command-line arguments, separated by spaces.
{$AppType Console}
var
  I: Integer;
begin
  if ParamCount > 0 then
    Write(ParamStr(1));
  for I := 2 to ParamCount do
    Write(' ', ParamStr(I));
  WriteLn;
end.

See Also

CmdLine Variable, ParamCount Function
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset