Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2023-07

Export a method to be called from javascript?

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

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".

Bye

Luca

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 10 lines
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.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 3/7/23 a les 11:32, Michael Van Canneyt via Pas2js ha escrit:

Show quoted text 28 lines
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

Reply by email