Logo Blog Writing Program.

This program can be run as part of an online game or in its own right. It creates a basic webpage which then displays a blog. The blog is written using the predefined windows in Logo.

The program contains 5 elements.

cblog

This creates the blog. It gets the details of the blog from its creator and then sets up 3 files.
Note the use of se (sentence) to join "words" (basic logo building blocks) into longer blocks of text. The file operation commands are then used to write the file.
Make sure that you are writing to a extant directory! The easiest way to change the directory code is to open the whole blogwrit.lgo file in notepad and use find/replace in seek and destroy mode. (ie substitute N: for D:)

  1. blogwrap.htm This is the HTML container for the blog.
  2. blogtext.txt This is the text content of the blog.
  3. blogwrap.htm This is the blog content rendered into HTML.

to cblog
local "text
make "username questionbox [What is your Username?][What is your username?]
make "blogname questionbox :username [What is the name of your blog?]
make "blogcont questionbox :blogname [What is your blog about?]
make "title (se "<Title> :blogname ")
make "title1 (se "<h3> :blogname "</h3>)
make "title2 (se "Created "by :username "</p>)
make "blurb1 (se "<p>The "theme "of "this "blog "is :blogcont "</br>)
make "text (se :title1 :blurb1 :title2)
filewriter :text
htmlwriter :text
htmlwrapper :text
end

filewriter

This writes the basic text file that contains the updated blog. The main thing here is to put the new entries at the top of the file so that they appear at the top of the blog window. Nobody wants to scroll through th eold entries first.

to filewriter :text
openwrite "D:\\logogame\\blog\\blogtext.txt
setwrite "D:\\logogame\\blog\\blogtext.txt
print :text
setwrite[]
close "D:\\logogame\\blog\\blogtext.txt
end

htmlwriter

This code writes the blog in HTML format. It inserts the basic blog text into an HTML container so that it can be displayed.

to htmlwriter :text
openwrite "D:\\logogame\\blog\\blogtext.htm
setwrite "D:\\logogame\\blog\\blogtext.htm
print [<HTML>]
print [<HEAD>]
print [</HEAD>]
print [<BODY>]
print :text
print [</BODY>]
print [</HTML>]
setwrite[]
close "D:\\logogame\\blog\\blogtext.htm
end

htmlwrapper

This creates the HTML wrapper. It uses the iframe code to create a scrolling box to contain blogtext.htm

to htmlwrapper :text
openwrite "D:\\logogame\\blog\\blogwrap.htm
setwrite "D:\\logogame\\blog\\blogwrap.htm
print [<HTML>]
print [<HEAD>]
print :title
print [</HEAD>]
print [<BODY >]
print [<table border="1"><tr><td valign="top">]
print :text
print [</td><td valign="top">]
print [<p>These are the instructions for creating a blog using logo.</p>]
print [<ol>]
print [<li>Load and run Logo.</li>]
print [<li>Load blogwrit.lgo</li>]
print [<li>If you are going to create a new blog then run the procedure cblog. Note that this will erase all previous blogs unless you have adapted my code.</li>]
print [<li>Update the display of the blog by clicking refresh.</li>]
print [<li>To add an entry to the blog use joinblog</li></ol>]
print [</td></tr></table>]
print [<table><tr ><td>]
print [<iframe src="blogtext.htm" width="800" height="400" scrolling="auto" >]
print [</iframe>]
print [</td></tr></table>]
print [</BODY>]
print [</HTML>]
setwrite[]
close "D:\\logogame\\blog\\blogwrap.htm
end

joinblog

This allows subsequent users to add comments to the blog.
Note the do.until command which reads the whole of the present version of blogtext.txt into the blog behind th ecurrent entry. eofp stands for end of file pointer and it changes from false to true when the file reading software reaches the end of the file.

to joinblog
local "text local "newname make "newname questionbox [Hello, person adding to this blog.][What is your username?]
local "blurb
make "blurb (se "Hello :newname)
local "content
make "content questionbox :blurb [What do you want to add?]
make "text (se "<p> :content "</br>Added "by: :newname "</p> )
openread "D:\\logogame\\blog\\blogtext.txt
setread "D:\\logogame\\blog\\blogtext.txt
do.until [make "text se :text readlist ][eofp]
close "D:\\logogame\\blog\\blogtext.txt
openwrite "D:\\logogame\\blog\\blogtext.txt
setwrite "D:\\logogame\\blog\\blogtext.txt
print :text
setwrite[]
close "D:\\logogame\\blog\\blogtext.txt
htmlwriter :text
end

How to run the program

  1. Get all the code typed in as procedures within the main program blogwrit.lgo
  2. Make sure that the directory you are writing to exists and is the same in all 5 procedures.
  3. Run cblog
  4. Open your target directory and open blogwrap.htm in your web browser
  5. Modify the blog using joinblog
  6. To use this program in a game you will need to add these 5 procedures to your game code.
  7. You can make more than one blog provided that they have different filenames.

blogwrap demo

blogwrit.lgo

Last updated 23rd February 2010