Re: Trouble with if statements

Posted by Joey p12386 on March 09, 2005

In Reply to: Re: Trouble with if statements posted by Al on March 08, 2005

Your code works fine in my version of Delphi (7 Personal) i think you must have a problem some where else.

I didnt know where you had your code but i put it in a console application and it worked as expected. To test it i added WriteLn(x, y) to see how many iterations of your looped passed and as expected 3 did.

Heres the full program code that worked fine:

program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
  numcol, numrow, x, y, row, col: Integer;
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;
        WriteLn(x, y); { print 910 to screen }
      end;
    end;
  end;
  ReadLn { here so i can see the output }
end.

I think you must have a problem some where else?

Joey ^__^


[ Delphi Tutorials -- by DelphiLand ]