File: 200.htm

package info (click to toggle)
eagle 4.16-5
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 36,508 kB
  • sloc: sh: 82; makefile: 32
file content (81 lines) | stat: -rw-r--r-- 2,409 bytes parent folder | download | duplicates (2)
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
<html>
<head>
<title>EAGLE Help: Function Definitions</title>
</head>
<body bgcolor=white>
<font face=Helvetica,Arial>
<hr>
<i>EAGLE Help</i>
<h1><center>Function Definitions</center></h1>
<hr>
You can write your own User Language functions and call them just like the
<a href=230.htm>Builtin Functions</a>.
<p>
The general syntax of a <i>function definition</i> is
<pre>
type identifier(parameters)
{
  statements
}
</pre>
where <tt>type</tt> is one of the
<a href=154.htm>data</a> or
<a href=161.htm>object types</a>,
<tt>identifier</tt> is the name of the function,
<tt>parameters</tt> is a list of comma separated parameter definitions,
and <tt>statements</tt> is a sequence of <a href=215.htm>statements</a>.
<p>
Functions that do not return a value have the type <tt>void</tt>.
<p>
A function must be defined <b>before</b> it can be called, and function
calls can not be recursive (a function cannot call itself).
<p>
The statements in the function body may modify the values of the parameters,
but this will not have any effect on the arguments of the
<a href=214.htm>function call</a>.
<p>
Execution of a function can be terminated by the
<tt><a href=224.htm>return</a></tt> statement. Without any
<tt>return</tt> statement the function body is executed until it's closing
brace (<tt>}</tt>).
<p>
A call to the <tt><a href=247.htm>exit()</a></tt> function will
terminate the entire User Language Program.
<p>
<b>The special function <tt>main()</tt></b>
<p>
If your User Language Program contains a function called
<tt>main()</tt>, that function will be explicitly called as the
main function, and it's return value will be the
<a href=130.htm>return value</a> of the program.
<p>
Command line arguments are available to the program through the global
<a href=229.htm>Builtin Variables</a> <tt>argc</tt> and <tt>argv</tt>.
<p>
<b>Example</b>
<pre>
int CountDots(string s)
{
  int dots = 0;
  for (int i = 0; s[i]; ++i)
      if (s[i] == '.')
         ++dots;
  return dots;
}
string dotted = "This.has.dots...";
output("test") {
  printf("Number of dots: %d\n",
                 CountDots(dotted));
  }
</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 &copy; 2005 CadSoft Computer GmbH</i>
</font></td></tr></table>
<hr>
</font>
</body>
</html>