Stuck? Need help? Ask questions on our forums.
*/
*/

Software Tools in Turbo Pascal

Theme Graphic
Theme Graphic

Software Tools in Turbo Pascal

I intend to go through SOFTWARE TOOLS IN PASCAL by Kernighan & Plauger and to re-write the programs they presented using Turbo Pascal, taking advantage of Turbo Pascal's improvements over the...
Posted on Sunday, January 13, 2008 at 1:39 PM

Command line parameters

The Turbo Pascal functions ParamStr and ParamCount give us access to command line arguments. ParamCount returns the number of command line arguments while ParamStr(i : Word) returns the individual parameter strings. Ekho illustrates the use of these two functions. We use the spelling Ekho instead of Echo to avoid colliding with the DOS command ECHO.
Program Ekho ;
{
   echo command line arguments to output.
}
Uses
   Tools ;
Var
   i  :  Byte ;
begin
   for i := 0 to ParamCount do
      Write (ParamStr(i), BLANK) ;
   WriteLn
end.
Note that even if no parameters are included on the command line we still get output. ParamStr(0) is the executable file itself. Thus:
c:\pascal\tools\ekho
C:\PASCAL\TOOLS\EKHO.EXE
The next few programs we write will use command line parameters.


corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings