For Programmers: Free Programming Magazines  


Home > Archive > Delphi > March 2004 > For loop to while loop convet









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author For loop to while loop convet
Albert Truter

2004-03-27, 12:21 am

Hey all you Delphi Guru's, please help.

I need to convert the following For loop to a nested while loop.
I send programe with as attachment.

Thanks
Albert
alberttruter@webmail.co.za




procedure TfrmLooping.btnloopClick(Sender: TObject);
var
sString : String;
jIndex. iIndex : Integer;

begin
sString := edtStringInitial.Text;
for iIndex := sedStartFirst.Value to sedEndFirst.Value Do
begin
for jIndex := sedStartSecond.Value to sedEndSecond.Value Do
Begin
sString := sString + IntToStr(iIndex) + IntToStr(jIndex);
end;
end;
edtStringOutput.Text := sString;

end;
end.








Nicolai Hansen

2004-03-27, 12:21 am

procedure TfrmLooping.btnloopClick(Sender: TObject);
var
sString : String;
jIndex, iIndex : Integer;

begin
sString := edtStringInitial.Text;
iIndex:=sedStartFirst.Value;
while iIndex<=sedEndFirst.Value do
begin
jIndex:=sedStartSecond.Value;
while jIndex<=sedEndSecond.Value do
Begin
sString := sString + IntToStr(iIndex) + IntToStr(jIndex);
inc(jIndex);
end;
inc(iIndex);
end;
edtStringOutput.Text := sString;
end.
D. L. von Pontz

2004-03-27, 12:21 am

Thanks! Inspiring to me, on how code oughta look!

Nicolai Hansen wrote:

> procedure TfrmLooping.btnloopClick(Sender: TObject);
> var
> sString : String;
> jIndex, iIndex : Integer;
>
> begin
> sString := edtStringInitial.Text;
> iIndex:=sedStartFirst.Value;
> while iIndex<=sedEndFirst.Value do
> begin
> jIndex:=sedStartSecond.Value;
> while jIndex<=sedEndSecond.Value do
> Begin
> sString := sString + IntToStr(iIndex) + IntToStr(jIndex);
> inc(jIndex);
> end;
> inc(iIndex);
> end;
> edtStringOutput.Text := sString;
> end.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com