Description |
The ParamStr function returns one of the parameters from the command line used to invoke the current program.
The ParamIndex parameter determines which parameter is returned:
0 : The execution drive/path/program
1 : Return the 1st parameter
2 : Return the 2nd parameter ...
If there is no parameter value for the given index,an empty string is returned.
|
|
Notes |
The related FindCmdLineSwitch function can be used to check for the presence of parameters, as starting with a control character, such as - or /.
|
|
Related commands |
CmdLine |
|
Holds the execution text used to start the current program |
FindCmdLineSwitch |
|
Determine whether a certain parameter switch was passed |
ParamCount |
|
Gives the number of parameters passed to the current program |
|
|
|
Example code : Display command line parameters |
var
cmd : string;
i : Integer;
begin // Before running this code, use the Run/parameters menu option // to set the following command line parameters : -parm1 -parm2
// Show these parameters - note that the 0th parameter is the // execution command on Windows
for i := 0 to ParamCount do
WriteLn('Parameter '+IntToStr(i)+' = '+ParamStr(i));
end;
|
Show full unit code |
Parameter 0 = C:\PROGRAM FILES\BORLAND\DELPHI7\PROJECTS\PROJECT1.EXE
Parameter 1 = -parm1
Parameter 2 = -parm2
|
|