[Oberon] Removing RETURN from Mail.MatchQuery.
peter at easthope.ca
peter at easthope.ca
Mon Jan 1 16:48:31 CET 2024
Hi,
In A2, Oberon.Mail.Mod has procedure MatchQuery.
https://en.wikibooks.org/wiki/Oberon/A2/Oberon.Mail.Mod#MatchQuery
The second half of the procedure is a LOOP occupying most of the display
of my browser. Within the LOOP is a RETURN.
For Oberon-07 conformance the RETURN must be removed. My reasoning
followed these steps.
(1) Invert the IF statement. Ie. change IF Q.root.eval to IF ~Q.root.eval.
That leaves RETURN just before the end of the procedure.
(2) Change LOOP to WHILE ~Q.root.eval and move the RETURN outside the
END of the loop.
This is my result from LOOP to the end of the procedure.
(* LOOP *) WHILE ~Q.root.eval DO
REPEAT
i := 0; cond := Q.conds; (* evaluate logical ops *)
WHILE cond # NIL DO
IF cond IS Node THEN
WITH cond: Node DO
IF ~cond.eval THEN
IF cond.left.eval & cond.right.eval THEN
IF cond.op = or THEN (* OR *)
cond.value := cond.left.value OR cond.right.value
ELSIF cond.op = and THEN (* AND *)
cond.value := cond.left.value & cond.right.value
ELSE
HALT(99)
END;
cond.eval := TRUE; INC(i)
ELSIF (cond.op = or) & ((cond.left.eval & cond.left.value) OR (cond.right.eval & cond.right.value)) THEN
cond.value := TRUE; cond.eval := TRUE; cond.left.eval := TRUE; cond.right.eval := TRUE; INC(i)
ELSIF (cond.op = and) & ((cond.left.eval & ~cond.left.value) OR (cond.right.eval & ~cond.right.value)) THEN
cond.value := FALSE; cond.eval := TRUE; cond.left.eval := TRUE; cond.right.eval := TRUE; INC(i)
END
END
END
END;
cond := cond.next
END
UNTIL Q.root.eval OR (i <= 0);
IF ~Q.root.eval THEN
IF txt THEN
cond := Q.conds;
WHILE cond # NIL DO
IF (cond.field = text) & ~cond.eval THEN
cond.value := TextSearch(cond, no);
cond.eval := TRUE
END;
cond := cond.next
END
ELSE
HALT(99)
END
ELSE (* Q.root.eval *)
END
END; (* LOOP, WHILE *)
RETURN Q.root.value
END MatchQuery;
--
VoIP: +1 604 670 0140
work: https://en.wikibooks.org/wiki/User:PeterEasthope
More information about the Oberon
mailing list