[fpc-pascal] Illeagal assignment to For Loop variable in Free pascal

Ewald ewald at yellowcouch.org
Tue Jun 17 13:03:16 CEST 2014


On 17 Jun 2014, at 13:05, mokashe.ram wrote:

> Hi,
> 
> Could Any one help me for fixing below error in free pascal. as i am tring
> to excute for loop in decemental order using 'DOWNTO' but its thwoing error
> 'Illeagal assignment to For Loop variable 'Counter' as this is possible in
> TP but in Free pascal its not working so is there any workaround for this?
> 
>  FOR counter := 8 DOWNTO 1 DO
>              IF filename[counter] = ' 'THEN
>                 DELETE(filename,counter,1)
>              ELSE
>                  counter := 1;
> 

How about:
	Counter:= 8;
	While Counter >= 1 do
	Begin
		If .... Then 
			...
		Else
			Counter:= 1;	

		Counter-= 1;
	End;

?

Perhaps there is a switch that allows assignments to for-loop counters (although I doubt it), I don't know.

--
Ewald




More information about the fpc-pascal mailing list