Logo File Operations.

Logo can write and read from files. These commands can generate quite tricky errors if things go wrong. They will also overwrite any previous files of the same name.
YOU HAVE BEEN WARNED!

These commands could be used to write files to share between users over a network. This would enable the development of multi-player games. They can also be used to save data and parameters generated by programs.

These commands can be found in the Communication/File Access section of the Help file.

File Writer.

This program write a file called test.txt to the N: directory. You will need to alter the directory name if you don't have a drive N: that you can write to.
NB: This won't work with filenames longer than 8 letters.
It requires an input in the form of a block of text.

to filewriter :text
make "cnt count :text
openwrite "N:\\test.txt
setwrite "N:\\test.txt
repeat :cnt [print item repcount :text]
setwrite[]
close "N:\\test.txt
end

File Reader.

This program reads a file called test.txt from the N: directory. You will need to alter the directory name if you don't have a drive N: that you can write to.
NB: This won't work with filenames longer than 8 letters.

to filereader
openread "N:\\test.txt
setread "N:\\test.txt
repeat 10 [show readlist]
close "N:\\test.txt
end

HTML Writer

This generates a very basic HTML page.
This could be a useful interface component for an online interactive game. The LOGO program could outpu to this file which several users share. They would need to click refresh to obtain the latest update to the game.

to htmlwriter
openwrite "N:\\test.htm
setwrite "N:\\test.htm
print [< html >]
print [< HEAD >]
print [< TITLE > A Basic Webpage < /TITLE>]
print [< /HEAD >]
print [< BODY >]
print [< p > This is a basic HTML page < /p > ]
print [< /BODY >]
print [< /HTML >]
setwrite[]
close "N:\\test.htm
end

Make sure that you have an N: drive that you can write to. Use your browser to view the result.

Last updated 23rd February 2010