# ifThenEval(cases,A)

Defines a function of multiple domains - is also a general Case statement.

### Syntax

o_ifThenEval(cases,A)
  cases: Array 1D Record - defines the cases to be considered
  A: any - defines the independent variable
  return: any - for each case the result of the input formula

### Usage

Use this where you would normally use a Case statement. The input "cases" is a array of records. Each record has two fields, each of type Text and each one defining a formula to be evaluated. The "if" field of the first record (case) is evaluated. If True then the "eval" field is evaluated and the result is returned. If False then the next record (case) is evaluated the same way. As soon as any condition is matched the function exits. If no condition matches then the original value is returned.

### Location

menu: veeos ==> Math ==> ifThenEval

library: mathLib

### Example

Define a function of two domains: A>0 and A<5 and A>5 and two accompanying formulas 1/A and 2*A .
For the ifThenEval we then create a record array with two fields such that

rec[0].if = "A>0 and A<5";
rec[0].eval="1/A";
rec[1].if = "A>5";
rec[1].eval = "2*A";

Feeding values A 0,1,2,3,4,5,6,7 to o_ifTheneval(rec,A) we obtain an output of 0,1,1/2,1/3,1/4,5,16,14

### Notes

VEE never had a Case statement but has always needed one. Originally there was a good reason that Case was not included but, although that reason went away many years ago, Case was never added. This function was developed to fill that gap.

### Reference

### Dependencies

Use eval() extensively

### Supported On

VEE 7.0+, all platforms

### See Also

eval

© 2015-2017. All Rights Reserved. Stan Bischof (stan@worldbadminton.com). Last updated 24 February 2017 08:58.