[Pas2js] Export a method to be called from javascript?

Luca Olivetti luca at ventoso.org
Mon Jul 3 11:58:34 CEST 2023


El 3/7/23 a les 11:32, Michael Van Canneyt via Pas2js ha escrit:
> 
> 
> 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.

Thank you. Right after sending the message I found that I can just call

pas.program.Application.myMethod(parameter)


Bye
-- 
Luca


More information about the Pas2js mailing list