[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] |
Return value of a command-line argument.
Source position: systemh.inc line 1395
function ParamStr( |
l: LongInt |
):string; |
Paramstr returns the L-th command-line argument. L must be between 0 and Paramcount, these values included. The zeroth argument is the path and file name with which the program was started.
The command-line parameters will be truncated to a length of 255, even though the operating system may support bigger command-lines. The Objpas unit (used in objfpc or delphi mode) defines versions of Paramstr which return the full-length command-line arguments, using ansistrings.
In the interest of portability, the ParamStr function tries to behave the same on all operating systems: like the original ParamStr function in Turbo Pascal. This means even on Unix, paramstr(0) returns the full path to the program executable. A notable exception is Mac OS X, where the return value depends on how the application was started. It may be that just the name of the application is returned (in case of a command-line launch)
In general, it's a bad idea to rely on the location of the binary. Often, this goes against best OS practices. Configuration data should (or can) not be stored next to the binary, but on designated locations. What locations these are, is very much operating system dependent. Therefore, ParamStr(0) should be used with care.
For an example, see Paramcount.
None.
|
Return number of command-line parameters passed to the program. |