ILWIS objects

 

Functions    

 

 

Functions can be used in all three calculators in ILWIS: in MapCalc/TabCalc, in scripts and in the pocket line calculator. In ILWIS, some 50 internal functions are available (see also MapCalc and TabCalc), but you can also create your own functions. By creating a user-defined function beforehand, your MapCalc and TabCalc formulas may be simplified.

A user-defined function allows you to pre-define complex calculations and/or calculations which you will need to repeat several times. At the time of using the function, you will only need to fill out the function's parameters and not the complicated formula itself.

A user-defined function may contain any combination of operators and existing functions, and may use parameters representing map names, table names and column names.

To create a user-defined function:

The Create Function dialog box appears in which you can type the expression that the function should perform.

To edit a user-defined function:

The Function editor appears.

Names of user-defined functions:

In ILWIS 3, object names comply with Windows long file names. Also Universal Naming Convention (UNC) paths are supported. For more information, see How to use long object names.

Parameters in user-defined functions:

A function will perform a certain calculation based on the parameters and the MapCalc/TabCalc operators and functions that you define in the expression of the function.

Parameter names:

Output domain type of a function and input domain types of function parameters:

In the function editor, the first line states:

Thus, when creating a function:

 

Mind: In case your input parameters use another domain type than domain type Value, or when the output domain of the function is another domain than system domain Value, you need to change the word(s) Value yourself in the appropriate place(s).
In other words, you must make sure that the domain types of parameters and the output domain of the function are correctly declared.

Function syntax is explained in detail in Function editor : functionality.

To apply a function:

When you use the function on the command line of the Main window or a Table window, you have to type the function name followed by brackets in which you type the map name(s) or column name(s) that need to be filled out for the parameter(s) in the function. You can separate parameters with commas. Instead of map names or column names, you can also type complete expressions.

The first filled out parameter is taken as the first parameter encountered in the function, etc.

In this way, you can use the function several times, each time filling out different map or column names on which the function should be applied. 

Technical information:

Functions consist of an ASCII object definition file (.FUN), and an ASCII data file (.FND).

Internal MapCalc and TabCalc functions are built in in the software and cannot be visualized.

Examples:

In Map calculation : creating and applying user-defined functions and in Table calculation : creating and applying user-defined functions several 'basic' examples are given. For more advanced user-defined functions, e.g. user-defined functions with IF, THEN, ELSE loops, FOR loops, WHILE loops and REPEAT/UNTIL loops, see Map and Table calculation : User-defined functions (advanced).

See also: