# Derived Files Part 2

Leo
Basics
Tutorial
Using Leo to to Create files derived from outlines.
Leo derived files directives literate programming
8/12/2002
draft
C:\testtt\Leo\Basics\Tutorials\Derived Files Part 2\
<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>

[Empty]

# The @file directive

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<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>

pic02.png

# A @file directive node

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>We enter <strong>[CTRL-S]</strong> to save our .leo file, and the<strong> sampleHello2.c</strong> file is automatically written.</p>

pic03.png

# Saving automatically writes the derived file.

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<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>

pic04.png

# Here is the sampleHello2.c file

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>Let's try adding some code in the text editor.</p>

pic05.png

# Add some code in the text editor.

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>Next we save the file with the text editor.</p>

pic06.png

# Save the file

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<p>When we return to Leo, we do not see the changes. We must either reopen the file or reread it.</p>

pic07.png

# Return to Leo

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<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>

pic08.png

# Reopen the file

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com
<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>

[Empty]

# Summary

Joe Orr
[Empty]
Copyright 2002 All Rights Reserved
orrj@jserv.com