I understand that units are designed to be reusable code / libraries / APIs. It's a practical way to organize code, and a pretty good name for it, too.<div><br></div><div>In some languages, especially scripting languages, units can serve dual purposes. They can act as both a library and a self-sufficient program. RosettaCode describes this behavior as <a href="http://rosettacode.org/wiki/ScriptedMain">scripted main</a>. If it's possible to compile a Pascal unit such that it executes initialization code as if it were a typical program/begin/end file, then this dual behavior can be achieved.<br clear="all">

<div><br></div><div>Let's say I want to write a dual-purpose Fibonacci program, fib.p. It should:</div><div><br></div><div>1) Export a Fib (n : integer) function.</div><div>2) Compile to an executable fib.exe (or fib in Unix)</div>

<div>3) When the executable is run, it prompts the user for n, then prints Fib (n).</div><div><br></div>Cheers,<div><br></div><div>Andrew Pennebaker</div><div><a href="http://www.yellosoft.us" target="_blank">www.yellosoft.us</a></div>


<br><div class="gmail_quote">On Thu, Oct 13, 2011 at 11:09 PM, Ralf A. Quint <span dir="ltr"><<a href="mailto:FreeDOS@gmx.net">FreeDOS@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">At 08:02 PM 10/13/2011, Andrew Pennebaker wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I can USE the code just fine in a second file, test.p, and compile and run a test executable. But I'd like to be able to turn my units into self-sufficient executables (and later add command line options).<br>
</blockquote>
<br></div>
Looks like you do not understand the basic concept behind the use of units. They are not supposed to be "self-sufficient". Code in units are supposed to be re-usable code (snippets) across projects or to devide a larger program into smaller, better maintainable "pieces"...<br>

<font color="#888888">
<br>
Ralf <br></font><div><div></div><div class="h5">
______________________________<u></u>_________________<br>
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank">fpc-pascal@lists.freepascal.<u></u>org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/<u></u>mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br></div>