AUTO-COMPLETE(P)
1. let repositoryCOLLECT-KNOWN-VALUES
2. if VERIFY-CHECK-CODES(P)FALSE
3. while CHANGE(repository)= TRUE do
4. foreachdo
5. if CHECK-MODE-CHECK-CODE()
FALSE
6. foreachof
do
7. if CHECK-MODE-GUARD()
FALSE
8. if EVALUATE-GUARD()
FALSE
9. if CHECK-MODE-RULE()
FALSE
10. TRIGGER-RULE()
11. if VERIFY-CHECK-CODES(P)FALSE
12. then UPDATE(repository) (with rule trigger field)
13. break(from loop in line 6)
14. else RETRACT(repository)
15. return
16. return
17. end-while
The algorithm keeps track of known form fields by means
of a repository. The repository is initialised (line 1) and
all check-codes are verified before the start of the while-loop
(line 2). The
loop starts with a list of predicates P(line 4).
For any predicate
, if any of the check-code mode fields
are not known, then it becomes a candidate for rule triggers (line
5). All rules of that predicate are then checked for rule
triggers(line 6). If the guard for a rule (
) is not
empty2,
then the guard mode is checked for the existence of field values
that are
required to evaluate the guard (line 7). If the mode is satisfied
then the guard is evaluated (line 8). If a guard is
satisfied (evaluates to true) then a check is made on the rule
mode (line 9). If all the fields of a rule mode are known, a rule
is triggered (line 10). All the
check-codes are run to ensure that
check-codes are satisfied (line 11). If the check-codes are
not satisfied the value is retracted (line 14) otherwise it is
added to the repository (line 12). The next predicate is then
chosen for rule trigger (line 13). The while-loop (line 3-17)
terminates if in the last
iteration there was no rule trigger (line 3). If field formats are
specified, then they are taken into account (line 2,10).
In line 2, all field values are checked against
their specified field formats whereas in line 10, the deduced
field
value is checked for its conformance to the specified field format.
The algorithm for auto-update is similar except for the fact that when a user updates an existing value all the deduced values are removed from the repository and new values are then computed by the algorithm given above. If metainfo is specified then it is taken into account at this stage.