This doesn't compile, but should it?

Thanks Donald,

I found Marc’s explanation here . At least I know it’s not me,

The way Elements handles ifdefs in v10 is that each IFDEF must be its own logical structure. you can nest an IFDEF in another code structure, or you can nest an other code structure inside Ean IFDEF, but you cannot have them “overlap”, say, as below.

{$IFDEF X}
for x := 0 to 5 do begin
do stuff
{$ENDIF}
do more stuff
{$IFDEF X}
end;
{$ENDIF}

The for loop must be inside the ifdef or the ifdef must be inside the for loop. That’s because in Elements, IFDEFs become regular code structures (because you can also write then using “ if defined("X") ”).

1 Like