1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<html>
<head>
<title>EAGLE Help: output()</title>
</head>
<body bgcolor=white>
<font face=Helvetica,Arial>
<hr>
<i>EAGLE Help</i>
<h1><center>output()</center></h1>
<hr>
<dl>
<dt>
<b>Function</b>
<dd>
Opens an output file for subsequent printf() calls.
<p>
<dt>
<b>Syntax</b>
<dd>
<tt>output(string filename[, string mode]) statement</tt>
<p>
<dt>
<b>Description</b>
<dd>
The <tt>output</tt> statement opens a file with the given <tt>filename</tt>
and <tt>mode</tt> for output through subsequent printf() calls.
If the file has been successfully opened, the <tt>statement</tt> is
executed, and after that the file is closed.
<p>
If the file cannot be opened, an error message is given and execution
of the ULP is terminated.
<p>
By default the output file is written into the <b>Project</b> directory.
<p>
</dl>
<b>See also</b> <a href=255.htm>printf</a>,
<a href=235.htm>fileerror</a>
<p>
<b>File Modes</b>
<p>
The <tt>mode</tt> parameter defines how the output file is to be opened.
If no <tt>mode</tt> parameter is given, the default is <tt>"wt"</tt>.
<p>
<table>
<tr><td valign=top><font face=Helvetica,Arial><tt>a</tt> </font></td><td valign=top><font face=Helvetica,Arial>append to an existing file, or create a new file if it does not exist</font></td></tr>
<tr><td valign=top><font face=Helvetica,Arial><tt>w</tt> </font></td><td valign=top><font face=Helvetica,Arial>create a new file (overwriting an existing file)</font></td></tr>
<tr><td valign=top><font face=Helvetica,Arial><tt>t</tt> </font></td><td valign=top><font face=Helvetica,Arial>open file in text mode</font></td></tr>
<tr><td valign=top><font face=Helvetica,Arial><tt>b</tt> </font></td><td valign=top><font face=Helvetica,Arial>open file in binary mode</font></td></tr>
<tr><td valign=top><font face=Helvetica,Arial><tt>D</tt> </font></td><td valign=top><font face=Helvetica,Arial>delete this file when ending the EAGLE session (only works together with <tt>w</tt>)</font></td></tr>
<tr><td valign=top><font face=Helvetica,Arial><tt>F</tt> </font></td><td valign=top><font face=Helvetica,Arial>force using this file name (normally *.brd, *.sch and *.lbr are rejected)</font></td></tr>
</table>
<p>
Mode characters may appear in any order and combination. However, only the
last one of <tt>a</tt> and <tt>w</tt> or <tt>t</tt> and <tt>b</tt>, respectively,
is significant. For example a mode of <tt>"abtw"</tt> would open a file for
textual write, which would be the same as <tt>"wt"</tt>.
<p>
<b>Nested Output statements</b>
<p>
<tt>output</tt> statements can be nested, as long as there are enough file
handles available, and provided that no two active <tt>output</tt> statements
access the <b>same</b> file.
<p>
<b>Example</b>
<pre>
void PrintText(string s)
{
printf("This also goes into the file: %s\n", s);
}
output("file.txt", "wt") {
printf("Directly printed\n");
PrintText("via function call");
}
</pre>
<hr>
<table width=100% cellspacing=0 border=0><tr><td align=left><font face=Helvetica,Arial>
<a href=index.htm>Index</a>
</font></td><td align=right><font face=Helvetica,Arial size=-1>
<i>Copyright © 2005 CadSoft Computer GmbH</i>
</font></td></tr></table>
<hr>
</font>
</body>
</html>
|