According to FPL:
I think this program is a better example of what the problem is. It is not as artificial as the prior one, and can be executed without gdb so that one can see the problem may lie somewhere else that in debugging informations.
program loop2(input, output); var i, j : integer;
begin j:=0; repeat for i:=0 to 10 do if (i div 2)=0 then begin write('*'); j:=j+1; end; writeln; until j=10; end.
Do you agree the output should be a rectangular array of 5 stars by ten,
No. For each run of the `repeat' loop, only one star (for i = 0) is printed.
Perhaps you mean `if i mod 2 = 0'?
Well, what *I* get when running the output code is
... correct. ;-)
Also, I have (in the other program) some file of text type ever opened, and I have noticed in applying your advice that GPC complains it cannot write on the default output device (the screen) because of my opened file. Just a writeln('*') and *not* a writeln(f, '*') wille make it say
?GPC runtime error: File is not open for writing (#9)
This sounds strange and *maybe* indicates a bug. How did you open the file?
The following should work:
Assign ( MyFile, 'filename.txt' ); rewrite ( MyFile ); writeln ( 'Hello?' ); writeln ( MyFile, 'Hello!' ); close ( MyFile );
Greetings,
Peter