func


function

Principle
Declaration
Call
error
Example
Parameter passed by address
Generation
function passed as a parameter
func
See also

Principle

The function syntax is based on that of the C language, see functions.

Déclaration:

name(liste)
       {
       ... code ...
       }
liste = liste de paramètres formels (éventuellement vide)

Call:

name(liste)
liste = formal parameter list (possibly empty).

error

func error

Returns the names of the functions where an error occured.

func error(0)

Resets this name, must be done after each error (otherwise message reset error appears after 100 errors and then func error(0) is automatically done).

Exemple:

Given the function:
a(x,y)
        {
        $"x=",x," y=",y;RC
        }
a(0,1.5): produces x=0 y=1.5
a(1,"ABCD"): Produit x=1 y=ABCD
a((1,2,3),"A"): produces x=1,2,3 y=A

Notes:

1) When a formal parameter receives no current value, default is NIL.
2) No type declaration is required.
3) Parameters are passed by value, ie a function does not change the current settings.

Parameter passed by address

When current setting (in the function call) is preceded by @, it can be modified by the function (through-address), the corresponding formal parameter in the function must be declared address.

Example:

Given the function:
f(p)
address p;
{
       p++;
}

Assign a value to v: v=1;
Call the function f () by passing the address of v: f(@v);
$v; produces 2.000000 (v (v has been incremented).

Generation:

1) Functions can be written to an ASCII file extension. Func in any text editor and read in anyflo by: read func and add func. Les fonctions peuvent être écrites dans un fichier ASCII d´extension .func sous n´importe quel éditeur et lues dans anyflo par ´read func´ et ´add func´
2) edit func is an internal editor to anyflo.
3) Functions can be generated dynamically by generate func
4) The function call fff which is not in memory provokes the search, in the current directory and then in the environment, of the fff.func file whose primary function is fff().

function passed as a parameter

the statement func f declares f as a function name passed as a parameter.
Example:
Given the function:
a(f,n)
func f
{
$f(n)
}
a("cos",3*PI/4): produces value (-0.707107)
a("sin",3*PI/4): producex value (0.707107)

Note:
These functions passed by name can also be anyflo functions created by the user. See an example in the file with the function fonction(a,b) of file demo0_func.func

func

func

        Returns the names of all functions.

func("f")

        Returns the text of the function named f.
Examples:
$func; prints the names of all functions.
x=func "foo"; gives to x the value of the text of the function foo.

func("f")compile

        Prints the pseudo code of the compilation of function named f.

See also:

add func
edit func
generate func
ini func
read func
rem func
write func