### TPaxScripter Methods

- AddCode
- AddCodeFromFile
- AddModule
- Compile
- Create
- Destroy
- GetHandle
- RegisterArrayType
- RegisterLanguage
- RegisterNamespace
- RegisterRecordType
- RegisterRoutine
- RegisterParameter
- RegisterPointerType
- RegisterProceduralType
- RegisterSetType
- RegisterSubrangeType
- RegisterVariable
- Reset

### TPaxScripter.AddCode

> Adds source code to module.

>     procedure AddCode(const ModuleName, Text: String);

> #### Example

>     AddCode('MyModule', 'begin');
>     AddCode('MyModule', 'writeln(123);');
>     AddCode('MyModule', 'end.');

### TPaxScripter.AddCodeFromFile

> Adds source code from text file to module.

>     procedure AddCodeFromFile(const ModuleName, FileName: String);

> #### Example

>     AddCodeFromFile('MyModule', 'MyFile.pas');

### TPaxScripter.AddModule

> Adds source code module to compiler.

>     procedure AddModule(const Name, LanguageName: String);

> #### Example

>     AddModule('MyModule', 'Pascal');

### TPaxScripter.Compile

> Compiles program.

>     function Compile(PaxProgram: TPaxProgram): boolean;

> #### Arguments

> > PaxProgram

> > > TPaxProgram instance that saves result of compilation.

> #### Example

>     procedure TForm1.Button1Click(Sender: TObject);
>     var
>       I: Integer;
>       PaxCompiler1: TPaxCompiler;
>       PaxPascalLanguage1: TPaxPascalLanguage;
>       PaxProgram1: TPaxProgram;
>     begin
>       PaxCompiler1 := TPaxCompiler.Create(nil);
>       PaxPascalLanguage1 := TPaxPascalLanguage.Create(nil);
>       PaxProgram1 := TPaxProgram.Create(nil);

>       try
>         PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);

>         // register routine 'ShowMessage'
>         H_ShowMessage := PaxCompiler1.RegisterRoutine(0, 'ShowMessage', _typeVOID, _ccREGISTER);
>         PaxCompiler1.RegisterParameter(H_ShowMessage, _typeSTRING, _Unassigned);

>         // register variable 'S'
>         H_S := PaxCompiler1.RegisterVariable(0, 'S', _typeSTRING);

>         PaxCompiler1.AddModule('1', PaxPascalLanguage1.LanguageName);
>         PaxCompiler1.AddCode('1', 'begin');
>         PaxCompiler1.AddCode('1', '  ShowMessage(S);');
>         PaxCompiler1.AddCode('1', 'end.');

>         if PaxCompiler1.Compile(PaxProgram1) then
>         begin
>           PaxProgram1.SaveToFile('1.bin');
>           ShowMessage('Compiled script has been created!');
>         end
>         else
>           for I:=0 to PaxCompiler1.ErrorCount - 1 do
>             ShowMessage(PaxCompiler1.ErrorMessage[I]);
>       finally
>         PaxCompiler1.Free;
>         PaxPascalLanguage1.Free;
>         PaxProgram1.Free;
>       end;
>     end;

### TPaxScripter.Create

> Constructor of TPaxCompiler class.

>     constructor Create(AOwner: TComponent); override;

### TPaxScripter.Destroy

> Destructor of TPaxCompiler class.

>     destructor Destroy; override;

### TPaxScripter.GetHandle

> Returns id of a script-defined variable, procedure or function.

>     function GetHandle(LevelId: Integer; const Name: String; Upcase: Boolean): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace.

> > Name

> > > Name of the script-defined variable, procedure or function.

> > Upcase

> > > If 'false', the search of id will be case sensitive.

> #### Example

>     procedure TForm1.Button1Click(Sender: TObject);
>     var
>       H_ShowMessage, H_IntToStr, H_X: Integer;
>       P: Pointer;
>       I: Integer;
>     begin
>       PaxCompiler1.Reset;
>       PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);

>       H_ShowMessage := PaxCompiler1.RegisterRoutine(0, 'ShowMessage', _typeVOID, _ccREGISTER);
>       PaxCompiler1.RegisterParameter(H_ShowMessage, _typeSTRING, _Unassigned);

>       H_IntToStr := PaxCompiler1.RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
>       PaxCompiler1.RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);

>       PaxCompiler1.AddModule('1', PaxPascalLanguage1.LanguageName);
>       PaxCompiler1.AddCode('1', 'var x: Integer = 5;');
>       PaxCompiler1.AddCode('1', 'begin');
>       PaxCompiler1.AddCode('1', '  ShowMessage(''script:'' + IntToStr(x));');
>       PaxCompiler1.AddCode('1', 'end.');

>       if PaxCompiler1.Compile(PaxProgram1) then
>       begin
>         H_X := PaxCompiler1.GetHandle(0, 'x', true);

>         PaxProgram1.SetAddress(H_ShowMessage, @ShowMessage);
>         PaxProgram1.SetAddress(H_IntToStr, @IntToStr);
>         PaxProgram1.Run; // the first run
>         if H_X <> 0 then
>         begin
>           P := PaxProgram1.GetAddress(H_X);
>           ShowMessage('host:' + IntToStr(Integer(P^))); // show script-defined variable
>         end;

>         Integer(P^) := 30; // change script-defind variable

>         PaxProgram1.Run; // the second run
>       end
>       else
>         for I:=0 to PaxCompiler1.ErrorCount do
>           ShowMessage(PaxCompiler1.ErrorMessage[I]);
>     end;

### TPaxScripter.RegisterArrayType

> Registeres array type for paxCompiler.

>     function RegisterArrayType(LevelId: Integer; const TypeName: String; RangeTypeId, ElemTypeId: Integer): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace.

> > TypeName

> > > Name of array type.

> > RangeTypeId

> > > Id of ordinal type that specifies range of array.

> > ElemType

> > > Id of type that specifies type of array element.

> #### Example

>     H_Range := PaxCompiler1.RegisterSubrangeType(0, 'MySubrangeType', _typeCHAR, ord('A'), ord('Z'));
>     H_TMyPoint := PaxCompiler1.RegisterRecordType(0, 'TMyPoint');
>     PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
>     PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);
>     H_Array := PaxCompiler1.RegisterArrayType(0, 'MyArray', H_Range, H_TMyPoint);

### TPaxScripter.RegisterLanguage

> Registeres component that represents programming language for paxCompiler.

>     procedure RegisterLanguage(L: TPaxCompilerLanguage);

> #### Example

>     var PaxCompiler1: TPaxCompiler;
>         PaxPascalLanguage1: TPaxPascalLanguage;
>     begin
>       PaxCompiler1 := TPaxCompiler.Create(nil);
>       PaxPascalLanguage1 := TPaxPascalLanguage.Create(nil);
>       PaxCompiler1.RegisterLanguage(PaxPascalLanguage1);
>     ................

### TPaxScripter.RegisterNamespace

> Registeres a namespace for the paxCompiler.

>     function RegisterNamespace(LevelId: Integer; const NamespaceName: String): Integer;

> #### Arguments

> > LevelId

> > > Id of owner namespace.

> > NamespaceName

> > > Name of namespace.

> #### Example

>     id := RegisterNamespace(0, 'MyNamespace'); // 0 represents noname namespace
>     RegisterVariable(id, 'MyVar', _typeINTEGER, @MyVar);

### TPaxScripter.RegisterRecordType

> Registeres a record type.

>     function RegisterRecordType(LevelId: Integer; const TypeName: String): Integer;

> #### Arguments

> > LevelId

> > > Id of owner record type or id of namespace.

> > TypeName

> > > Name of record type.

> #### Example

>     H_TMyPoint := PaxCompiler1.RegisterRecordType(0, 'TMyPoint');
>     PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
>     PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);

### TPaxScripter.RegisterRoutine

> Registeres header of function or procedure for paxCompiler.

>     function RegisterRoutine(LevelId: Integer; const Name: String; ResultTypeID: Integer; CallConvention: Integer; SaveESI_EDI: Boolean = false): Integer;

> #### Arguments

> > LevelId

> > > Id of owner namespace.

> > Name

> > > Name of procedure or function.

> > ResultTypeID

> > > Id of result type.

> > CallConvention

> > > _ccSTDCALL = 1 _ccREGISTER = 2

> > SaveESI_EDI

> > > If 'true', each call of function will save ESI and EDI registers in stack.

> #### Example

>     H_IntToStr := PaxCompiler1.RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
>     PaxCompiler1.RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);

### TPaxScripter.RegisterParameter

> Registeres parameter of a host-defined procedure of function.

>     function RegisterParameter(HSub: Integer; ParamTypeID: Integer; const DefaultValue: Variant; ByRef: Boolean = false): Integer;

> #### Arguments

> > HSub

> > > Id of routine.

> > ParamTypeId

> > > Id of type of parameter.

> > DefaultValue

> > > Default value of parameter.

> > ByRef

> > > If 'true', this is the variable parameter, otherwise this is the value parameter.

> #### Example

>     H_IntToStr := PaxCompiler1.RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
>     PaxCompiler1.RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);

### TPaxScripter.RegisterPointerType

> Registeres a pointer type for paxCompiler.

>     function RegisterPointerType(LevelId: Integer;
>     const TypeName: String; OriginTypeId: Integer): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace.

> > TypeName

> > > Name of pointer type.

> > OriginTypeId

> > > Id of origin type.

> #### Example

>     H_TMyPoint := PaxCompiler1.RegisterRecordType(0, 'TMyPoint');
>     PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'X', _typeINTEGER);
>     PaxCompiler1.RegisterRecordTypeField(H_TMyPoint, 'Y', _typeINTEGER);
>     H_PMyPoint := PaxCompiler1.RegisterPointerType(0, 'PMyPoint', H_TMyPoint);

### TPaxScripter.RegisterProceduralType

> Registeres a procedural type for paxCompiler.

>     function RegisterProceduralType(LevelId: Integer; const TypeName: String; SubId: Integer): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace.

> > TypeName

> > > Name of type.

> > SubId

> > > Id of header of a subroutine.

> #### Example

>     H_IntToStr := PaxCompiler1.RegisterRoutine(0, 'IntToStr', _typeSTRING, _ccREGISTER);
>     PaxCompiler1.RegisterParameter(H_IntToStr, _typeINTEGER, _Unassigned);
>     H_FuncType := PaxCompiler1.RegisterProceduralType(0, 'TFuncType', H_IntToStr);

### TPaxScripter.RegisterSetType

> Registeres a set type for paxCompiler.

>     function RegisterSetType(LevelId: Integer; const TypeName: String; OriginTypeId: Integer): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace.

> > TypeName

> > > Name of set type.

> > OriginTypeId

> > > Id of origin type.

> #### Example

>     RegisterSetType(0, 'TMySet', _typeCHAR);

### TPaxScripter.RegisterSubrangeType

> Registeres a subrange type for the paxCompiler.

>     function RegisterSubrangeType(LevelId: Integer; const TypeName: String; TypeBaseId: Integer; const B1, B2: Integer): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace.

> > TypeName

> > > Name of subrange type.

> > TypeBaseId

> > > Id of base type.

> > B1

> > > Low bound.

> > B2

> > > High bound.

> #### Example

>     PaxCompiler1.RegisterSubrangeType(0, 'MySubrangeType', _typeCHAR, ord('A'), ord('Z'));

### TPaxScripter.RegisterVariable

> Registeres a host-defined variable for paxCompiler.

>     function RegisterVariable(LevelId: Integer; const Name: String; TypeId: Integer): Integer;

> #### Arguments

> > LevelId

> > > Id of namespace

> > Name

> > > Name of variable.

> > TypeId

> > > Id of variables's type.

> #### Example

>     H_MyVar := PaxCompiler1.RegisterVariable(0, 'MyVar', _typeSINGLE);

### TPaxScripter.Reset

> Removes all source code modules and registered items from compiler.

>     procedure Reset;