Terrapin Resources

Files, Folders, and Locations

The Logo Workspace

The first time you started Logo, there was no SQUARE command. After all the work you’ve done, you wouldn’t want to lose it and have to start all over again, would you? If you save your workspace before quitting Logo, then the next time you start Logo, you can load it back and be right back where you were.

What’s the workspace in Logo? It’s simply that part of Logo that contains your procedures. (There is really a bit more to it but don’t worry about that for now.)

Why save the workspace? Organization! You can have many workspace files, one for each project. When you work on a project about one thing, you don’t want your workspace cluttered up with procedures from something else. Your workspace could get pretty messy.

Your menu contains two items for loading and saving your data. Each menu item opens a dialog where you can select what to load or to save. These menu items will always load from, and save to, your local drive.

Several Logo commands accept a file name as input. This section is an introduction to the way handles file names, disk files, and files located on an Internet server.

Path names

As a computer user, you are familiar with the concept of folders and files. A folder contains files, and often other folders. When you click a folder name, the folder opens and displays its content.

To make a file name specific, it needs to be at the end of a so-called path, which is a list of folders that leads to the file itself. Here is a Windows path:

C:\Users\someone\Documents\MyFile.lgo

Which makes the file MyFile.lgo reside inside the folder Documents. That folder finds itself inside the folder someone, which is inside the folder Users, which is located on drive C. You get the idea.

Other operating systems most often use the slash instead of the backslash character. Here is a typical path on Mac OS:

/Volumes/Macintosh HD/Users/someone/Documents/MyFile.lgo

Windows uses drive letters, while the Mac, for example, uses the name of the hard disk to start a path.

The Internet uses a different approach, for example:

https://www.somecomputer.com/Users/someone/Documents/MyFile.lgo

Here, the path name starts with the a protocol specifier, which is https://. Don’t worry about that part; modern browsers do not even display that part anymore. What follows is the server name, which would be www.somecomputer.com. Then, the path name of the file on that server follows. There could be more, like a question mark plus a lot of characters, which is just additional info for the server.

Internet paths (the part behind the computer name) are case sensitive, which is not the case for Windows and Mac computers. Also, you can in most cases not look at the contents of a folder located on a server.

In this manual, we use the terms “directory” and “folder”, and both mean the same.

Logo paths

Logo paths are much like all other paths, but sonce Logo runs on a lot of operating systems, a Logo path starts with a file system specifier that is unique to Logo. Disk file paths always start with the name ~PC to tell Logo to look for a file on disk. Internet paths start with ~HTTP or ~HTTPS. Paths to toolbox images and sounds start with ~HOME.

Since all of these prefixes refer to different locations with different conventions, Logo uses the term “File System” for each location. For example, the file sytem PC lets you read and write disk files, but with several limitations. The file system HOME does not let you write, but offers lists of folder contents, while HTTPS does not let you list folder contents.

To maintain compatibility with Internet paths, Logo also accepts the Internet way of specifying a protocol. Instead of ~PC, you could also use pc://, and instead of ~HTTPS, you can use ‘ https://`.

You are free to use Logo uppercase characters, except for Internet paths, which remain case sentivie. The path separator is the slash. Here is a Logo path:

~HOME/TOOLBOX/ANIMALS/APE.PNG

Which refers to the “Ape” picture in the Toolbox.

BUT: The path

“https://www.terrapinlogo.com/products/robots/beebot-ss.html

is very different from

https://www.terrapinlogo.com/products/robots/beebot-ss.html

Because Logo would convert the former to uppercase, that path woukld really be

HTTPS://WWW.TERRAPINLOGO.COM/PRODUCTS/ROBOTS/BEEBOT-SS.HTML

which is very different from the latter path, because Internet paths are case sensitive.

Hint: When you drag a picture from the Toolbox to the Editor or Listener panels, Logo copies the Logo path of that picture.

If a Logo path ends with a slash, Logo assumes that you mean a folder and not a file. The “Animals” folder in the Toolbox is, therefore:

~HOME/TOOLBOX/ANIMALS/

The Current Folder

To avoid having to type an entire path name repeatedly, Logo has the concept of a current folder. This is eseentially a path name that Logo prepends to a path name when it does not start with a file system name, nor a slash character.

When Logo starts up, the current folder is set to ~PC/. This means that the active file system is your local hard disk. Assume that you change the current folder to, say, ~HOME/TOOLBOX, then you can refer to the APE.PNG file above simply as ANIMALS/APE.PNG. Logo sees that this path does not begin with a slash or a file system name, so it automatically prepends the path with ~HOME/TOOLBOX, making it ~HOME/TOOLBOX/ANIMALS/APE.PNG.

If you use just a path name without a leading slash, Logo assumes that it needs to use the current folder as the starting point, just as described above. The path that you use is called a relative path, because the location is relatrivew to the current folder.

If you let a path start with a slash, Logo will not use the current folder, but just the cueetn file system. If your current folder points to somwehere inside the ~HOME file system (as in ~HOME/TOOLBOX), the path /SOUNDS/AHHA.MP3 would refer to the path ~HOME/SOUNDS/AHHA.MP3. This is called an absolute path.

The SETCURDIR is the command that you use to change the current folder. Note that for file systems other than PC, the command does not check if the path that you entered actually exists. It only helps you to specify the starting portion of your path name. You will see if the file that the full path name exists when you attempt to access it!

The PC file system is different; please read on for more information.

The CURDIR command reports the current folder.

Logo will remember the current folder across page reloads until you log off.

Each file system has its own current folder. You can easily switch file systems by using SETCURDIR with just the file system name:

SETCURDIR “~HOME SETCURDIR “~PC

Root Folders

A root folder is usually the top-level folder of a path. Here are some examples:

~HOME/ https://www.terrapinlogo.com/ ~PC/

Note the trailing slash. The latter, however, is quite different. Read on.

Disk Files

A browser-based program like Logo has certain limits when it comes to disk access, which are based on security concerns. Imagine what could happen if just any web page would be allowed to read and write files on your disk at will?

Therefore, Logo has to ask you nicely before accessing any disk file system.

The first time you want to access a disk file, like loading a Logo program, or checking the current folder, Logo will ask you to pick a folder that will act as a root folder for later file or folder access. You might think that this would be drive C, but for security reasons, you will actually need to select a folder, like your Documents folder, as the root where Logo will start looking for files.

After selecting a root folder, the browser will again ask you if it is OK for Logo to access the contents of that folder.

If you, for example would select a folder “Terrapin Logo”, the outcome of a CURDIR command would be

~PC/Terrapin Logo

Logo always remembers the file system’s root folder together the the current folder until you log off.

As soon as you have established the root folder, you can access folders and files within that folder without Logo having to ask you again. If you, for example, issued the command LOAD "MYFILE, Logo would try to load the file MYFILE.LGO from inside the root folder.

What if you would like to change the root folder?, Well, use (SETCURDIR) without any inputs.

There is another convenient way to change the root folder; just use an absolute path. For example, if you use the path name JOE/HISFILE.LGO, Logo would look up the file inside the current folder, because it is a relative path. If you use the path /JOE/HISFILE.LGO with a leading slash as an absolute path name, Logo would again ask you to select the folder JOE, which would become the new root folder, even if the file where you asked for did not exist. Also, the folder name could different from “JOE” if you selected a different folder.

There are more ways to ask Logo to display a file picker. For example, omit the path to load from or to save to entirely, or use the empty word or the empty list as path name. This would display the contents of the current folder.

You can also use file filters. This is a list of file extensions that you supply to limit the display of the files to files with these extensions. This is handy if you, for example, want the user to select a picture. In this case, you would supply a filter that limits the list to image files.

If you, for example, only want to display certain image files, you can do this:

LOADPIC [JPG PNG]

~HOME: The Toolbox and Sounds Folders

The HOME file system is located on the Terrapin server. It is read only and contains sounds and images for you to use. The Toolbox panel acts as a window into that file system service. To tell the truth, the Toolbox panel also contains views for controls and colors, which are not part of the HOME file system.

In previous versions of Terrapin Logo, the ~HOME prefix referenced a disk location, so we kept that name for backwards compatibility.

The Toolbox images that you see are part of the ~HOME/TOOLBOX folder, and all images are .PNG files. You already know that you could change the shape of your turtle to an ape just by selecting the Toolbox “Animals” folder, dragging the picture of an ape over to your turtle and dropping it there. If you want to do this from within a Logo program, you can use the LOADSHAPE command to load the ape as a turtle shape like this:

How do you get to these path names? Simply drag the Toolbox image that you’d like to refer to into the Listener or Editor panels, and Logo will drop the path name of the image or sound for you to use.