cause:-
    foreach(recorded(cause,CAUSE,_),
            (foreach(recorded(inferbase,[[CAUSE,_],[CONS,_]],_),
                     explaincause(CONS)))),!,
    recorda(data,[cause,true],REF).


explaincause(CONS):-
    foreach(recorded(inferbase,[[CONS,_],[ANTE,VALUE]],_),
            (fileinfo([ANTE,VALUE],'$ttss/advice'),
             explaincause(ANTE))).

fileinfo(Key,File) :-
        see(File),
        repeat,
        read(Y),
        ( Y = end_of_file,
              seen
          ;
              once(showinfo(Y,Key)),
              fail
        ).

once(X) :- call(X),!.

/* look for comment brackets - call readinfo if found */
showinfo(X,X) :- hget(47),get0(42),hget(C),readinfo(C).
showinfo(X,X) :- print('eeek'), nl.

/* display everything up to comment brackets - argument is previous char
   read from file */
readinfo(42) :- !,get0(Y),(Y=47;put(42),readinfo(Y)).
readinfo(Y)  :-  !,put(Y),hget(Z),readinfo(Z).

/* read up to next instance of C, fail on end of file */
hget(C) :- repeat,get0(D),(D=26,!,fail;D=C),!.
