[Pas2js] is it possible to create GUi with no need to manually add the code to .html page

Jean SUZINEAU Jean.Suzineau at wanadoo.fr
Mon Aug 24 23:00:46 CEST 2020


Le 24/08/2020 à 22:30, Mgr. Janusz Chmiel a écrit :
> Here is my wrong code.
> procedure TMyApplication.doRun;
> begin
>    FMyPage:=TWebPage.Create(Self);
> FMyButton:=TButtonWidget.Create(Self);
>
> I Am getting The following error
> project1.lpr(17,3) Error: identifier not found "FMyPage"
> But where to declare The variable FMyPage and which data type should I
> assign it?

Very likely, you just need to declare it before the begin of the 
implementation method doRun:

procedure TMyApplication.doRun;
var
    FMyPage: TWebPage;
    FMyButton: TButtonWidget;
begin
      FMyPage:=TWebPage.Create(Self);
      FMyButton:=TButtonWidget.Create(Self);

Or better in the class declaration, because it's likely you'll need to 
access FMyPage in other methods of class TMyApplication :

type
   TMyApplication = class(TBrowserApplication)

     procedure doRun; override;
   private
     FMyPage: TWebPage;
     FMyButton: TButtonWidget;
   end;

Just for notice, I have a running page made with pas2js, but I'm not 
sure it can be useful to you because it's written in French and it uses 
canvas to display charts with ChartJS.

Running page: http://jsuzineau.github.io/pascal_o_r_mapping/jsFrequences/

pas2js source code: 
https://github.com/jsuzineau/pascal_o_r_mapping/tree/TjsDataContexte/tools/jsFrequences 
(project in subdirectory pas2js)



More information about the Pas2js mailing list