Recent

Author Topic: "Local variable does not seem to be initialized" for move, fillchar - won't fix?  (Read 12243 times)

del

  • Sr. Member
  • ****
  • Posts: 258
Code: Pascal  [Select][+][-]
  1.  buff[1] := 0;

The first element of the array is 0 not 1.

See Thaddy's warning above about doing this: the cure may be worse than the disease.

Personally I'd use initialize:

Code: Pascal  [Select][+][-]
  1. procedure foo;
  2. var
  3.   buffer : array[0..9] of byte;
  4. begin
  5.   initialize(buffer, length(buffer));
  6.  ...

Finally, you're replying to a 4 year old thread.
I didn't need the thread until now. And I didn't find a good answer until now. When I tried "0" as the first element I got a range error. Now the next time somebody comes here they'll see a good answer. Thanks.

ccrause

  • Hero Member
  • *****
  • Posts: 845
Code: Pascal  [Select][+][-]
  1.  buff[1] := 0;

The first element of the array is 0 not 1.

In del's example the array was defined to start at 1:
Code: Pascal  [Select][+][-]
  1. buff: array[1..BUF_SIZE] of byte;

del

  • Sr. Member
  • ****
  • Posts: 258
Yeah it's from some example I found (maybe here) for grabbing the output of a program you're running with TProcess.

 

TinyPortal © 2005-2018