Hi.

Index variable can neither be initialized nor computed. Read https://wiki.lazarus.freepascal.org/FOR..DO

Antonio

Le 09/09/2019 à 11:30, James Richters a écrit :
Can someone please tell me why this happens?

Var
    I : Longint = 0;
Begin
For I := 1 to 6 Do
    Writeln(I);
End.

This gives me :
initialize.pas(4,5) Error: Illegal counter variable
initialize.pas(6,4) Fatal: There were 1 errors compiling module, stopping
initialize.pas(0) Fatal: Compilation aborted

but this works fine:
Var
    I : Longint;
Begin
I := 0;
For I := 1 to 6 Do
    Writeln(I);
End.

Shouldn't these two programs be identical?  What difference does it make if I 
initialize the variable in the Var section?

James
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to