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

Jim Leonard trixter at oldskool.org
Wed Jun 18 04:54:52 CEST 2014


The error is because FreePascal optimizes loops wherever it can, and 
trying to modify the loop variable would break under that optimization.

While you could enable compilation flags to make things more TP 
compatible, looking at the code, I can see that the 'counter:=1' is just 
an early termination clause.  If the variable 'counter' isn't needed 
after that section, you could replace that line with 'break' which would 
exit the loop immediately (which is what the code does now).

On 6/17/2014 6:05 AM, 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;
>
> Thanks
> Sudarshan
>
>
>
> --
> View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Illeagal-assignment-to-For-Loop-variable-in-Free-pascal-tp5719603.html
> Sent from the Free Pascal - General mailing list archive at Nabble.com.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>


-- 
Jim Leonard (trixter at oldskool.org)
Check out some trippy MindCandy: http://www.mindcandydvd.com/
A child borne of the home computer wars: http://trixter.oldskool.org/
You're all insane and trying to steal my magic bag!



More information about the fpc-pascal mailing list