Forum > Pas2JS

[Solved] Import class?

(1/1)

Trenatos:
I just grabbed pas2js 1.4.6 for Windows and giving it a whirl.

I'm trying to import a class defined elsewhere, as in the Wiki example (http://wiki.freepascal.org/pas2js), but it's not compiling.


--- 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";}};} ---program hello; uses        browserconsole; type TJSFunction = class external name 'User'(TJSObject)        private         public                procedure sayHi(_name:String);        end;  begin        WriteLn(sayHi('Marcus'));end.
This is the error


--- 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";}};} ---hello.pas(8,30) Error: Expected "," or ":"Fatal: Compilation aborted

Trenatos:
If anyone else runs into this, the solution is to add the externalclass modeswitch


--- 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";}};} ---{$ModeSwitch externalclass}

Navigation

[0] Message Index

Go to full version