THtmlPscl v1.0/10.22


Augusto Angelim
 

THtmlPscl = THtmlViewer + MagicScript

 
 
   
  On CodeTyphon project unit
 
   
 
TForm1 = class(TForm)
  Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
HtmlPscl1: THtmlPscl;   // THtmlPscl component!
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
end;  
var  
Form1: TForm1;

implementation

{$R *.frm}

{ TForm1 }
   
procedure TForm1.Button1Click(Sender: TObject);
begin
  HtmlPscl1.LoadFromFile( UnicodeString(Edit1.Text) );
HtmlPscl1.ScriptExec;
To use a HTML file with
"<script type="text/pascalscript" src="html\pascalrt.pscl"></script>"
 code in HTML header.This code load "html\pascalrt.pscl" Script file
 
end;
   
procedure TForm1.Button2Click(Sender: TObject);
begin
  HtmlPscl1.LoadFromFile( UnicodeString(Edit1.Text) );
HtmlPscl1.LoadScript( Edit2.Text );
HtmlPscl1.ScriptExec;
To use a "HTML" file with a Script file
Load a "HTML" file from "Edit1" and load
Script file from "Edit2".
end;
   
procedure TForm1.FormCreate(Sender: TObject);
begin
  HtmlPscl1.memoConsole := Memo1; Console to view message from THtmlPscl
end;
end.  

 

   
 
   
  On HTML project
 
   
 
 
       
 
   
  On Pascal Script page project
 
   
 
// THtmlPscl 1.0/10.22 THtmlViewer with MagicScript
// Augusto Angelim
// 16/10/2022 17:57:45
//--------------------------------------------------
program manual;
var
  s : String;
b : TButton;
m : TMemo;
   
procedure chk01(Sender:TObject);
begin
  ConsoleActivate(DocumentHTML,false);
 
end;
   
procedure chk02(Sender:TObject);
begin
  ConsoleMsg(DocumentHTML,'Glórias a Deus!');  
end;
   
procedure chk03(Sender:TObject);
begin
  ConsoleActivate(DocumentHTML,true);
end;
end.  
procedure OnClick(Sender:TObject);
begin
  m.Lines.Add('Button: OnCLick!');  
end;
end.  

begin
  ConsoleActivate(DocumentHTML,true);
ConsoleMSG(DocumentHTML,'
Starting script "pascalweb2.pscl"');
//
panelComponent.Color := clBlue;
panelComponent.BorderStyle := bsNone;
//
b := TButton.Create(Self);
b.Parent :=
panelComponent;
b.Caption := 'Click';
b.Left := 10;
b.Top := 10;
b.OnClick := @OnClick;

//
ConsoleMSG(DocumentHTML,'
Button: "'+b.Caption+'" criado com sucesso!');
//
m := TMemo.Create(Self);
m.Parent :=
panelComponent;
m.Left := 110;
m.Top := 10;
//
ConsoleMSG(DocumentHTML,'
Memo: "'+b.Caption+'" criado com sucesso!');
//
memoConsole.lines.add(
TimeToStr(NOW) +': Oi mundo!');
//
s := HTMLGetValue(DocumentHTML,'
firstname','nil');
memoConsole.lines.add(s);
//
s := HTMLSetValue(DocumentHTML,'
lastname','Glórias a Deus!');
memoConsole.lines.add(s);
//
s := HTMLSetValue(DocumentHTML,'
combo','Item 4');
s := HTMLSetValue(DocumentHTML,'
chkbox',TRUE);
s := HTMLSetValue(DocumentHTML,'
R1',TRUE);
//
ThtEdit(firstname).Text := '
´É um "ThtEdit"!';
memoConsole.lines.add(
'Texto: ' + ThtEdit(firstname).Text);
//
TFormCheckBox(chkbox3).Checked := TRUE;
s := HTMLSetValue(DocumentHTML,'chkbox3',TRUE);
//
TFormCheckBox(chkbox3).Caption := 'CheckBox true caption';
//
ThtComboBox(combo).Items.Text:='AAA'+#13#10+'BBB'+#13#10+'CCC';
ThtComboBox(combo).Text := 'AAA';
memoConsole.lines.add( ThtComboBox(combo).Items.Text );
 
end.  
   
 
   
 
Notes:
 
DocumentHTML - Object from THtmlPscl
ConsoleActivate(htmlpscl, true/false) - Turn On/Off messages to console memo
ConsoleMSG(htmlpscl, 'message') - Send a message to console memo
memoConsole - Is TMemo from THtmlPscl
HTMLGetValue(htmlpscl, html element, return value to verify)
HTMLSetValue(htmlpscl, html element, return value to verify)
ThtEdit - Class from THtmlPscl (see console on run "shtmlpscl")
TFormCheckBox - Class from THtmlPsc l(see console on run "shtmlpscl")
ThtComboBox - Class from THtmlPsc l(see console on run "shtmlpscl")
panelComponent - TPanel criate from HTML directive "<panel name="panelComponent" align="center"  Height="150" Width="100%">"