DelphiDigest
65 subscribers
226 photos
13 videos
11 files
1.09K links
Download Telegram
#ObjectPascalNotes

Whenever you call an API for a given platform in your Object Pascal code you lose the ability to recompile the application for any other platform than the specific one. The exception is if the call is surrounded by platform specific
$IFDEF
compile directives.
Watch "TMS FNC TreeView component (part 1): Intro" on YouTube
https://youtu.be/CJ8ZH2L8HmE
Watch "TMS FNC TreeView component (part 2): Virtual mode" on YouTube
https://youtu.be/smEQ89dEJWY
Watch "TMS FNC TreeView component (part 3): Collection" on YouTube
https://youtu.be/TCRfre-mFcE
Watch "TMS FNC TreeView component (part 4): Icons - Columns" on YouTube
https://youtu.be/14_Jyb_4Rp8
Watch "092 - Delphi 10.3.2 com REST Dataware" on YouTube
https://youtu.be/FW23EutbGPY
#ObjectPascalNotes

type
TAllYearTemps = array [1..24, 1..31, 1..12] of Integer;

var
AllYear: TAllYearTemps;


Static arrays immediately take up a lot of memory (in the case above on the stack), which should be avoided. The AllYear variable requires 8,928 Integers, taking up 4 bytes each, this is almost 35KB. Allocating such a large block in the global memory of on the stack is really a mistake. A dynamic array, instead, uses the heap memory, and offers much more flexibility in terms of memory allocation and management.
#ObjectPascalFeatures

var 
di: array of Integer;
i: Integer;

begin
di := [1, 2, 3]; // initialization
di := di + di; // concatenation
di := di + [4, 5]; // mixed concatenation

for i in di do
begin
Show(i.ToString);
end;

end.


These features to dynamic arrays were added in Delphi XE7