[Pas2js] Export a method to be called from javascript?
Michael Van Canneyt
michael at freepascal.org
Mon Jul 3 11:32:40 CEST 2023
On Mon, 3 Jul 2023, Luca Olivetti via Pas2js wrote:
> Hello,
>
> how do I export a method/procedure so that it can be called by plain
> javascript?
>
> I need it so I can call it from an android WebView
> (myWebView.evaluateJavascript).
>
> I tried to add an "export" modifier both to a method and to a plain procedure
> but the compiler tells me "not yet implemented".
The trunk compiler supports compilation of libraries, there you can do this.
But normally, you can call a method with
pas['yourunit'].yourfunctionname()
pas['yourunit'].$impl.yourfunctionname()
if the function is in the program, replace 'yourunit' with 'program'
Note that the program must have been initialized with run() before you can
do this, because run() will call the initialization section of all units.
Michael.
More information about the Pas2js
mailing list