Simple Global Script Examples

Example 1

This script named “myProduct”, simply takes two arguments, multiplies them together, and returns the product.

function myProduct(arg1, arg2)
 return arg1 * arg2;

Example 2

This script named “myConvertFtoC” only takes one argument (arg1), which will be a temperature given in degrees Fahrenheit. The function converts the value to degrees Celsius and returns it.

function myConvertFtoC(arg1)
 return (arg1 - 32) * (5/9);

How the Global Scripts Look in Mango


Example of calling a global script from a Meta Data Source script

In this example we have a Meta Data Source named celsiusView which has a script that converts the value from OutsideTemp from Fahrenheit to Celsius using the global script myConvertFtoC.

return myConvertFtoC(OutsideTempF.value);

How the Meta Data Source script looks in Mango