Array of Records with Const  in Pas2JS

Top 

Example code : Array of Records with Const  in Pas2JS

type

 TTwoNames = array[0..2of string;

 

 TMyRec = record

    Nome: TTwoNames;

  end;

 

const

  NAMES1: TTwoNames = ('Warley','Alex','Sete Lagoas');

  NAMES2: TTwoNames = ('Osama','Bin Laden','Alcaida');

 

procedure TForm1.W3Button9Click(Sender: TObject);

var

   v : variant;

   StringArraysList: array[0..1of TMyRec = (

                                                (Nome: NAMES1),

                                                (Nome: NAMES2)

                                             );

begin

 v := StringArraysList[1];

 WriteLn(v.Nome);

end;

["Osama", "Bin Laden", "Alcaida"] 

 

 

JS output:

  var v$4 = undefined;

  var StringArraysList = [{Nome:["","",""]},{Nome:["","",""]}];

  var StringArraysList = [{Nome:["Warley","Alex","Sete Lagoas"]},{Nome:["Osama","Bin Laden","Alcaida"]}];

      v$4 = Clone$TMyRec(StringArraysList[1]);

      WriteLn(v$4.Nome);