function and procedure call in release mode

Hello friends, is there any way in release mode to call procedures and functions to work more or less like this pas.Unit1.Form1.Form1DOMContentLoaded(self); ?

Do you have more details on what exactly you want to do?
How does release or debug mode make a difference to what you want to do?

Hello Bruno! Basically if I keep it in debug mode, the call to this function via javascript works anywhere in the html, now if I put it in release mode, it gives a function not found error.

It is most likely the optimizer that removes this code as it thinks it is not used.
Try to add somewhere a (pseudo) Object Pascal code call to this function and the optimizer should keep it.

Something like

if (1<0) then
    CallMyPascalFunction;

Thanks Bruno, everything worked out that way. Will it be possible in the future not to have to use this artifice?

This is absolutely not trivial to implement a solution for this as it would require added a JavaScript parser that is able to determine calls to Object Pascal code and mark the code as used.
A maybe easier alternative could be some attribute on methods that instruct the compiler to not optimize code away.
We'll discuss this with the pas2js team

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.