[Pas2js] Call functions from other JS file
Michael Van Canneyt
michael at freepascal.org
Sat Dec 12 10:57:49 CET 2020
On Fri, 11 Dec 2020, imperyal wrote:
> Hello,
>
> Probably a very basic thing...
> How can I call a function defined on pascal, from normal js code?
First, the rtl.run() fnuction must have been called exactly once.
This does some housekeeping, for example it runs the initialization
section. After this, the pascal functions are available as
pas.unitname.functionname.
So for example
pas.SysUtils.UpperCase()
You can also call functions defined in the main program:
pas.program.yourfunc()
or run the main program again:
pas.program.$main()
One of the thngs on the roadmap is lobrary support and Javascipt modules,
this will make things simpler.
but for the moment, the above will work.
Michael
More information about the Pas2js
mailing list