EAGLE Help

output()


Function
Opens an output file for subsequent printf() calls.

Syntax
output(string filename[, string mode]) statement

Description
The output statement opens a file with the given filename and mode for output through subsequent printf() calls. If the file has been successfully opened, the statement is executed, and after that the file is closed.

If the file cannot be opened, an error message is given and execution of the ULP is terminated.

By default the output file is written into the Project directory.

See also printf, fileerror

File Modes

The mode parameter defines how the output file is to be opened. If no mode parameter is given, the default is "wt".

a append to an existing file, or create a new file if it does not exist
w create a new file (overwriting an existing file)
t open file in text mode
b open file in binary mode
D delete this file when ending the EAGLE session (only works together with w)
F force using this file name (normally *.brd, *.sch and *.lbr are rejected)

Mode characters may appear in any order and combination. However, only the last one of a and w or t and b, respectively, is significant. For example a mode of "abtw" would open a file for textual write, which would be the same as "wt".

Nested Output statements

output statements can be nested, as long as there are enough file handles available, and provided that no two active output statements access the same file.

Example

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");
  }

Index Copyright © 2005 CadSoft Computer GmbH