Where are my files?
We live in modern times. The traditional desktop PC slowly fades away. Your file storage is not limited to your local disk anymore; your files may live on a memory chip or on some cloud storage.
Files and Folders
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 contains a list of folders that leads to the file itself. Here is a Windows path:
Other operating systems most often use the slash instead of the backslash character. Here is a typical path on Mac OS:
Most os the paths are identical; the first part is different and varies from OS to OS. Windows uses drive letters, whilc the Mac, for example, uses the name of the hard disk to start a path.
The Internet uses a different approach, for eample:
Here, the path name starts with the computer name; also, Internet paths (the part behind the computer name) is case sensitive, which is not the case for Windows and Mac computers.
Specifically, an Internet address is still a path, but the path elements may or may not exist on the computer’s disk; it is up to the computer how the path is interpreted. This means that you usually cannot list the contents of a folder for an Internet path.
In an Internet application, the meaning of a folder In this manual, we use the terms “directory” and “folder”, and both mean the same.
Logo introduces the concept of storages. A storage is a file system, and covers a specific location, either on your hard drive, or somewhere else. Storages are responsible for all file I/O to this location.
As a result, some storages may not be able to perform certain I/O operations. Some may, for example, be read-only. A storage name is always the first part of a path, and its first character is always the tilde (~) character.
Terrapin Logo comes with five built-in storages:
- ~PC is your own hard disk.
- ~HOME is the location for all Toolbox files.
- ~FILES is a special file system inside Terrapin Logo for you to use.
- ~HTTP and ~HTTPS refer to Internet locations.
We’ll explain these storages more in depth later.
A Logo path starts with the storage name, followed by the path itself. Most storages are case-insensitive, so you are free to use Logo uppercase characters. The path separator is the slash. Here is a Logo path:
Which refers to the “Ape” picture in the Toolbox.
Hint: When you drag a picture from the Toolbox to the Editor or Listener panels, Logo copies the pictures Logo path.
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:
If Logo knows that a certain path is a folder, you can leave the trailing
slash off; for example, since Logo knows that
~HOME/ is a folder, you
can safely use
You can use special folder names as part of path names. The special
. references the current folder, and the folder name
references the parent folder inside that path. If your current folder is
example, the path name
../MAIN.LGO points to a file in
If you attempt to load or read a folder, Logo will display a dialog that lets
you select a file from that folder. The
~PC storage will, for security reasons,
always display a file picker dialog. If you want to load a picture from a folder
like in the command
LOADPIC ~HOME, Logo will open a file picker dialog that
lets you select a file from the ~HOME storage.
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.
SAVE " (SAVE)
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.
Note: The following examples use the
LOADPIC command, which already
knows how to limit the selection of files to images. The command is used
to show the usage of file filters here.
If you, for example, only want to display certain image files, you can do this:
LOADPIC [JPG PNG]
Since you cannot know which image types your browser supports, there is
a special “extension”
IMAGES that you can use to make Logo display all
Note that if you use an asterisk
*, it means to display all files.
This is a “leftover” from Terrapin Logo 4, where you could use special
type lists to specify which files to display. Logo supports these lists
for backwards compatibility, but their use is not recommended anymore.
Mostly, Logo path names are not case sensitive. It often does not matter
whether you use “Toolbox” or “TOOLBOX”; Logo finds the file or folder
regardless of the case of the case letters. The
are canse sensitive, however.
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 storage name, nor a slash character.
When Logo starts up, the current folder is set to
~PC/. This means that the
active storage is you local hard disk. Assume that you change the current folder
~HOME/TOOLBOX, then you can refer to the
APE.PNG file above simply
ANIMALS/APE.PNG. Logo sees ahat this path does not begin with a slash or
a storage name, so it automatically prepends the path with
The SETCURDIR is the command that you use to change the current folder. Note that 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 load it!
The CURDIR command reports the current folder.
If you publish a Logo app, Logo sets the initial current directory to
~FILES instead of
~PC, because it assumes that a Logo app
typically comes with its own data, which you stored into the Files panel
before you published your app. Logo also switches to
~FILES when you
edit an app that you have published before.
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.
Storages in Detail
Time to look at the available storage services and their limitations.
~PC: The local disk
Logo is a browser-based app. A browser-based app is subject to a lot of security limitations, which are all meaningful; Logo is, as any web page, just another web page. And you certainly do not want to load a web page that can read your local hard drive, or even write to the drive without your consent!
There are a few more limitations, but the inability to access your local hard drive from within a Logo program is a big problem.
Fortunately, there are a few exceptions to this strict rule. If file operations are caused by a user gesture, most of them are OK to use. A user gesture is anything that you did to load or save a file, like, for example, clicking a button, or selecting a menu item.
This means that you can open a dialog to select a file to load, and you can save to your local Downloads folder without problems. You can also drag and drop a file from the Explorer (or the FInder on a Mac) into most Logo panels.
The Chrome and Edge browsers have a different security implementation. Both browsers also offer a Save File dialog. If Logo detects that the browser thinks that there was no user gesture, Logo displays this small dialog:
When you now click or touch the screen, the browser consider this to be a goo user gesture, and displays the file picker dialogs.
Also, the browser may display another dialog, asking for permissiobn to access a file. You will need to OK this dialog to continue loading or saving a file.
The Safari browser on Apple devices (iPhones and iPads) does not let you save files easily. Therefore, Logo saves a file or picture into a new browser tab. Once this tab is displayed, you can save the file or picture from there.
It is not recommended to use Chrome on iOS devices. Saving files or pictures will not work.
~FILES: The Local Files Storage
Since the PC storage has limited functionality, Logo offers you a separate storage where you can manage your files as you would like: the ~FILES part of the Files panel. You can use all file commands on that storage; the storage does NOT save its contents to disk, however; you need to use the menu command “File/Save/Files Panel” to save the contents of the storage to disk.
You can drop files, but not folders, into the ~FILES storage. Using the appropriate Logo commands, you can load these files (it can because dropping is a user action), and you can work with these files normally afterwards.
When you save the ~FILES storage, Logo saves it as a Zip archive. Such a Zip file is a compressed archive of files and folders, and can, therefore, contain any number of files in a separate folder hierarchy. You can actually view a Zip file as containing its own file system.
This is an example of the contents of a Zip file:
As you can see, this Zip file contains three files, a Logo file, an image and a sound.
Most operating systems have Zip compression features built in. Often, you can right-click files and select “Compress” or a similar menu item, and the operating system will create a Zip archive for you.
Logo lets you load such an Zip archive into the Files panel. Select “File/Load” or “File/Load Files Panel” to select the Zip file that you would like to load. Before doing so, select the storage that you would like to load from with the SETCURDIR command, or from the “File/Storage” menu.
Once you load a Zip archive, the Files panel
acts as a window into that archive. You can see all files in the Zip
archive; you can even drag images into your Graphics, Editor, or Listener panel. Just try to
drag the file
pig.png and drop it on top of your turtle, and your
turtle turns into a pig!
You could, of course, also use the Logo command
LOADSHAPE ”PIG.PNG. Note that you do not
need to prefix the file name as in
~FILES/PIG.PNG as long as the
current directory points to the ~FILES storage service (see above for
The ~FILES storage also becomes important when you publish your app. See the chapter “Become a Publisher” for details.
The menu item “Load…” also loads and runs .LGO files. When you load a Logo source file, Logo does not load the file into the ~FILES panel, but runs it instead. If you load a Zip archive, Logo collects and runs all LGO files in that archive’s top-level directory. Use “Load/Files Panel…” to load the ~FILES storage without running Logo Files.
The Files Panel displays all known storage services (except for the ~PC service). At the top, there is a drop-down list that lets you select which storage service to display. You can drag files or folders into the Listener por Editor; when you drop, Logo fills in the complete path for that file or folder, saving you a lot of typing work. Also, you can drag and drop images onto the Graphics panel to create new bitmaps, or to a turtle to changes it shape, just as you would do with the Toolbox.
Only the ~FILES storage accepts drops from the operating system, however.
~HOME: The Toolbox and Sounds Folders
The HOME storage 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 storage service. To tell the truth, the Toolbox panel also contains views for controls and colors, which are not part of the Toolbox storage.
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:
~HTTPS: Web Links
You want to access a file stored somewhere on a Web server? Logo lives up to its name here; all file operations that read a file can also access Web links (also called URLs or URIs). Would you like your turtle to look like the Google letters? Or do you prefer the turtle to have a Facebook “f”? No problem, as long as you know the Web link of the picture. This command, for example, turns your turtle into “Google”:
(The link may change, so do not rely on this link to work). How do you
get that cryptic-looking link? Well, right-click the image that you
would like to use on the Web page that displays the image, and select
“Copy Image Address”, or a similar text, and the Web link is in the
clipboard for you to use. Use
Cmd+V on the Mac) to paste the link into your command line.
You can always use “https:” instead of
Note that you cannot access links that begin with “http:” dur to browser security reasons.
You can use a Web link instead of a file name in all commands that read files, like LOADSHAPE, PLAY (for sounds and music), LOAD, LOADPIC, and even OPEN or READFILE. Logo cannot write to a Web server, or delete a file on the Web.
Of course, there are limitations. First, Web links are case sensitive. You must use vertical bars or the back-quote character to tell Logo not to convert the Web link to upper case.
Second, you cannot just load any Internet file. Many servers do not deliver every content to Web apps that did not launch from their own server. Pictures and sounds are usually fine, as are often simple text files. Servers are reluctant to deliver all sort of contents to prevent so-called cross-site scripting attacks. Therefore, you may see that some files just do not load, or cannot be opened.
And last, but not least, most Web server do not support directory listings. when you try to use the DIR or SUBDIR command, the commands may return an empty list.
Online Files as Web Links
You can usually share files stored on an online cloud service. Usually, you right-click the file, causing a context menu to pop up. One of the menu items is “Share this File”, “Copy Link”, or the like. If you select the menu item, the service either displays a Web link, or even copies it to the clipboard for you.
Unfortunately, most of these links are intended for browsers. If you paste the link into a browser’s address bar, it displays a page showing the shared file; from there, you can select to download the file. In general, the link that you’ve got is a link to view the file, not to download it, which is what Logo needs.
Before you can use the link in Logo, you need to convert it to a direct download link. The sections below contain information for the most common cloud services.
There is an online link converter available for Google Drive, OneDrive and DropBox that converts view links to download links for you.
Again, there is a caveat. Most cloud storages are very picky about delivering text files for security reasons. Images and sounds are generally OK, but you may not be able to access text files.
The links below show sequences of “XXXXXXX” characters. Your real links will show character garbage instead of these “XXXXXXX” links.
Dropbox will deliver text files as well as images and sounds. All you need to do to convert your link is to replace the server name with a different name as shown in the example below:
New link: https://dl.dropboxusercontent.com/s/XXXXXXX/MyImage.png?dl=0
Google Drive will not let you load text files. Also, the link rewrite is a little more elaborate. Your link will look like this example (note the file ID in red, which is the only part of the link that you need to keep):
Now, rewrite the link to this format:
Microsoft OneDrive will not let you load text files, but the link change is easy, following the example below:
New link: https://onedrive.live.com/download?resid=XXXXXXX&authkey=XXXXXXX&ithint=file%2cTXT