texttransformer.jpg

This article can be obsolete: Actual documentation online

Initializing arrays


Array's are initialized very simply in Delphi. The initialization of an array of TStyleRecord's:


TStyleRecord = record
  Name    : string;
  Style   : TFontStyles;
end;

could look like:


DefaultStyles : TStylesArray = (
 (Name : 'tnone';    Style :  []),
 (Name : 'tstring';  Style :  []),
 (Name : 'tcomment'; Style :  [fsItalic])
);

This was translated in the earlier versions of Delphi2Cpp as:


TStylesArray DefaultStyles = { 
     { "tnone" /*Name*/, arrays__0 /*Style*/ },
     { "tstring" /*Name*/, arrays__1 /*Style*/ },
     { "tcomment" /*Name*/, arrays__2 /*Style*/ } 
    };

It is a problem however, that such initializations are only possible, if the elements are built in types of C. Such initializations of elements of the type TFontStyle aren't permitted. Beginning with version 1.2.4., Delphi2Cpp therefore generates initialization functions which are called within the initialization routine of the corresponding unit (see above).


void DefaultStylesInit( )
{
  DefaultStyles[0].Name = "tnone";
  DefaultStyles[0].Style = arrays__0;
  DefaultStyles[1].Name = "tstring";
  DefaultStyles[1].Style = arrays__1;
  DefaultStyles[2].Name = "tcomment";
  DefaultStyles[2].Style = arrays__2;
}


   deutsch Deutsch

 

 
Latest News
08/26/24
Delphi2Cpp 2.4: Updated to RAD Studio 12.1 Athens [more...]

01/29/24
Aurora2Cpp: Delphi 7 translator [more...]



"Thanks for your great work, really appreciate the work you have done on zlib and compiling ... test case."


Mattewada, Udayabhaskar
Nokia India 02/01/2021




[from case study...]

"A masterpiece -- Delphi2Cpp has exceeded all my expectations by far."


Tony Hürlimann
virtual-optima 08/20/2011



"First off, I have to say WOW! Delphi2Cpp is doing a *fantastic* job!"


Daniel Flower
linkrealms 01/15/2011


 
This website is generated from plain text with [Minimal Website ]

Minimal Website
Minimal Website is made with TextTransformer

TextTransformer
TextTransformer is made with Borland CBuilder

  borland