[fpc-devel] Declare variables inside the code

Vinzent Höfler JeLlyFish.software at gmx.net
Wed May 11 22:01:35 CEST 2011


On Wed, 11 May 2011 12:07:31 +0200, Hans-Peter Diettrich  
<DrDiettrich1 at aol.com> wrote:

> kingbizugo at gmail.com schrieb:
>
>> I would like to be able this:
>> [ some code after begin ]
>> DoSomething;
>> var I: Integer;
>> for I := 0 to 1000 do
>> DoAnotherThing(I);
>> [ inside the code ]
>
> That's not good practice, in no programming language.
>
> Better move the loop into a local procedure, where you can declare  
> really local variables.

Or make the loop variable completely implicit and thus 100% local to
the loop.

|for i : integer := 0 to 1000 do ...;


Vinzent.



More information about the fpc-devel mailing list