[Pas2js] call from external js files

Michael Van Canneyt michael at freepascal.org
Tue Jun 18 08:44:53 CEST 2019



On Tue, 18 Jun 2019, pas2js at gauns.org wrote:

>
>> You can use (as I proposed originally) an external class definition:
>> (see the external name just after the class keyword)
>
> oh sorry, i missed that
>
>> 
>> TExternal = class external name 'anonymous'
>>    public
>>      name : String;
>>      function getName : String;
>>      procedure log( aMessage : String );
>>    end;
>> 
>> 
>> var
>>   logger : TExternal; external name 'logger';
>
> would by nice to have it this way, if its possible,
> but to have the external declaration two times (class and variable) is 
> also ok, just a wish
>
> type
>   TExternal = class external name 'logger'
>   public
>     name : String;
>     function getName : String;
>     procedure log( aMessage : String );
>   end;
>
> var
>   ext : TExternal;

This will never be possible.

You can declare & instantiate a local instance of an external class, that is
what your code does.

The "external" after the ext : texternal is necessary to make clear that
the variable already exists externally.

Michael.


More information about the Pas2js mailing list