Recent

Author Topic: [SOLVED] Fixed dynamic array of char size  (Read 2097 times)

qq9ebg9acvzx

  • New Member
  • *
  • Posts: 21
[SOLVED] Fixed dynamic array of char size
« on: July 02, 2017, 07:30:24 pm »
I have the following type:
Code: Pascal  [Select][+][-]
  1. EntryData = packed record
  2.               group   : packed array[1..256] of char;
  3.               group_id: TGuid;
  4.               // entries array length is dynamic, each packed array of char (string) can have any length and it cannot change, must be fixed length always
  5.               entries : packed array of packed array of char;
  6.             end;
  7.  

The problem is when I set the content of the strings in the dynamic array, FPC changes its length.
Code: Pascal  [Select][+][-]
  1.   SetLength(data[0].entries[0], 64);
  2.   SetLength(data[0].entries[1], 80);
  3.  
  4.   data[0].entries[0] := 'eTyWw6TtLFpkFd1XD3vB';
  5.   data[0].entries[1] := 'GhW2C1i7e3xEay2ak';
  6.  
After setting data FPC changes length to other value othen than 64, 80 respectively. And it is bringing trouble as the data is expected to be that length when written to file as returned by Length().

Is there anything I can do to prevent that behavior?

Thank you!
« Last Edit: July 02, 2017, 07:55:26 pm by qq9ebg9acvzx »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Fixed dynamic array of char size
« Reply #1 on: July 02, 2017, 07:37:13 pm »

qq9ebg9acvzx

  • New Member
  • *
  • Posts: 21
Re: Fixed dynamic array of char size
« Reply #2 on: July 02, 2017, 07:55:11 pm »

 

TinyPortal © 2005-2018