> On Jun 16, 2023, at 6:07 AM, Steve Litt via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> Is http://sprunge.us/MOJIg4 a legitimate use of a for loop with break? I
> know there are better ways to do it, but I'm just wondering whether
> it's legitimate.

What are you trying to do exactly? It's an array with a terminator string? 
Probably the length of the array should be set instead of doing string compares 
every loop.

program fordo;
var words: array[1..6] of string;
var ss: integer; 

begin
for ss := 1 to 6 do
   words[ss] := '~';

words[1] := 'One';
words[2] := 'Two';
words[3] := 'Three';

for ss := 1 to 6 do
   if words[ss] = '~' then
      break
   else
      write(words[ss], '    ');

writeln;
end.

Regards,
Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to