Weblog Banner

Visual Rules

Throughout these pages, you will have noticed the stress on the key focal point, that Weblog is full Prolog which isable to run across the Web. The appearance of your Weblog applications is totally separate from the logic that drives them, so that you can design pages any way you like, and then create the content using uncluttered, natural code.

What has not been stressed, so far, is the corollary: a happy side-effect of this true "prologness", is that other toolkits and systems, written in Prolog, will also run naturally on Weblog. One such toolkit is VisiRule 2 ...

Grass for All

VisiRule 2

VisiRule 2 (VR2) is a prototype replacement for the current VisiRule business rules program tookit; unlike the current version, VR2 compiles directly down to Prolog, and consequently, runs very happily in Weblog.

Taking an existing VisiRule example, modified and compiled in VR2, this present application runs a version of the "Lawns" expert system, which aims to advise you on how to improve that patch of grass in your rear garden.

There is not a lot to say about the application itself, other than that it was compiled directly from the VR2 chart shown below. The Lawns Advisor comprises a series binary questions about the state of your lawn, asking you questions and following through the logic to an appropriate conclusion, which is returned as a Prolog string. It is the text of these questions and the final string which is shown on the web pages.

VisiRule 2

Weaving the Dream

Apart from an advance glimpse of VisiRule 2, the other feature of this example is that its web page was generated in one of the most popular website development programs, Adobe DreamWeaver.

DreamWeaver is very much like a desktop publishing program, enabling you to play with website designs in a "WYSIWYG" fashion, without every having to get into direct HTML editing, unless you particularly wish so to do. When you want to place a Weblog "{:label:}", all you need to do is type its name in between those curly/colon brackets.

The actual HTML generated by DreamWeaver tends to be a little messy to read in its raw form, so on this occasion, the file will not be listed here. However, the file is essentially in the same format as all the other examples you have seen, complete with a "<form>" element which provides the interaction with Weblog.

Keep Off Grass

A Modicum of Help

As noted above, VisiRule 2 is currently in a prototype state, and as such, does not yet have a complete web interface. However, as this particular example, the Lawns Advisor, is relatively simple, it took only a couple of special predicates to be written to get it running. First up is weblog/0, which here does nothing more than call the compiled, VR2 program, "lawn/3", before displaying the response with submit/2.

% call the grass example and display the result

weblog :-
   lawn( start, [], Answer ),
   submit( 'grass_2.htm', [(answer,Answer)] ).

And here is a part which will not be necessary in due course, providing a "dialog" interface which calls submit/2 to display the query page, followed by getarg/2 to collect the response, and a "button" interface which enumerates the choices offered.

% simplified response dialog

vsr_dialog( [], [], Answer, _, Answer ).

% simplified question dialog

vsr_dialog( [], Choices, (Name,Question), _, Response ) :-
   vsr_buttons( Choices, Buttons ),
   submit( 'grass_1.htm',
          [ (buttons,Buttons),
   getarg( response, Response ).

% convert a list of options into html

vsr_buttons( Choices, Buttons ) :-
   forall( member( Item, Choices ),
           (  swrite( `<input type="submit" name="response" value="` ),
              swrite( Item ),
              swrite( `"/>~M~J` )
         ) ~> Buttons.

Click here to run the "Lawns" example

Click on the buttons to find out more, or jump directly to any of these links:

Weblog Previous Next
Direct LinkExample Name
One Shot Program"Hello World"
Input and Backtracking"Bonjour Le Monde"
Learning and Storage"Teach Me"
Flexible Output"John Likes Mary"
Tables and Forms"Family Tree"
Photoshop and Images"Lunar Phase"
Illustrator and Prolog"Big Ben Time Check"
DreamWeaver and VisiRule 2"Lawns"