Can't you just multiply all your numbers together instead of using a function?
The UI allows the user to input fractions as text such as "1/4", "79/520" and "1/2".
Evaluate works if I allow the user to put all input into one text field with the operator:
"1/4 * 79/520 * 1/2"
But the user has to remember to put those operands in there.
So, I put this custom function together, but I just didn't know if someone had done something better.
EDIT: Found these at Brian Dunning (link). Not quite what I was looking for, but interesting.
- Fraction ( _a_b ; _operator ; _c_d )
- ListOperation ( list ; operator )
- Operate ( Expression )
Function Product ( a ; b ; c ; d ; e ; f ; g ; h ; i )
If ( a ; Evaluate ( a ) ; 1 ) * // change to whatever operator you desire
If ( b ; Evaluate ( b ) ; 1 ) *
If ( c ; Evaluate ( c ) ; 1 ) *
If ( d ; Evaluate ( d ) ; 1 ) *
If ( e ; Evaluate ( e ) ; 1 ) *
If ( f ; Evaluate ( f ) ; 1 ) *
If ( g ; Evaluate ( g ) ; 1 ) *
If ( h ; Evaluate ( h ) ; 1 ) *
If ( i ; Evaluate ( i ) ; 1 )
EDIT: Simplified logic in If().
or you could do this:
Evaluate ( Substitute ( List ( a ; b ; c ; d ; e ; f ; g ; h ; i ) ; ¶ ; " * " ) )
I originally was going to use repetitions, but was discouraged due to only having up to 10 fixed fields for the factors. (Mini spreadsheet.)
Thanks! That does simplify it quite a bit and makes the operator a parameter to boot.
I'll have to rename the function ...
PS. Actually it is important to filter out the zero in a multiplication, but that can be done easily at the field level.
While a zero in one of these fields would produce a zero result, please be aware that a blank field will not produce such a result.
And if this were my system, I'd replace this set of fields with a set of related records in a related table.