#!/usr/local/bin/prologcgi

:-s_charset(_,utf8).
top_call:-
    reconsult('mojidata.pl'),
    html_call([
    "Content-Type: text/html; charset=utf-8

     <html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>
     <body><center><H1>ＡＢＣフォントの学習データ</H1>
     <a href='puttxt.exe?mojidata.pl' target='source'>生データ表示</a>
     <a href='puttxt.exe?disp_abc.cgi' target='source'>このページのソース表示</a><br> 
     <INPUT TYPE='button' VALUE='RETURN' onClick='history.back()'><br><br>
     <font size=8>",
        call(d([1,0,0],'A')),            %% Prolog Call 
        call(d([0,1,0],'B')),            %% Prolog Call 
        call(d([0,0,1],'C')),            %% Prolog Call 
    "</font></center></body></html>" ]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

d(Type,Disp):-
    e_register(1,_,1),
    write_listnl(['<H1>',Disp,'</H1><table  border="2" cellpadding="3" cellspacing="0" width="95%"><tr>']),
    data(List,Type),                                % reconsulted data 
        e_register(1,N,N+1),
        write_list(['<td> No.',N]),
           disp(35,List),                           % Display One Pattern
        kugiri(N,'</tr><tr>',P),
        write_listnl(['</td>',P]),
    fail.
d(_,_):- write('</tr></table>'),nl.

disp(_,[]):-!.
disp(N,[A|L]):- kugiri(N,'<br>',P),dispChar(A,X),write_list([P,X]),NN is N-1,disp(NN,L).

dispChar(0.0,'□'):-!.
dispChar(1.0,'■').

kugiri(N,Pattern,Pattern):- 0 is N mod 5,!,nl.
kugiri(_,_,'').
