Author Topic: [SOLVED]Dynamic array as pointer  (Read 747 times)

creaothceann

  • Sr. Member
  • ****
  • Posts: 471
Re: Dynamic array as pointer
« Reply #15 on: September 23, 2026, 10:27:28 am »
So that is different than using ResourceString ?

ResourceString is for translations. Embed etc. is for binary data.

H₂SO₄

  • Hero Member
  • *****
  • Posts: 511
Re: Dynamic array as pointer
« Reply #16 on: September 24, 2026, 07:24:11 am »
ResourceString is for translations. Embed etc. is for binary data.

For those that are curious: all  resourcestring  does is place the identifiers and addresses of associated strings in a special global table so they can be accessed by translation routines; it doesn't do any resource management on its own.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6451
  • Compiler Developer
Re: Dynamic array as pointer
« Reply #17 on: September 24, 2026, 09:49:59 pm »
Here is the code

Code: Pascal  [Select][+][-]
  1. procedure DrawPicture(x, y : Integer; img : Pointer);
  2. var x1, y1 : Integer;
  3.     temp   : array of array of Integer;
  4. begin
  5. temp := @img;
  6.  
  7. for x1:=Low(temp) to High(temp) do
  8.     begin
  9.     for y1:=Low(temp) to High(temp[0]) do
  10.         begin
  11.         ScaledPixel(x1 * SCALE + x, y1 * SCALE + y, temp[x1, y1], SCALE);
  12.         end;
  13.     end;
  14. Pointer(temp) := Nil;
  15. end;
  16.  

The main issue here is that an array of array of X is on the first level an array of Pointer. So you can't simply convert a flat two dimensional array of values to such an array, because then the variable would interpret the values inside the first array as pointers to the sub arrays.

 

TinyPortal © 2005-2018