[fpc-pascal] PAS2JS: operations with array of record
Michael Van Canneyt
michael at freepascal.org
Thu Jan 11 13:23:32 CET 2018
On Thu, 11 Jan 2018, warleyalex via fpc-pascal wrote:
> Thanks a lot for the feedback.
> it worked as expected! The solution was:
> /* in DWScript world */var recA : JA; recB : JB; recC : JC;for var
> k:=0 to 2 do begin recC.id := k; recC.name := 'abc'+IntToStr(k); recC.age
> := 10+k; recB.field1 := 'rec'+ IntToStr(k); recB.params.Add(recC);
> recA.fields.Add(recB);end;/* in Pas2JS world */var recA : JA; recB : JB;
> recC : JC; k: Integer;beginfor k:=0 to 2 do begin recC.id := k;
> recC.name := 'abc'+IntToStr(k); recC.age := 10+k; recB.field1 := 'rec'+
> IntToStr(k); TJSArray(recB.params).push(recC);
> TJSArray(recA.fields).push(recB);end;
> Take a look at this array of record example, in Smart Pascal world, as long
> as the datatypes match (e.g. field params is a array of record), we have the
> pseudo methods functionality "built-in" for all arrays, for instance. Pas2JS
> could have this high level functionality as well. Using the Pas2JS approach
> with external classes interfaces it looks so powerful :)
> <http://free-pascal-general.1045716.n5.nabble.com/file/t339674/codeinsight.png>
In due course, array methods will be added, to get on par with FPC/Delphi.
But we have no plans to copy smart pascal extensions.
Michael.
More information about the fpc-pascal
mailing list