new to Analytica 5.2
Use this function when you want to return more than one distinct value from a User-Defined Function or expression. It is also sometimes convenient in certain looping scenarios when you want to set multiple local variables at the same time.
MultiResult( expr ... )
_( expr ... )
Accepts repeated expressions separated by commas, evaluates the only the ones that are captured by the caller or parent expression, and returns the results as multiple distinct return values. The dimensions of each return value are kept distinct -- they are not combined in any way.
_(a,b,c) are identical in functionality. Stylistically, the
MultiResult(...) syntax is generally nicer when used for a UDF return value, whereas the
_(...) lends itself to looping scenarios.
This function returns the R, G, B and Alpha components as separate return values given a color integer c.
- Function ColorComponents(c: Color ) :=
You can then capture the separate return values in local values using, e.g.,
Local (r,g,b,a) := ColorComponents( 'Turquoise' );
When you don't need the alpha value,
Local (r,g,b) := ColorComponents( 'Turquoise' );
The next example illustrates its use in a looping construct. Here
v is indexed by
In1, but the «bodyExpr» does something where it requires
v to be indexed only by
Time. At the same time, it also needs to know the corresponding index value from
In1 for that slice of
Local ( vi[Time], i[ ] ) := _( v, In1);