# Finding the lowest of multiple variables

## Recommended Posts

Hi,Does anyone know of a neat way to find the lowest in a group of variables?I.E I have 5 variables with different values and I need to pick the lowest value at any given time.Any ideas?

##### Share on other sites
 Help AVSIM continue to serve you!Please donate today!

Hi Paul,This is what first came in mind: (maybe not the most efficient:-))(L:Var1,number) (>L:VarMin,number) (L:Var2,number) d (L:VarMin,number) < if{ (>L:VarMin,number) }(L:Var3,number) d (L:VarMin,number) < if{ (>L:VarMin,number) }(L:Var4,number) d (L:VarMin,number) < if{ (>L:VarMin,number) }(L:Var5,number) d (L:VarMin,number) < if{ (>L:VarMin,number) }Use (L:VarMin,number) as referenceHope this helpsTom

##### Share on other sites

Tom,Much more efficient than the route my brain was going!Many thanks,

##### Share on other sites

Hi Paul,Glad it was useful! If you need to handle Var1..Var5 independent from VarMin within a gauge, you can use a macro:(L:Var1,number) s0(L:Var2,number) d l0 < if{ s0 }(L:Var3,number) d l0 < if{ s0 }(L:Var4,number) d l0 < if{ s0 }(L:Var5,number) d l0 < if{ s0 }l0And then check the VarMin Value ie:..@VarMin 10 < if{ XXX } etcCheersTom

##### Share on other sites

Euhh....What's wrong with:var1 var2 var3 var4 var5 min min min min :-) ??Cheers, Rob Barendregt.

##### Share on other sites

"What's wrong with:var1 var2 var3 var4 var5 min min min min :-) ??"I can't see anything. Should be something??:-lol:-lol:-lolCheersTom

##### Share on other sites

Ok thanks... Sorry for being thick but what does min do?

##### Share on other sites

Paul,min takes the smallest of two values. ie "10 12 min" returns 10.What Rob showed seems to be the most efficient way I was talking about :-)Regards,Tom

##### Share on other sites

Excellent thanks,

##### Share on other sites

Q.E.D. :-)Cheers, Rob

## Create an account

Register a new account

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!