Unit 'msesysenv' Package
[Overview][Constants][Types][Classes][Procedures and functions][Index] [#msegui]

tsysenvmanager

[Properties (by Name)] [Methods (by Name)]

Parses and validates the command line arguments

Declaration

Source position: msesysenv.pas line 153

type tsysenvmanager = class(tmsecomponent,istatfile)

public

  constructor create(); override;

  function init();

  procedure processinfo();

  procedure errormessage();

  procedure printmessage();

  procedure printhelp;

  function getcommandlinemacros();

  property errorcount: int32; [r]

  property defined []: Boolean; default; [rw]

  property objectlinker: tobjectlinker; [r]

  property values []: msestringarty; [rw]

  property value []: msestring; [rw]

  property integervalue []: Integer; [rw]

  function getintegervalue();

  function findfirstfile();

  function findlastfile();

  property defs: sysenvdefarty; [rw]

  property defcount: int32; [r]

published

  property options: sysenvoptionsty; [rw]

  property errorcode: Integer; [rw]

  property statfile: tstatfile; [rw]

  property statvarname: msestring; [rw]

  property statpriority: Integer; [rw]

  property helpheader: msestring; [rw]

  property helpfooter: msestring; [rw]

  property onvalueread: sysenvmanagervalueeventty; [rw]

  property oninit: sysenvmanagereventty; [rw]

  property onafterinit: sysenvmanagereventty; [rw]

end;

Inheritance

tsysenvmanager

  

Parses and validates the command line arguments

|

tmsecomponent,istatfile

  

Extends the FPC tcomponent with object linking facilities and the like; base of every MSEgui component

|

tcomponent,ievent,iificommand,iificlient

|

tpersistent

|

TObject

Description

Parses and validates the command line arguments (or an explicit array of values) according to a declarative array of argumentdefty records, and prints a usage message if a mandatory argument is missing.

The following example declares a mandatory named argument (-o) and an optional positional argument, then reads back their values with the value property.

uses
  sysutils,
  msesys,
  msesysutils,
  msetypes,
  msesysenv,
  msestrings;

type
  argty = (arg_dest, arg_names);

const
  arguments: array[argty] of argumentdefty = (
    (kind: ak_pararg; name: 'o'; anames: nil; flags: [arf_mandatory]; initvalue: ''),
    (kind: ak_arg;    name: '';  anames: nil; flags: [];              initvalue: '')
  );

var
  sysenv: tsysenvmanager;
  s1, s2: msestring;

begin
  sysenv := tsysenvmanager.create(nil);
  try
    if sysenv.init(arguments) then
    begin
      s1 := sysenv.value[ord(arg_dest)];
      s2 := sysenv.value[ord(arg_names)];
      writestdout('s1 = "' + string(s1) + '"' + lineending);
      writestdout('s2 = "' + string(s2) + '"' + lineending);
    end;
  finally
    sysenv.destroy();
  end;
end.

Documentation generated on: 2026-10-03