Recent

Author Topic: [Solved] Import class?  (Read 1959 times)

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
[Solved] Import class?
« on: June 05, 2019, 04:14:37 pm »
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  [Select][+][-]
  1. program hello;
  2.  
  3. uses
  4.         browserconsole;
  5.  
  6. type
  7.  
  8. TJSFunction = class external name 'User'(TJSObject)
  9.         private
  10.  
  11.         public
  12.                 procedure sayHi(_name:String);
  13.         end;
  14.  
  15.  
  16. begin
  17.         WriteLn(sayHi('Marcus'));
  18. end.

This is the error

Code: Pascal  [Select][+][-]
  1. hello.pas(8,30) Error: Expected "," or ":"
  2. Fatal: Compilation aborted
« Last Edit: June 05, 2019, 05:37:16 pm by Trenatos »

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: Import class?
« Reply #1 on: June 05, 2019, 05:36:57 pm »
If anyone else runs into this, the solution is to add the externalclass modeswitch

Code: Pascal  [Select][+][-]
  1. {$ModeSwitch externalclass}

 

TinyPortal © 2005-2018