Weblog Banner

One Shot Program: "Hello World"

Let's jump right in with the simplest of all examples, a "Hello World!" program. As with all Weblog applicatons, you need just two things: an HTML page and a Prolog program.


The HTML page can be as simple or as complex as you like, whether written by hand or using a web development tool such as DreamWeaver. Within the page, you can add Weblog "labels", which act as placeholders for information that will be returned by the Prolog program. Here is an example, "hello_1.htm":


    <title>Hello World Example</title>



Labels in Weblog are just text names, surrounded by the special brackets, "{:" and ":}"; in the example above, there is just one label, whose name is "hello". When the Weblog application completes its work, this label will be replaced with whatever text the program supplies.

weblog :- ? ...

The "weblog/0" and "submit/2" Predicates

Your application can do absolutely anything you want: think "blue sky", and you get the idea. The only fixed thing, is that whatever it does, your program should be called "weblog/0".

Just think, "weblog :- anything_at_all.", and you will be in the right zone.

When it comes to displaying the results of your blue sky application, you just call "submit/2" to combine your HTML web page with one or more pieces of data that your program has created, pairing your data with Prolog atoms which match the labels on the page.

In the simplest case of all, all that your program needs to do is call "submit/2" directly from within your defininition of "weblog/0", for example:

weblog :-
   submit( 'hello_1.htm', [(hello,`Hello World!`)] ).

OK, so this is a minimalist program, but it works! The weblog/0 program does nothing other than call "submit/2", to display the HTML file, "hello_1.htm", with the label, "{:hello:}" replaced with the text string, "`Hello World!`".

The Basics of Weblog

So far, you have seen the very basics of Weblog: combining an HTML page with a matched Prolog program, and displaying the result. Next, you'll see how to process input from a web page, and also demonstrate backtracking.

Click here to run the "Hello World" 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"