Function Editor

Allows a user defined function to be performed on the selected sites.  

The function can also be referred to as a script.  

Simple functions may be written much like a mathematical expression, so no expert knowledge of programming is required.

For example, to make a percentage change of sites in a map, you might write:

v \* 0.1

If you click ‘Apply’, the function will be applied to the sites in the map.  If you want the function to be applied to all sites, uncheck the “Apply to Selection” box.

See also Example Function Scripts.

The language used for scripts is “ECMA Script” and there are many resources on the web on its usage:

http://www.w3schools.com/JS/default.asp

http://en.wikipedia.org/wiki/JavaScript

Simple View

Function Simple View Function Simple View

The function editor can be opened by first selecting a channel, map, option, etc and then pressing Ctrl+F

By default, the function editor will display in a simple view mode.  This offers an immediate method of entering simple mathematical operations.  Pressing the Return key will apply the function and close the window.

If you check the ‘Advanced View’ check box, then you can enter more complicated multi-line scripts.

Advanced View

Function Advance View Function Advance View

You can write very complicated scripts if you need to that apply functions taking into account all of the sites in the map.  Scripts can contain function definitions and may include additional script files from the files system via the ‘include’ function.

Objects and functions defined by GWv4 are listed on the left hand side of the function editor window, along with a brief description of their purpose.  To add one of these items at the current cursor location in your script, double click on the item in the list or simply type it in.  Variable and function names are case-sensitive.

If you do not set the ‘result’ value, then the site will be set to the value of the last expression in the script.

There are too many predefined functions and objects within the scripting language to list here.  

Of most use in this context are the Math functions and constants:

http://www.w3schools.com/jsref/jsref_obj_math.asp

For example, the screenshot above shows the use of the Math.log function.  This is the base 10 logarithm of the value supplied.

Trigonometric and exponentiation functions are also available, as are functions to generate absolute values.

The ‘object’ variable represents the object that you are performing the function on.  For example, this could be a table or a map.

Such objects have member functions to adjust the value of specific sites:

thing.getReal(xy);
thing.setReal(valuexy);

See also Example Function Scripts.