Difference between revisions of "lazarus pas2js integration"

From Free Pascal wiki
Jump to navigationJump to search
(Page describing the pas2js integration of lazarus)
 
Line 8: Line 8:
  
 
=== New Web Browser application ===
 
=== New Web Browser application ===
This wizard will ask for some options before generating a new project
+
This wizard will ask for some options before generating a new project.
 +
The dialog is shown below.
 +
 
 +
[[File:webbrowserappoptions.png]]
 +
 
 +
The following options are available:
 +
* Create initial HTML page. This is self-explanatory, <br/>the IDE will generate a template HTML page which includes all that is necessary to run the pas2js code.<br/>The page is included in the project description, so you can open and edit it from within the IDE.
 +
* Maintain HTML page.<br>If you change the name of the project, the IDE will update the references in the HTML File.<br/>(all your changes will be lost)
 +
* Run rtl in document.onReady. By default the script tag that starts the ball rolling will  call <code>rtl.run()</code>.<br/> Checking this option changes the script, so the <code>rtl.run</code> is run in the HTML <code>document.onReady</code> event instead.<br/> This is necessary if your code contains  startup code that references elements in the HTML. <br/>The elements will only be available after the onReady event.
 +
* Use Browser Application object.<br/>This changes the code to use the <code>TBrowserApplication</code> object.<br/> This is a <code>TCustomApplication</var> descendent which offers support for query parameters etc. as if they were command-line parameters.
 +
* Use Browser Console unit.<br/> Checking this will simply include the browserconsole unit in the uses clause. <br/>This hooks into the system units writeln command: any output will be appended to the HTML. <br/> the generated HTML has a div with the correct ID to which the output is appended.
 +
* Project needs a HTTP server.<br> If the project needs a HTTP server, then the IDE can start one for you, or you can indicate the URL to use when the 'Run without debugging'  command is used.

Revision as of 14:26, 17 December 2017

Lazarus pas2JS integration

project wizards

The pas2js support is in the pas2jsdsgn.lpk package, which you can find in the components/pas2js directory. It registers 2 wizards in the 'New project' dialog:

  • Web Browser Application
  • Node.js Application

New Web Browser application

This wizard will ask for some options before generating a new project. The dialog is shown below.

webbrowserappoptions.png

The following options are available:

  • Create initial HTML page. This is self-explanatory,
    the IDE will generate a template HTML page which includes all that is necessary to run the pas2js code.
    The page is included in the project description, so you can open and edit it from within the IDE.
  • Maintain HTML page.
    If you change the name of the project, the IDE will update the references in the HTML File.
    (all your changes will be lost)
  • Run rtl in document.onReady. By default the script tag that starts the ball rolling will call rtl.run().
    Checking this option changes the script, so the rtl.run is run in the HTML document.onReady event instead.
    This is necessary if your code contains startup code that references elements in the HTML.
    The elements will only be available after the onReady event.
  • Use Browser Application object.
    This changes the code to use the TBrowserApplication object.
    This is a TCustomApplication descendent which offers support for query parameters etc. as if they were command-line parameters.
  • Use Browser Console unit.
    Checking this will simply include the browserconsole unit in the uses clause.
    This hooks into the system units writeln command: any output will be appended to the HTML.
    the generated HTML has a div with the correct ID to which the output is appended.
  • Project needs a HTTP server.
    If the project needs a HTTP server, then the IDE can start one for you, or you can indicate the URL to use when the 'Run without debugging' command is used.