Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

Logo Packages

Often, a Logo program needs additional resources, like sounds or images. When you distribute a Logo program, you cannot rely on these resources to be present on the target computer.

Fortunately, Terrapin Logo 4 can help you. Version 4 of Terrapin Logo can load entire Zip file archives that may contain any number of Logo files, images, and other resources. If you rename the file extension of such an archive file from Zip to logobin, you can even double-click such a file, and Logo launches and executes the programs stored inside that archive.

When Logo loads a package file, it sets the current folder to the loaded file’s folder. This is mostly irrelevant for zipped archive files, but important for Logo source files. Also, it remembers the path of the archive file, and tries to load files from that archive if it cannot find a file on disk.

Of course, nothing is as easy as it seems to be. Several restrictions apply that must be kept in mind if you create a Zip archive file.

1. Make sure to keep your Logo files at toplevel

A Zip archive can contain subfolders, but Logo only auto-loads Logo files that it finds at the Zip archive’s top level. Therefore, make sure that you do not zip a folder containing your Logo program and its resources, but rather all files inside your program folder.

Logo can load files out of subfolders inside a Zip archive just fine if you specify the full path name of the file. See the example below.

2. Define a MAIN procedure

When Logo scans a Zip archive for Logo files, it loads these files in any order they happen to be. Logo defines the procedures and runs all top level code in each file as it loads them. If your Logo files contain top-level commands as your program, Logo may run them before all files have been loaded, and parts of your program may not be ready to execute. Therefore, you must bundle your program commands in a procedure called MAIN. After Logo has loaded all Logo files and run all top-level commands, Logo looks up the MAIN procedure and runs it, which would be your program. If Logo does not find a procedure named MAIN, it displays an error message and exits.

3. Use relative file path references

Logo cannot treat folders inside a Zip file as normal folders. Therefore, folder commands like DIRECTORY or SETCURDIR do not work for Zip files. You can, however, use relative paths to address your files inside a Zip archive. This command:

would load the shape MOOSE.BMP out of a zipped folder SHAPES inside the Zip file.

Q&A

  • How do I debug my program? Load and run your LGO files normally, but make sure to use the SETCURDIR command to set the current folder to the folder that you intend to archive so relative path references work before you run your procedures.

  • Can I use LOAD to load a Zip archive? Yes. Logo does not exit if a runtime error occurs, but will handle the error as usual. Logo will still attempt to run MAIN.

  • How does Logo load zipped files? All commands that open or load files first attempt to load or open the file from the current directory (Logo’s CURDIR). If not found, then Logo would look inside the last loaded Zip archive file.
    Every time you load a Zip archive, Logo remembers the name of that file as an additional location to search for files. Logo only remembers the last loaded file, so every new load of a Zip file makes Logo forget the location of any previously loaded Zip files.

  • How does Logo handle runtime errors? For double-clicked Zip archives, Logo displays an error message dialog and exits. For Zip files loaded with the LOAD command, Logo stops and displays the usual error dialog.

  • What is the difference between the “zip” and “logobin” extensions? Both extensions are Zip file archives. To have your operating system connect a certain file type to a program, it requires a unique extension. Therefore, Logo registers the extension logobin so a double-click on a logobin file opens Logo instead of your favorite Zip file handler.