|
»»»Home «««
»»»TELL «««
»»»Toped «««
»»»Ifaces «««
|
Table of Contents Functions are the basic building blocks of TELL code. Syntactically they look like C code. Below is the list of the main properties of TELL functions
The example below demonstrate the function definition and function call. box MOStran(point bound, real W, real L) {
// draw some shapes
return {{0,0},{10,8}}; // overlapping box
}
void Invertor(point bound, real NW, real NL, real PW, real PL) {
MOStran(bound,NW,NL);
// doing something
box ptrActive = MOStran(bound,PW,PL);
}
The examples of overloaded functions are Toped build-in functions like addbox, addpoly etc. described later in this manual.
Here is a quick example of a function calling itself int factoriel(real stop)
{
if (stop > 0)
{
int inter = factoriel(stop - 1);
return (stop * inter);
};
return 1;
}TELL itself defines predominantly general purpose functions. Toped in turn internally defines and implements a list of functions ensuring its own functionality. In general the editor that interprets TELL shall define and implement its own internal functions. These functions will be parsed first as a part of the initialization phase of the interpreter, so that any internal commands (function calls) received from the command line (or file) can be properly handled. TELL functions described below are using directly the underlying C functions and more detailed description can be obtained directly from the C math library documentation. One of the few differences is that the trigonometric functions work with angle degrees instead of radians.
Example 1. Trigonometric functions point list arc(point center, int radius, int start, int stop, int numsteps)
{
real step = abs(stop -start) / numsteps;
real current = start;
point list the_arc;
while (current <= stop)
{
point cur_point;
cur_point.x = center.x + radius * cos(current);
cur_point.y = center.y + radius * sin(current);
current = current + step;
the_arc[:+] = cur_point;
}
return the_arc;
}
Returns the list length. Empty lists are valid and their length will be 0
Prints the value of a TELL variable. This function is rather temporary. It takes any type of argument and prints its value in the log window. It could be useful for some very basic debugging of the TELL script.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||