tpaxscripter_methods.htm

来自「Delphi脚本控件」· HTM 代码 · 共 1,897 行 · 第 1/5 页

HTM
1,897 行
字号
</blockquote>
<a name="TPaxScripter.GetClassInfo"><h3>TPaxScripter.GetClassInfo</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Allows you to get information about methods, fields, properties and events of a class.
<pre>
<font color="blue"><b>procedure</b></font> GetClassInfo(<font color="blue"><b>const</b></font> FullName: <font color="blue"><b>String</b></font>; mk: TPaxMemberKind; L: TStrings);
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>FullName</i>
<blockquote>
Full qualified name of class.
</blockquote>
</blockquote>
<blockquote>
<i>mk</i>
<blockquote>
Admissible values are mkField, mkProp, mkMethod, mkEvent.
</blockquote>
</blockquote>
<blockquote>
<i>L</i>
<blockquote>
Output string list.
</blockquote>
</blockquote>
</blockquote>
<a name="TPaxScripter.GetInstruction"><h3>TPaxScripter.GetInstruction</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns p-code instruction.
<pre>
<font color="blue"><b>function</b></font> GetInstruction(N: Integer): TPaxInstruction;
</pre>
<p>
TPaxInstruction = record
  N, Op, Arg1, Arg2, Res: Integer;
end;
</p>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.InstructionCount"><li>InstructionCount</li></a>
<a href="#TPaxScripter.RunInstruction"><li>RunInstruction</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.GetKind"><h3>TPaxScripter.GetKind</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns kind of id.
<pre>
<font color="blue"><b>function</b></font> GetKind(ID: Integer): TPAXMemberKind;
</pre>
<p>
TPAXMemberKind = (mkUnknown, mkConst, mkField, mkProp, mkParam, mkResult,
                  mkMethod, mkClass, mkStructure, mkEnum);
</p>
</blockquote>
<a name="TPaxScripter.GetLastResult"><h3>TPaxScripter.GetLastResult</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of result of function which was called in the debug mode.
<pre>
<font color="blue"><b>function</b></font> GetLastResult: Integer;
</pre>
</blockquote>
<a name="TPaxScripter.GetMemberID"><h3>TPaxScripter.GetMemberID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of a script-defined variable, method or type by its name.
<pre>
<font color="blue"><b>function</b></font> GetMemberID(<font color="blue"><b>const</b></font> Name: <font color="blue"><b>String</b></font>): Integer;
</pre>
<p>
Group: "Code explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetModule"><h3>TPaxScripter.GetModule</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of module.
<pre>
<font color="blue"><b>function</b></font> GetModule(ID: Integer): Integer;
</pre>
<p>
Modules are numerated by numbers 0, 1, 2... according to the order of AddModule method calls.
</p>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.AddModule"><li>AddModule</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.GetName"><h3>TPaxScripter.GetName</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns name of script-defined variable, method or class represented by its id.
<pre>
<font color="blue"><b>function</b></font> GetName(ID: Integer): <font color="blue"><b>String</b></font>;
</pre>
<p>
Group: "Code explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetOwnerID"><h3>TPaxScripter.GetOwnerID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of owner of script-defined type, variable or method.
<pre>
<font color="blue"><b>function</b></font> GetOwnerID(ID: Integer): Integer;
</pre>
</blockquote>
<a name="TPaxScripter.GetParamID"><h3>TPaxScripter.GetParamID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of formal parameter of a script-defined method.
<pre>
<font color="blue"><b>function</b></font> GetParamID(SubID, ParamIndex: Integer): Integer;
</pre>
<p>
Group: "Code Explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetPosition"><h3>TPaxScripter.GetPosition</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns text position of a script-defined variable, method or type by its id.
<pre>
<font color="blue"><b>function</b></font> GetPosition(ID: Integer): Integer;
</pre>
<p>
Group: "Code Explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetResultID"><h3>TPaxScripter.GetResultID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of result of script-defined method.
<pre>
<font color="blue"><b>function</b></font> GetResultID(SubID: Integer): Integer;
</pre>
<p>
Group: "Code explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetRootID"><h3>TPaxScripter.GetRootID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of noname namespace.
<pre>
<font color="blue"><b>function</b></font> GetRootID: Integer;
</pre>
<p>
Group: "Code explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetTypeID"><h3>TPaxScripter.GetTypeID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns id of type of a script-defined variable or method.
<pre>
<font color="blue"><b>function</b></font> GetTypeID(ID: Integer): Integer;
</pre>
<p>
Group: "Code explorer".
</p>
</blockquote>
<a name="TPaxScripter.GetUserData"><h3>TPaxScripter.GetUserData</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns user data associated with a host-defined variable, constant, type or method.
<pre>
<font color="blue"><b>function</b></font> GetUserData(ID: Integer): Integer;
</pre>
</blockquote>
<a name="TPaxScripter.GetValueByID"><h3>TPaxScripter.GetValueByID</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns value of a script-defined variable by its id.
<pre>
<font color="blue"><b>function</b></font> GetValueByID(ID: Integer): Variant;
</pre>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.SetValueByID"><li>SetValueByID</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.InstructionCount"><h3>TPaxScripter.InstructionCount</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns number of instructions of p-code.
<pre>
<font color="blue"><b>function</b></font> InstructionCount: Integer;
</pre>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.GetInstruction"><li>GetInstruction</li></a>
<a href="#TPaxScripter.RunInstruction"><li>RunInstruction</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.IsError"><h3>TPaxScripter.IsError</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns true, if there was an error at compile-time or run-time.
<pre>
<font color="blue"><b>function</b></font> IsError: Boolean;
</pre>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.DiscardError"><li>DiscardError</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.IsExecutableSourceLine"><h3>TPaxScripter.IsExecutableSourceLine</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns 'true', if line of source code is the executable script line.
<pre>
<font color="blue"><b>function</b></font> TPaxScripter.IsExecutableSourceLine(<font color="blue"><b>const</b></font> ModuleName: <font color="blue"><b>String</b></font>; L: Integer): Boolean;
</pre>
<p>
<H4>
Example
</H4>
<pre>
PaxScripter1.ResetScripter;
  PaxScripter1.AddModule(<font color="Red">'1'</font>, <font color="Red">'PaxPascal'</font>);
  PaxScripter1.AddCode(<font color="Red">'1'</font>, Memo1.Lines.Text);
  PaxScripter1.Compile();

  Memo2.Lines.Clear;

  L := TStringList.Create;
  L.Text := Memo1.Text;

  <font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> L.Count - 1 <font color="blue"><b>do</b></font>
  <font color="blue"><b>begin</b></font>
    <font color="blue"><b>if</b></font> PaxScripter1.IsExecutableSourceLine(<font color="Red">'1'</font>, I) <font color="blue"><b>then</b></font>
      S := <font color="Red">'*  '</font> + L[I]
    <font color="blue"><b>else</b></font>
      S := <font color="Red">'   '</font> + L[I];
    L[I] := S;
  <font color="blue"><b>end</b></font>;

  Memo2.Text := L.Text;

  L.Free;
</pre>
</p>
</blockquote>
<a name="TPaxScripter.IsLocalVariable"><h3>TPaxScripter.IsLocalVariable</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns true, if id represents a local variable.
<pre>
<font color="blue"><b>function</b></font> IsLocalVariable(ID: Integer): Boolean;
</pre>
</blockquote>
<a name="TPaxScripter.LanguageCount"><h3>TPaxScripter.LanguageCount</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Returns number of pax-languages which supports the paxScripter.
<pre>
<font color="blue"><b>function</b></font> LanguageCount: Integer;
</pre>
<p>
<H4>
Example
</H4>
<pre>
<font color="blue"><b>for</b></font> I:=0 <font color="blue"><b>to</b></font> PaxScripter1.LanguageCount - 1 <font color="blue"><b>do</b></font>
  ShowMessage(PaxScripter1.Languages[I].LanguageName);
</pre>
</p>
</blockquote>
<a name="TPaxScripter.LoadProject"><h3>TPaxScripter.LoadProject</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Loads paxScript project from disk.
<pre>
<font color="blue"><b>procedure</b></font> LoadProject(<font color="blue"><b>const</b></font> FileName: <font color="blue"><b>String</b></font>);
</pre>
<p>
<H4>
Example
</H4>
<pre>
PaxScripter1.LoadProject(<font color="Red">'myproject.pax'</font>);
</pre>
</p>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.AddCode"><li>AddCode</li></a>
<a href="#TPaxScripter.AddCodeFromFile"><li>AddCodeFromFile</li></a>
<a href="#TPaxScripter.AddModule"><li>AddModule</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.LoadFromFile"><h3>TPaxScripter.LoadFromFile</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Loads all modules of compiled script from a file.
<pre>
<font color="blue"><b>procedure</b></font> LoadFromFile(<font color="blue"><b>const</b></font> FileName: <font color="blue"><b>String</b></font>);
</pre>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.LoadFromStream"><li>LoadFromStream</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.LoadFromStream"><h3>TPaxScripter.LoadFromStream</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Loads all modules of compiled script from a stream.
<pre>
<font color="blue"><b>procedure</b></font> LoadFromStream(S: TStream);
</pre>
<p>
<H4>
Example
</H4>
<pre>
<font color="blue"><b>var</b></font>
  S: TPaxScripter;
  F: TFileStream;
<font color="blue"><b>begin</b></font>
  F := TFileStream.Create(<font color="Red">'compiled_script.bin'</font>, fmOpenRead);
  S := TPaxScripter.Create(nil);
  <font color="blue"><b>try</b></font>
    S.LoadFromStream(F);
    S.Run;
  <font color="blue"><b>finally</b></font>
    S.Free;
    F.Free;
  <font color="blue"><b>end</b></font>;
<font color="blue"><b>end</b></font>;
</pre>
</p>
<H4>
See Also
</H4>
<blockquote>
<ul>
<a href="#TPaxScripter.LoadFromFile"><li>LoadFromFile</li></a>
</ul>
</blockquote>
</blockquote>
<a name="TPaxScripter.RegisterConstant"><h3>TPaxScripter.RegisterConstant</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Adds a host-defined constant to a script.
<pre>
<font color="blue"><b>procedure</b></font> RegisterConstant(<font color="blue"><b>const</b></font> Name: <font color="blue"><b>String</b></font>; Value: Variant; Owner: Integer = -1);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?