Recent

Author Topic: Compile error  (Read 1370 times)

SudoKai

  • Newbie
  • Posts: 6
    • SudoKai
Compile error
« on: April 26, 2019, 09:36:24 pm »
One of my applications triggered a 'Wrong number of parameters specified for call to "Length"' compile error.

My very old installation of Lazarus 1.4.0 does not trigger this compile error, but Lazarus 2.0.2 does.

Below is some test code:

Code: Pascal  [Select][+][-]
  1. uses
  2.  BGRABitmapTypes;
  3.  
  4. Procedure TForm1.Set_Length;
  5. Var
  6.  Loop: Integer;
  7.  Array_of_TPointF: Array[0..5] of TPointF;
  8.  Array_of_Integer: Array[0..5] of Integer;
  9. Begin
  10.  With Array_of_TPointF[0] do
  11.   For Loop := 0 to Length(Array_of_Integer)-1 do
  12. end;

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Compile error
« Reply #1 on: April 26, 2019, 10:15:02 pm »
Better would be the following which avoids Length() altogether:

Code: Pascal  [Select][+][-]
  1.      ...
  2.      for Loop := Low(Array_of_Integer) to High(Array_of_Integer) do
  3.      ...

SudoKai

  • Newbie
  • Posts: 6
    • SudoKai
Re: Compile error
« Reply #2 on: April 26, 2019, 10:47:31 pm »
Only the x,y variables are supposed to be visible with TPointF, yet the identifier completion (Ctrl+space) lists procedures and functions as well.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11447
  • FPC developer.
Re: Compile error
« Reply #3 on: April 26, 2019, 11:36:45 pm »
Only the x,y variables are supposed to be visible with TPointF, yet the identifier completion (Ctrl+space) lists procedures and functions as well.

Later Delphi's add methods, and so does FPC. I think 3.0 for the non floating point records, and 3.0.4 for the floating point ones.

SudoKai

  • Newbie
  • Posts: 6
    • SudoKai
Re: Compile error
« Reply #4 on: April 27, 2019, 09:26:02 am »
Thank you for the feedback thus far. I will try the Low and High suggestion.

Seems I have to be careful with Lazarus 2.0.2 as I can get into trouble real quick real fast.


 

TinyPortal © 2005-2018