3 lines
16 KiB
HTML
3 lines
16 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>04-USING-FILES</title><link href="navigation.css" rel="stylesheet" type="text/css"/><link href="document.css" rel="stylesheet" type="text/css"/></head><body><p class="top_nav"><a href="part6.htm">< Previous</a><span> | </span><a href="../Medley-Primer.html">Contents</a><span> | </span><a href="part8.htm">Next ></a></p><h1 style="padding-top: 3pt;padding-left: 35pt;text-indent: 0pt;text-align: left;"><a name="bookmark6">4. HOW TO USE FILES</a></h1><p style="padding-left: 35pt;text-indent: 0pt;line-height: 6pt;text-align: left;"><span><img width="640" height="8" alt="image" src="Image_030.png"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Types of Files </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">A program file, or Lisp file, contains a series of expressions that can be read and</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">evaluated by the Lisp interpreter. These expressions can include function or macro</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">definitions, variables and their values, properties of variables, and so on. How to save Interlisp-D expressions on these files is explained in Chapter 7. Loading a file is</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">explained in the Simple Commands for Manipulating Files section below.</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Not all files, however, have Lisp expressions stored on them. For example, TEdit files store text; sketches are stored on files made with the package Sketch , or can be</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">incorporated into TEdit files. These files are not loaded directly into the environment, but are accessed with the package used to create them, such as TEdit or Sketch.</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">When you name a file, there are conventions that you should follow. These conventions allow you to tell the type of file by the extension to its name.</p><p class="s10" style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">If a file contains: Then:</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Lisp expressions It should not have an extension or have the extension</p><p class="s3" style="padding-left: 251pt;text-indent: 0pt;line-height: 107%;text-align: left;">.LISP<span class="p">. For example, a file called </span>MYCODE <span class="p">should contain Lisp expressions.</span></p><p style="padding-top: 6pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Compiled Code It should have the extension <span class="s3">.LCOM or .DFASL</span>. For</p><p style="padding-left: 251pt;text-indent: 0pt;line-height: 107%;text-align: left;">example, a file called <span class="s3">MYCODE.DFASL </span>should contain compiled code.</p><p style="padding-top: 6pt;padding-left: 251pt;text-indent: -144pt;line-height: 107%;text-align: left;">A Sketch Its extension should be <span class="s3">.SKETCH</span>. For example, a file called <span class="s3">MOUNTAINS.SKETCH </span>should contain a Sketch.</p><p style="padding-top: 7pt;padding-left: 251pt;text-indent: -143pt;line-height: 107%;text-align: left;">Text It should have the extension <span class="s3">.TEDIT</span>. For example, a file called <span class="s3">REPORT.TEDIT </span>should contain text that can be edited with the editor <span class="s3">TEDIT</span>.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Directories </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;line-height: 106%;text-align: left;">This section focu ses on how you can find files, and how you can easily manipulate files. To see all the files listed on a device, use the function <span class="s3">DIR</span>. For example, to see what files are stored in your current directory, type:</p><p class="s3" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">(DIR *.*)</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: justify;">Partial directory listings can be gotten by specifying a file name, rather than just a</p><p style="padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: justify;">device name. The wildcard character <span class="s3">* </span>can be used to match any number of unknown characters. For example, the command <span class="s3">(DIR T*) </span>will list the names of all files that begin with the letter <span class="s3">T</span>. An example using the wildcard is shown in Figure 4-1.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 198pt;text-indent: 0pt;text-align: left;"><span><img width="300" height="139" alt="image" src="Image_031.gif"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 4pt;padding-left: 220pt;text-indent: 0pt;text-align: left;">Figure 4-1. Using <span class="s3">DIR </span>with a Wildcard</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Directory Options </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">Various words can appear as extra arguments to the <span class="s3">DIR </span>command. these words give you extra information about the files.</p><p class="s3" style="padding-top: 6pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">SIZE <span class="p">displays the size of each file in the directory. For example, type:</span></p><p class="s3" style="padding-top: 8pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">(DIR {DSK} SIZE)</p><p class="s3" style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">DATE <span class="p">displays the creation date of each file in the directory. An example of this is shown in Figure 4-2.</span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 198pt;text-indent: 0pt;text-align: left;"><span><img width="300" height="139" alt="image" src="Image_032.gif"/></span></p><p style="padding-top: 9pt;padding-left: 106pt;text-indent: 127pt;line-height: 164%;text-align: left;">Figure 4-2. Example Using <span class="s3">DATE DEL </span>deletes all the files foun d by the directory command.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-top: 9pt;padding-left: 35pt;text-indent: 0pt;text-align: left;">Subdirectories </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Sudirectories are very helpful for organizing files. A set of files that have a single</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">purpose (for example, all the external documentation files for a system) can be grouped together into a subdirectory.</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">To associate a subdirectory with a filename, simply include the desired subdirectory as part of the name of the file. Subdirectories are specified after the device name and</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">before the simple filename. The first subdirectory should be between less-than and</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">greater-than signs (angle brackets) < >, with nested subdirectory names only followed by a greater than sign >. For example:</p><p class="s3" style="padding-top: 8pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">{DSK}<Directory>SubDirectory>SubSubDirectory>...>filename</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">or use the UNIX convention:</p><p class="s3" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">{DSK}/Directory/Subdirectory/Subsubdirectory/filename</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-top: 4pt;padding-left: 35pt;text-indent: 0pt;text-align: left;">To See What Files Are Loaded </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;line-height: 164%;text-align: left;">If you type <span class="s3">FILELST<CR></span>, the names of all the files you loaded will be displayed. Type <span class="s3">SYSFILES<CR> </span>to see what files are loaded to create the sysout.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-top: 9pt;padding-left: 35pt;text-indent: 0pt;text-align: left;">Simple Commands for Manipulating Files </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">When using these functions, always be sure to specify the full filename, including subfile directories if appropriate.</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">To have the conents of a file displayed in a window:</p><p class="s3" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">(SEE ’<span class="s4">filename</span>)</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">To copy a file (see Figure 4-3):</p><p class="s3" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">(COPYFILE ’<span class="s4">oldfilename </span>’<span class="s4">newfilename</span>)</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 143pt;text-indent: 0pt;text-align: left;"><span><img width="447" height="114" alt="image" src="Image_033.gif"/></span></p><p style="padding-top: 7pt;padding-left: 221pt;text-indent: 0pt;text-align: left;">Figure 4-3. Example Use of <span class="s3">COPYFILE</span></p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">To delete a file (see Figure 4-4):</p><p class="s3" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">(DELFILE ’<span class="s4">filename</span>)</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 143pt;text-indent: 0pt;text-align: left;"><span><img width="447" height="114" alt="image" src="Image_034.gif"/></span></p><p style="padding-top: 7pt;padding-left: 224pt;text-indent: 0pt;text-align: left;">Figure 4-4. Example Use of <span class="s3">DELFILE</span></p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">To rename a file:</p><p class="s4" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;"><span class="s3">(RENAMEFILE ’</span>oldfilename <span class="p">’</span>newfilename<span class="s3">)</span></p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Files that contain Lisp expressions can be loaded into the environment. That means that the information on them is read, evaluated, and incorporated into the Medley</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">environment. To load a file, type:</p><p class="s3" style="padding-top: 7pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">(LOAD ’<span class="s4">filename</span>)</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Connecting to a Directory </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: justify;">Often, each person or project has a subdirectory where files are stored. If this is your situation, you will want any files you create to be put into this directory automatically. This means you should "connect" to the directory.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-top: 4pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">CONN <span class="p">is the Medley command that connects you to a directory. For example, </span>CONN <span class="p">in Figure 4-5 connects you to the subsubdirectory </span>IM<span class="p">, in the subdirectory </span>PRIMER <span class="p">, the directory </span>LISPFILES<span class="p">, on the device </span>DSK<span class="p">. This information—the device and the</span></p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">directory names down to the subdirectory to which you want to be connected—is called the "path" to that subdirectory. <span class="s3">CONN </span>expects the path to a directory as an argument.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 143pt;text-indent: 0pt;text-align: left;"><span><img width="447" height="114" alt="image" src="Image_035.gif"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 156pt;text-indent: 0pt;text-align: left;">Figure 4-5. <span class="s3">CONN</span>ecting to Subdirectory Primer Subsubdirectory <span class="s3">IM</span></p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">Once you are connected to a directory, the command <span class="s3">DIR </span>will assume you want to see the files in that directory, or any of its subdirectories.</p><p style="padding-top: 6pt;padding-left: 107pt;text-indent: 0pt;line-height: 106%;text-align: left;">Other commands that require a filename as an argument (e.g., <span class="s3">SEE</span>, above) will assume that the file is in the connecteds directory if there is no path specified with the filename. This will often save you typing.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">File Version Numbers </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">When stored, each filename is fillowed by a semicolon and a number, as shown in this example:</p><p class="s3" style="padding-top: 8pt;padding-left: 143pt;text-indent: 0pt;text-align: left;">MYFILE.TEDIT;1</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">The number is the version number of the file. This is the system’s way of protecting your files from being overwritten. Each time the file is written, a new file is created with a version number one greater than the last. This new file will have everything from your previous file, plus all of your changes.</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">In most cases, you can exclude the version number when referencing the file. When the version is not specified, and there is more than one version of the file on that particular directory, the system generally uses your most recent version. An exception is the</p><p style="padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">function <span class="s3">DELFILE</span>, which deletes the oldest version (the one with the lowest version number) if none is specified.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 209pt;text-indent: 0pt;text-align: left;">[This page intentionally left blank]</p><p class="nav"> </p><p class="nav"> </p><p class="nav"><a href="part6.htm">< Previous</a><span> | </span><a href="../Medley-Primer.html">Contents</a><span> | </span><a href="part8.htm">Next ></a></p><p class="nav"> </p></body></html>
|