The following is a simple program on 'while ... do':

program dowhile;

{$APPTYPE CONSOLE}

uses
SysUtils,
Ourcrt;

Var
my_words: string;

begin
my_words:='';
writeln('Enter some words (type "stop" to finish):');
readln(my_words); while (my_words<>'stop')do
begin
clrscr;
writeln('You typed:');
writeln(my_words);
writeln;
writeln('Enter some words (type "stop" to finish):');
readln(my_words); end;
end.


My question is: The above program (the font in green color) and (the font in red color) are similar. I have try to make changes to the 'writeln ('Enter some words (type "fuck" to finish):'); but it only follow the original instruction. How can I understand it?

Cheers,

Do you think so ? :D

Program dowhile;

{$APPTYPE CONSOLE}

Uses
   SysUtils,
   Ourcrt;

Var
  my_words:string;

Begin
   my_words:='';

  {while the condition is true that my_words is not equal to 'stop'}
   While(my_words <> 'stop')Do Begin  {1}
      ClrScr;{clear the screen}
      {write the question to the user}
      Write('Enter some words (type "stop" to finish): ');
      ReadLn(my_words);{catch her/his answer}
      Write('You typed: ');
      WriteLn(my_words);{write the entered word/s}
      Sleep(2000);{sleeping a bit}
   End;  {end of (1) while ..do}

   {it is the same as above just a condition is else}
   While(my_words<>'****')Do Begin  {2}
      ClrScr;
      Write('Enter some words (type "****" to finish): ');
      ReadLn(my_words);
      Write('You typed: ');
      WriteLn(my_words);
      Sleep(2000);
   End; {end of (2) while..do}


   WriteLn;
   Write('Press enter to quit.');
   ReadLn;
End. {end of main program}

{
-=Fixed by FlamingClaw for turbomen=-
-=2009.04.28=-
}

I hope this code is helps to you to understand... :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.