Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2023-01

For Loop with QWord

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

James Richters
I'm wondering why I can't have the following:
Var
  I: QWord;
Begin
  For I := 1 To N Do
     .

It generates an error:
Error: Ordinal expression expected

If I change it to LongInt, then it works, but the question is, why can't I use a Qword here if I know I will never need I to be a negative number?

James

Reply by email

Bart
to James Richters
PM James Richters wrote 10 lines
Var I: QWord; Begin For I := 1 To N Do It generates an error: Error: Ordinal expression expected If I change it to LongInt, then it works, but the question is, why can’t I use a Qword here if I know I will never need I to be a negative number?

IIRC then you can only use native type or smaller as a loop variable in for loop.
You can use it in a while or repeat loop though.
On 64-bit you can use qword as a loop variable in a for loop.

Bart

Reply by email