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
|
<html>
<head>
<title>EAGLE Help: Writing a ULP</title>
</head>
<body bgcolor=white>
<font face=Helvetica,Arial>
<hr>
<i>EAGLE Help</i>
<h1><center>Writing a ULP</center></h1>
<hr>
A User Language Program is a plain text file which is written in a C-like
<a href=131.htm>syntax</a>.
User Language Programs use the extension <tt>.ulp</tt>.
You can create a ULP file with any text editor (provided it does
not insert any additional control characters into the file) or you can
use the <a href=23.htm>builtin text editor</a>.
<p>
A User Language Program consists of two major items,
<a href=197.htm>definitions</a> and
<a href=215.htm>statements</a>.
<p>
<a href=197.htm>Definitions</a> are used to define constants,
variables and functions to be used by <a href=215.htm>statements</a>.
<p>
A simple ULP could look like this:
<pre>
#usage "Add the characters in the word 'Hello'\n"
"Usage: RUN sample.ulp"
// Definitions:
string hello = "Hello";
int count(string s)
{
int c = 0;
for (int i = 0; s[i]; ++i)
c += s[i];
return c;
}
// Statements:
output("sample") {
printf("Count is: %d\n", count(hello));
}
</pre>
If the <tt><a href=137.htm>#usage</a></tt> directive is present,
its value will be used in the <a href=11.htm>Control Panel</a> to display a description
of the program.
<p>
If the result of the ULP shall be a specific command that shall be executed in the
editor window, the <tt><a href=247.htm>exit()</a></tt> function can be
used to send that command to the editor window.
<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>
|