next up previous
Next: Specific Structures for Forms Up: Handling HTML as Prolog Previous: General Structures

Specific Structures

 

In this section we will list the special structures for HTML which PiLLoW understands. A predicate html_expansion/2 is provided to define new structures.

With these additional structures, we can rewrite the previous example as follows (note that in this particular example the use of heading/2 or h2/1 is equally suitable):

#!/usr/local/bin/lpshell

:- use_module('/usr/local/src/pillow/pillow.pl').

main(_) :-
    get_form_input(Input),
    get_form_value(Input,person_name,Name),
    response(Name,Response),
    output_html([
        cgi_reply,
        start,
        title('Telephone database'),
        image('phone.gif'),
        heading(2,'Telephone database'),
        --,
        Response,
        end]).

response(Name, Response) :-
    form_empty_value(Name) ->
       Response = 'You have to provide a name.'
  ; phone(Name, Phone) ->
       Response = ['Telephone number of ',b(Name),': ',Phone]
  ; Response = ['No telephone number available for ',b(Name),'.'].

phone(daniel, '336-7448').
phone(manuel, '336-7435').
phone(sacha,  '543-5316').

We have not included above the specific structures for creating forms, they are included and explained in the following section.


next up previous
Next: Specific Structures for Forms Up: Handling HTML as Prolog Previous: General Structures

Daniel Cabeza Gras
Fri Oct 4 18:56:02 MET DST 1996