Changing or disabling standard functions and classes set

<< Click to Display Table of Contents >>

Navigation:  Using Delphi classes and functions >

Changing or disabling standard functions and classes set

Sometimes it is necessary to reduce set of standard functions/classes or replace it with custom function set.

To use custom functions/classes set instead of standard, create a THtScriptGlobal class descendant.

THtScriptGlobal contains several method for functions and classes registration accordingly to Delphi units:

 

  THtScriptGlobal = class(THtScriptParser)
  protected
    // TObject.class
    fTObject: TScriptClass;
    // TObject.Free method
    fFreeMethod: TScriptFunc;
    StringHelper, IntegerHelper, SingleHelper, DoubleHelper: pointer;
    procedure RegisterInternals; virtual;
    procedure RegisterOrdinalHelpers; virtual;
    procedure RegisterMagicFunctions; virtual;
    procedure RegisterHtFunctions; virtual;
    procedure RegisterMathFunctions; virtual;
    procedure RegisterSystemFunctions; virtual;
    procedure RegisterSysUtilsFunctions; virtual;
    procedure RegisterClassesFunctions; virtual;
    procedure RegisterDateUtilsFunctions; virtual;
  public
    procedure RegisterAll; virtual;
  end;

 

By overriding RegisterAll method you can control what functions/classes will be registered.

Default RegisterAll code:

 

  fScriptGlobal := Self;
  RegisterInternals;
  RegisterOrdinalHelpers;
  RegisterMagicFunctions;
  RegisterSystemFunctions;
  RegisterSysUtilsFunctions;
  RegisterClassesFunctions;
  RegisterMathFunctions;
  RegisterDateUtilsFunctions;
  RegisterHtFunctions;

 

functions/classes registered by RegisterInternals are required, so this method should be called by any THtScriptGlobal descendants.

RegisterOrdinalHelpers is optional, like other methods, but is necessary for ordinal type helpers to work.

 

To use new THtScriptGlobal descendant class, create an object instance of this class and set ScriptParser.ScriptGlobal property to this instance.