R
Rich Grise
Guest
On Mon, 17 Jan 2005 16:34:34 -0800, John Larkin wrote:
use "C", I'd just continue;.
Cheers!
Rich
I just didn't remember if Pascal had gotos or not. If I'd been allowed toOn Tue, 18 Jan 2005 00:06:42 GMT, Rich Grise <richgrise@example.net
wrote:
On Mon, 17 Jan 2005 21:44:08 +0000, Ken Smith wrote:
In article <1gqjkh3.1lx82l9ruvmaaN%bskb@m.a.c.com>,
Bjarne Bäckström <bskb@m.a.c.com> wrote:
Ken Smith <kensmith@green.rahul.net> wrote:
[...]
write('Q = '); readln(q); { Read in the values }
write('P = '); readln(p);
p := abs(p); { The sign doesn't matter }
q := abs(q);
if (p=0) and (q=0) then halt; { Don't use silly values }
That's BAD user interface!
repeat
flag := true;
write('Q = '); readln(q); { Read in the values }
write('P = '); readln(p);
if (p=0) and (q=0) then { Don't use silly values }
begin
writeln('Illegal value(s)');
writeln;
flag := false
end
until flag { = true } ;
That's worse because it doesn't giver the user an escape if he doesn't
happen to know some good values. In this case it is not much of an issue
but if the restrictions were tighter, this would be a very bad idea.
repeat
flag := true;
write('Q = '); readln(q);
if (q=0) or (q > 10000) then
begin
writeln('Q must be between 0 and 10000');
writeln;
flag := false
end
until flag;
repeat
flag := true;
write('P = '); readln(p);
if (p=0) or (p > 10000) then
begin
writeln('P must be between 0 and 10000');
writeln;
flag := false
end
until flag;
Cheers!
Rich
--
That's a lot of trouble to avoid a coupe of GOTOs. I never understood
the anti-GOTO religion.
use "C", I'd just continue;.
Cheers!
Rich