|
»»»Home «««
»»»TELL «««
»»»Toped «««
|
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 hardly defines any build-in functions. Toped however internally defines and implements a list of functions ensuring its own functionality. In general the editor that interprets TELL must 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. Returns the list length. Empty lists are valid and their length will be 0
Returns the absolute value of the argument. Because of the internal conversion between int and real, the function works for both types.
Returns the sine of the argument. The value of the argument must be in degrees
Example 3. sin 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 cosine of the argument. The value of the argument must be in degrees
See the example in sin 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.
| ||||||||||||||||||