Where are my files?
In these days, files can live anywhere, on a USB stick, in the Cloud, or on a disk drive. Files can even be part of another file, like a Zip archive.
Logo supports various ways to load or save files. In this chapter, we use the word “file system” to describe a certain way or location to load and store files.
Files are most often stored inside a folder, which is a container for all kinds of files. A folder (also called a directory) can also contain other folder as well as files.
Path Names and File Systems
Let us look at file names in more detail before we move on. A file name can, of course, also contain the name of a folder where the files resides. This “parent folder” may again be part of another folder etc. Think of a disk drive. It contains a main folder which contains several sub-folders and/or files.
Therefore, we use the term “path name” for a file name that may include parent folder names, and/or the name of a file system.
Logo uses the name of a file system to determine where to liik for files:
PCis the file system for all disk files.HTTPS(orHTTP) is the file system for files that reside on an external Web server.HOMEis the file system for all files that are part of the Toolbox.- Finally,
FILESis the name of an internal file system that resides in memory, and whose contents can be loaded from Zip files, or saved into Zip files.
A path name is a list of folder names, separated by the slash character, like e.g. /IMAGES/TURTLE.PNG. Optionally, a path name can start with the name of a file system. There are two ways to mark the name of a file system. You either use the name with a tilde character at the beginning (like ~PC), or you use an Internet-like designation with the file system name, followed be a colon and a slash character. Thus, the path names ~HOME/TOOLBOX/SEALIFE/DOLPHIN.PNG and HOME://TOOLBOX/SEALIFE/DOLPHIN.PNG are both equivalent. Both path names refer to the file DOLPHIN.PNG inside the folder chain /TOOLBOX/SEALIFE, being part of the file system HOME.
The Current Folder
You may notice that the folder path begins with a slash character. This means that the folder path begins at the file system’s top level. If the slash was omitted, Logo would assume that the path’s first element resides within the file system’s current folder.
To avoid unnecessary repeats of the first few path elements, every file system remembers a “current folder”. This is a path name that Logo uses if a path name does not begin with a file system name, or a slash character. The SETCURDIR command lets you lets you specify the current folder, so you do not need to type in a long list of file system and folder names; you can just use a file name or a partial path name, and Logo would prepend any path name with the current folder.
Instead of having to type ~HOME/TOOLBOX/SEALIFE/DOLPHIN.PNG, you could, for example, issue the command SETCURDIR ~HOME/TOOLBOX, and reference the file as SEALIFE/DOLPHIN.PNG (note the missing slash character!).
The CURDIR command reports the current directory.
You can use special folder names as part of path names. The special folder name . references the current folder, and the folder name .. references the parent folder. If your current folder is IMAGES, for example, the path name ../MAIN.LGO points to a file in IMAGES’s parent folder.
Let us look at a few examples, given the current folder as ~HOME/TOOLBOX/SEALIFE:
| Path name | Real path name | Comments |
|---|---|---|
| DOLPHIN.PNG | ~HOME/TOOLBOX/SEALIFE/DOLPHIN.PNG | Relative path name |
| /MYFILE.LGO | ~HOME/MYFILE.LGO | Absolute path name without file system |
| ~PC/MYFILE.LGO | ~PC/MYFILE.LGO | Absolute path name with file system |
| ../BIRDS/HEN.PNG | ~HOME/TOOLBOX/BIRDS/HEN.PNG | Relative path name offset from parent |
Instead of a path name, you can make Logo display a File Open or File Save dialog. The easiest way to do this is to supply the empty word as the path name, as in SAVE ". Alternatively, use SAVE without inputs in parentheses as in (SAVE).
File System Limitations
Unfortunately, there are many limitations to the various file systems:
~PC - the local disk
Due to security constraints, you cannot load any file from disk directly. Trying to do so will generate a “File not found” error. You will want to use an empty file name as in LOAD " to have Logo open an Open File dialog where you can select the file to load.
Also, you cannot save to any arbitrary disk location. You can only save to the Downloads folder. Therefore, any attempt to save a file will open a small dialog box where the file name that you supply is already filled in.
Listing files or folders with the DIR or SUBDIR is also not possible.
~HOME - the Toolbox files
This file system is read-only; you cannot save any files. Also, picking a file is not possible, because the file system does not support a File Open dialog. But you can load files with full or partial path names just fine.
Hint: Drag any image or shape from the Toolbox into the Editor or Listener panels, and Logo will write the full path name of the dragged image.
Listing files or folders with the DIR or SUBDIR is supported.
~HTTPS and ~HTTP - Internet files
These file sytems are read-only as well. There is no way to display a FIle Open dialog, or to list and folder contents. Furthermore, 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.
Finally, the path name is case sensitive.
But try this for fun:
SETSHAPE "|https://logo6.terrapinlogo.com/icons/toolbox.png|
See below for a detailed description of how to access files stored in the Cloud, with examples for various cloud services.
~FILES - the internal file system
Since the PC file system has limited functionality, Logo offers you a separate in-memory file system where you can manage your files as you would like. You can use all file commands on that file system; the file system does NOT save its contents to disk, however; you need to use the SAVE contents of the storage to disk, and you must supply a file name ending in .ZIP or .LOGOENV so Logo know that you want to save the FILES file system. 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:

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 file system. Use the LOAD command together with a file name ending with .ZIP or .LOGOENV.
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.
Logo’s Icon Bar contains two icons to load and save your work.
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
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:
Original link:
https://www.dropbox.com/s/XXXXXXX/MyImage.png?dl=0
New link:
https://dl.dropboxusercontent.com/s/XXXXXXX/MyImage.png?dl=0
Google Drive
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):
https://drive.google.com/file/d/XXXXXXX/view?usp=sharing
Now, rewrite the link to this format:
https://drive.google.com/uc?export=download&id=XXXXXXX
Microsoft OneDrive
Microsoft OneDrive will not let you load text files, but the link change is easy, following the example below:
Original link:
https://onedrive.live.com/redir?resid=XXXXXXX&authkey=XXXXXXX&ithint=file%2cTXT
New link:
https://onedrive.live.com/download?resid=XXXXXXX&authkey=XXXXXXX&ithint=file%2cTXT
