Delphi 7 Compilation error, "For loop control variable must have ordinal type"

282 views
Skip to first unread message

Rolando Arnaudo

unread,
Dec 15, 2014, 1:13:21 PM12/15/14
to wst-...@googlegroups.com
Error on delphi 7 compile, "For loop control variable must have ordinal type".
in many functions like this:

function TranslateDotToDecimalSeperator(const Value: string) : string;
var
  i : PtrInt; <---ERROR must be a integer;
begin
  Result := Value;
  for i := 1 to length(Result) do begin
    if ( Result[i] = '.' ) then
      Result[i] := {$IFDEF HAS_DEFAULT_FORMAT_SETTINGS}DefaultFormatSettings.{$ENDIF}DecimalSeparator;
  end;
end;


How repair this error? Cannot solution with {$include wst_deplhi} have errors.

Juha Manninen

unread,
Jan 1, 2015, 11:54:45 AM1/1/15
to wst-...@googlegroups.com
On Monday, December 15, 2014 8:13:21 PM UTC+2, Rolando Arnaudo wrote:
Error on delphi 7 compile, "For loop control variable must have ordinal type".
in many functions like this:

function TranslateDotToDecimalSeperator(const Value: string) : string;
var
  i : PtrInt; <---ERROR must be a integer;
begin
  Result := Value;
  for i := 1 to length(Result) do begin
    if ( Result[i] = '.' ) then
      Result[i] := {$IFDEF HAS_DEFAULT_FORMAT_SETTINGS}DefaultFormatSettings.{$ENDIF}DecimalSeparator;
  end;
end;

It should clearly be an integer. I think you have Delphi 2007, not Delphi 7.
See wst_deplhi.inc :

    {$IF Declared(NativeUInt)}
      PtrInt  = NativeInt;
      PtrUInt = NativeUInt;
    {$ELSE} // old delphi
      PtrInt = Integer;
      PtrUInt = Cardinal;
    {$IFEND}

So, PtrInt = Integer for Delphi 7 but NativeInt for Delphi 2007, and NativeInt / NativeUInt seem to be buggy there.

Who will fix it? Inoussa, should I send a patch?
On choice is that you give me permission to fix clear bugs directly to CCR repo. I already have write access there.
I need a cross-solution for Delphi 2007 / FPC (Window + Linux) and WST seems to have many bugs!

Juha

Inoussa OUEDRAOGO

unread,
Jan 3, 2015, 9:02:14 AM1/3/15
to wst-list
Fixed.

Thanks.

--
Inoussa O.
Reply all
Reply to author
Forward
0 new messages