Know a good article or link that we're missing? Submit it!
*/
*/

Command line parameters

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...

Subscribe

Author

Archive

Tags

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.

0 comments on "Command line parameters"
No comments posted yet.

Leave A Comment
Subject:


Comment:
   Bold Italic Underline          Code Link Image Horizontal Rule


Because you do not have or are not logged in to your Programmer's Heaven account, please enter your name.

Name:


To help prevent comment SPAM, please enter the magic code '211' in the box:




Posting Rules
Please follow these rules when posting comments on blog posts.
  • Do not post anything that is racist, hate speech or of a sexual or adult nature.
  • Do not post or link to anything that infringes copyrighted laws.
  • Posting about security or legal topics is fine so long as you are not glorifying or encouraging people to perform illegal activities.
  • Both the author of this blog and the Programmer's Heaven administrators may delete any inappropriate comments without notice at their own discretion.

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