Forum > Pas2JS

external library in pas2js file

(1/2) > >>

krolikbest:
Hi,

 i try to use some functions from my library. Declaration is as follows:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  function CalculateArm(x,y : Integer; fixedPoint : TFixedPoint; var RobotArmInfo : TRobotArmInfo; var seg : TArm) : Boolean; stdcall; external 'project1.dll';  function GetRangeOfArm(seg : TArm) : Integer; stdcall; external 'project1.dll';  
but during compilation pas2js file I get the error

--- Quote ---unit1.pas(81,24) Error: Not supported: stdcall
--- End quote ---
I'm using win7 64bit, Lazarus 2.0.10, but I suspect that the platform has nothing to do with it. Perhaps it is a matter to pas2js engine? I did installation two years ago, so maybe since then something in pas2js has changed and this issue appears no more?

Some variables in my library are Single type and using this type in pasjs file I get also warning:

--- Quote ---unit1.pas(76,13) Warning: Symbol "Single" is not implemented
--- End quote ---
I hope that in this case I'll be okey anyway.

Regards,

Thaddy:
replace with winapi

krolikbest:
Now it gives me Syntax error :) In Project Inspector  in Required Packages are added:
'pas2js_rtl, and 'WCL'. I'm saying this because maybe it is syntax error is related to use something else but I can't use i.e. LCL and similar..

 

PierceNg:

--- Quote from: krolikbest on January 28, 2023, 08:24:22 pm ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  function ...; stdcall; external 'project1.dll';  function ...; stdcall; external 'project1.dll';  
Perhaps it is a matter to pas2js engine? I did installation two years ago, so maybe since then something in pas2js has changed and this issue appears no more?

--- End quote ---

You mean the code worked two years ago? In web browser or with say Node?

The 'compiled' output of pas2js is Javascript source code, to be run with some Javascript engine. The well known engines are the web browsers and Node, but there are others.

Node supports calling DLLs. Not sure if this functionality is exposed to pas2js. Anyway if you can run Node you might also be able to run native-compiled Pascal program in its place and not use Node at all?

Web browsers dropped the old Netscape plugin API a few years back. Dunno if there is some new standard. Letting web browser run native code from arbitrary DLL is a security no-no in principle.

See this page: https://wiki.freepascal.org/pas2js_modules

krolikbest:

--- Quote ---You mean the code worked two years ago? In web browser or with say Node?
--- End quote ---

No, this is my first attempt at using an external library. Fortunately this is my library (for compute some trigonometric functions) so I can easily implement them into the source of the pas2js file.

Navigation

[0] Message Index

[#] Next page

Go to full version