ParamCount (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

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

Code

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
  for (int i=1;i<=ParamCount();i++)
  {
	if (LowerCase(ParamStr(i)) == "beep")
	  Beep();
	else if (LowerCase(ParamStr(i)) == "exit")
	  Application->Terminate();
  }
}

Uses

Personal tools
Assistance