Trouble with Delphi if statements

Posted by Mandy on March 06, 2005

Hello
I apologise in advance for posting what is probably a very easy question but it has been driving me crazy so here goes...
Below is a simplified version of some code I wrote, but it seems that if the if statement is true (in this case col=2) then it executes the following statements (x=, y=) but doesn't execute the first "end" that should be associated with the "if then begin" and instead jumps to the second "end", displacing everything so that the "end" of the "row" for-loop ends up being the overall program end ("end.") So what's wrong with my syntax?
Thanks
Mandy

begin
numcol:=2;
numrow:=3;
x:=0;
y:=0;
for row:=1 to numrow do
begin
for col:=1 to numcol do
begin
if col=2 then
begin
x:=9;
y:=10;
end;
end;
end;

end.

Related Articles and Replies


[ Delphi Tutorials -- by DelphiLand ]