unit ParamCount;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: ParamCount
// Routine: System.ParamCount
// Routine: System.ParamStr
// Routine: SysUtils.LowerCase
// Routine: SysUtils.Beep
// Method: Forms.TApplication.Terminate

// BeginCode
{
The following example beeps once for each "beep" passed in
on the command line.  The example terminates the application
if  "exit" is passed in on the command line.  Build the
project to generate a .exe file and then execute that file
from a command line: "ParamCount_proj beep beep exit".
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
//  Use print statements since you can't use the debugger.
//  MessageDlg(
//    'System ParamCount = ' + IntToStr(System.ParamCount),
//    mtConfirmation, [mbOK], 0);
  for i := 1 to System.ParamCount do
  begin
    if LowerCase(ParamStr(i)) = 'beep' then
      Beep
    else if LowerCase(ParamStr(i)) = 'exit' then
      Application.Terminate;
    Sleep(250);
  end;
end;
// EndCode
// EndExample: ParamCount
end.
