tps_bcb_demo_paxtime.htm

来自「Delphi脚本控件」· HTM 代码 · 共 89 行

HTM
89
字号
<html>
<head>
<link rel=stylesheet type="text/css" href="styles.css">
</head>

<body>

<font face="Arial, Helvetica">

<h3>
TpaxScripter Demo. PAX Time.
</h3>
<hr>

<pre>
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "PaxScripter"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  PaxScripter1->Run(rmRun, "", 0);
}
//---------------------------------------------------------------------------

<font color="red">
AnsiString GetStrTime() {
  return DateTimeToStr(Now());
}
</font>

void __fastcall TForm1::PaxScripter1AssignScript(TPaxScripter *Sender)
{
<font color="red">
  RegisterRoutine("function GetStrTime(): String; cdecl;", GetStrTime, -1);</font>
  Sender->AddModule("main", paxBasic);
  Sender->AddCodeFromFile("main", "script.txt");
}
//---------------------------------------------------------------------------

</pre>

<h4>
script.txt
</h4>

<pre>
<font color="blue"><b>Imports</b></font> SysUtils, ExtCtrls, Forms

<font color="blue"><b>Dim</b></font> Form = <font color="blue"><b>New</b></font> TForm(NULL)
Form.Caption = "PAX Time"
Form.Canvas.Font.Height = 50

<font color="blue"><b>Dim</b></font> Timer = <font color="blue"><b>New</b></font> TTimer(Form)
Timer.Interval = 100
Timer.OnTimer = <font color="blue"><b>AddressOf</b></font> ShowTime

Form.Show

<font color="blue"><b>Sub</b></font> ShowTime(Sender)
  Form.Canvas.TextOut 10, 10, <font color="red">GetStrTime()</font> 
<font color="blue"><b>End</b></font> <font color="blue"><b>Sub</b></font>
</pre>



<p>
<HR>
<font size = 1 color ="gray">
Copyright &copy; 1999-2005
VIRT Laboratory. All rights reserved.
</font>
</body>
</html>

⌨️ 快捷键说明

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