GenerativeComponents Help

Optional values

Aside from 'ref' and 'out' values, arguments can be optional. The built-in GenerativeComponents script global function 'Round' takes an optional second argument which sets the precision of the first argument. In the example below, the global variable Pi is rounded two different ways. When the precision is not given, the value is rounded to a whole number. When it is given, it is rounded to the specified precision (i.e. precision 2 rounds to the second decimal place Round(4.5678, 2) = 4.57).

To see the rounded Pi's, you must open the console window by selecting (Script Console ).

transaction 1 script 'New script transaction'
{
    	double pie = Round(Pi, 3); 
    	int pie2 = Round(Pi); 
            Print("The value of pie when the second argument is 3 is " + pie);
            Print("The value of pie when no second argument is given is " + pie2);
    	//The value of pie is 3.142
    	//The value of pie2 is 3 
}