Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

ScriptX

Auxilia a adição de métodos e variáveis ao PascalScript

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

ScriptX

Auxilia a adição de métodos e variáveis ao PascalScript

Exemplo de uso

delphi
type
  TDummy = class
  public
    [RegisterMethod]
    procedure MostraMsg(AMsg : string);
  end;

var LScript : IScriptX;
    LScriptContext : IScriptXContext;
begin
  LScript := TScriptX.Create;
  LScript.RegisterMethods(TDummy);
  LScriptContext := TScriptXContext.Create;
  LScript.SetContext(LScriptContext);
  LScriptContext.AddVariable(TScriptXVariable.New
  .SetName('LSomeString')
  .SetVariableType(vtString)
  .SetOnGetValue(
    procedure (var AValue : TValue)
    begin
      AValue := 'NOOB TEST';
    end));
  LScript.SetScript('begin MostraMsg(LSomeString); end.').Execute;
end;