Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on March 29, 2020, 09:04:30 AM
-
I'm trying to use the following in a Math Expression: IF(CT0.ACC==0,1565,IF(CT0.ACC==1, 1559, IF(CT0.ACC==2, 1560, IF(CT0.ACC==3, 1561, IF(CT0.ACC==4, 1562, IF(CT0.ACC==5, 1563, 1564)))))). I was trying to use one expression but apparently this exceeds the math stack depth. I don't particularly like all of the nested if statements anyway. Is there a better way to do this in one expression (something similar to a Case Statement) or do I just need to use a math expression for each of the cases?
-
Create a small memory block. Pre-fill with the numbers. Use a single statement: Result = Block[min(CT0.Acc, 6)]
-
Or try LERP.
-
Using LERP like that is pretty slick. Would there be an equivalent way to do that if the outputs were strings instead of integers?
-
Using LERP like that is pretty slick. Would there be an equivalent way to do that if the outputs were strings instead of integers?
It already exists in the STRPRINT script language. Lookup(value, 0string, 1string, 2string, ... Nstring) where Nstring is returned when value does not equal 0..N-1, otherwise it returns the string at that idex.
Each string can be a string literal or string element.
-
Thanks guys. Those are two pretty nifty tools and do exactly what I wanted in a more concise manner.