A User Language Program consists of two major items, definitions and statements.
Definitions are used to define constants, variables and functions to be used by statements.
A simple ULP could look like this:
#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));
}
If the #usage directive is present,
its value will be used in the Control Panel to display a description
of the program.
If the result of the ULP shall be a specific command that shall be executed in the editor window, the exit() function can be used to send that command to the editor window.
| Index | Copyright © 2005 CadSoft Computer GmbH |