Delphi Basics
TSysCharSet
Type
Characters used by supplied string parsing functions SysUtils unit
  type TSysCharSet : char;
Description
The TSysCharSet type is used as a general type for setting special characters during Delphi string parsing functions.
 
For example, the FindCmdLineSwitch can be configured to search for user defined command line 'switch' value prefix characters.
Related commands
FindCmdLineSwitch Determine whether a certain parameter switch was passed
 
Example code : Override the default Windows Command Line Switch parsing characters
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  SysUtils,   // Unit containing the TSysCharSet command
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  switchPrefixes : TSysCharSet;

begin
  // Before running this code, use the Run/parameters menu option
  // to set the following command line parameters : *def /abc
  ShowMessage(CmdLine);     // Show the execution command + parameters

  // How many parameters were passed?
  ShowMessage('There are '+IntToStr(ParamCount)+' parameters');

  // Scan for abc and def parameters using the default / and - values
  if FindCmdLineSwitch('abc')
  then ShowMessage('/abc found')
  else ShowMessage('/abc NOT found');

  if FindCmdLineSwitch('def')
  then ShowMessage('/def found')
  else ShowMessage('/def NOT found');

  // Rescan with * and / as the switch prefix characters
  switchPrefixes := ['*','/'];
  if FindCmdLineSwitch('abc', switchPrefixes, True)
  then ShowMessage('*abc or /abc found')
  else ShowMessage('*abc and /abc NOT found');

  if FindCmdLineSwitch('def', switchPrefixes, True)
  then ShowMessage('*def or /def found')
  else ShowMessage('*def and /def NOT found');
end;
 
end.
Hide full unit code
   "C:\Program files\Borland\Delphi7\Projects\Project1.exe" *def /abc
   /abc found
   /def NOT found
   *abc or /abc found
   *def or /def found
 
 
© CodeGear 2006 - 2007. All rights reserved.  |  Home Page