<?xml version="1.0" encoding="ISO-8859-1"?>
<screenbook>
<title realName="Derived Files Part 2">Derived Files Part 2</title>
<category realName="Leo">Leo</category>
<subcategory realName="Basics">Basics</subcategory>
<format realName="Tutorial">Tutorial</format>
<description>Using Leo to to Create files derived from outlines.</description>
<keywords>Leo derived files directives literate programming</keywords><ldate>8/12/2002</ldate><version>draft</version>
<locations>
<location>
C:\testtt\Leo\Basics\Tutorials\Derived Files Part 2\</location>

</locations>

<pages>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Leo has a second way of creating derived files. This is the <strong>@file</strong> directive. This directive at first seems similar to the <strong>@root</strong> directive, but there is an important conceptual difference.&#160;When you use the <strong>@file</strong> directive, outline information is always written to the derived file. Therefore, you cannot use the <strong>@silent</strong> directive.</p><p>The benefit&#160;of using the <strong>@file</strong> directive is that there is no longer any need to explicity&#160;tangle and untangle.&#160; <strong>Tangling and untangling happen automatically by opening a .leo file and saving it</strong>. This makes alternating between Leo and another editor or IDE completely transparent.</p><p>In addition, when you use the <strong>@file</strong> directive, you can have <strong>unnamed sections. </strong> To see how these work, read on...</p>]]></span>

</text>
<picture>[Empty]</picture>
<title>The @file directive</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Here we've added a second node with a <strong>@file</strong> directive to our tree from the previous tutorial. The <strong>@file</strong> directive, in contrast to the <strong>@root</strong> directive, appears only in a node headline, not in node text.</p><p>As before, the node text has&#160;the &lt;&lt; includes &gt;&gt; section name. But this time, instead of a &lt;&lt; methods &gt;&gt; section name, it has a new directive: <strong>@others</strong>. This directive means, "put the node text from all of the unnamed sections here." Unnamed sections are nodes that are not sections, i.e. nodes that do not have double angle brackets in the node headline. </p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic02.png</picture>
<title>A @file directive node</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>We enter <strong>[CTRL-S]</strong> to save our .leo file, and the<strong> sampleHello2.c</strong> file is automatically written.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic03.png</picture>
<title>Saving automatically writes the derived file.</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Here is the <strong>sampleHello2.c</strong> file in our text editor. Embedded outlines created with the <strong>@file</strong> directive have a different embedding format than those created with the <strong>@root</strong> directive.</p><p>All of the outline information embedded by Leo starts with the&#160;<strong>@</strong> sign (plus, in this case, two slashes). Needless to say, we can't delete any such <strong>sentinel line</strong> without interfering with the ability of Leo to read the file back into an outline.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic04.png</picture>
<title>Here is the sampleHello2.c file</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Let's try adding some code in the text editor.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic05.png</picture>
<title>Add some code in the text editor.</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>Next we save the file with the text editor.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic06.png</picture>
<title>Save the file</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>When we return to Leo, we do not see the changes. We must either reopen the file or reread it.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic07.png</picture>
<title>Return to Leo</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>When we reopen our <strong>sample2.leo</strong> file, we can see that the changes we made to <strong>sampleHello2.c</strong> have been incorporated into our outline in the proper place.</p>]]></span>

</text>
<picture width="640" height="480" ldate="" id="pagepic">pic08.png</picture>
<title>Reopen the file</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
<page>
<text>

<span id="pagetext"><![CDATA[<p>If you are a programmer, you now have all of the information you need to start using Leo with your own programs. You may find that Leo quickly brings about a great improvement in programming speed and enjoyment, both for your own projects and for team projects.</p><p>For a look at some sample projects that have used Leo successfully, see the <strong>Examples</strong> section in this tutorial series.</p>]]></span>

</text>
<picture>[Empty]</picture>
<title>Summary</title>
<author>Joe Orr</author>
<sauthor>[Empty]</sauthor>
<cp>Copyright 2002 All Rights Reserved</cp>
<authoremail>orrj@jserv.com</authoremail>

</page>
</pages>
</screenbook>


