I have a script that asks a user’s input for a number (saves it in variable X)
I would like the script to use this number and translate it to another variable Y (number) based on some range table.
if Variable X from 0 to 10 than the output will be variableY = 120
if Variable X from 11 to 20 than the output will be variableY =100
if Variable X from 21 to 30 … variableY = 90
and so on. about 10 ranges like that.
I dont want to build a lot of IF statements. whats the optimum way ?
We can use Regex with a lookup table that should work well.
Please test this macro and let us know if it works for you.
You will need to edit the first Action in magenta to enter your data.
And then edit the Prompt Action to set the allowed values of X max.
2017-07-13 20:39 CT VER 2.1.1
• New version with different algorithm.
• Prior version did not work properly.
###Example Results
####Normal Results
####IF Error
###MACRO: Set Variable Y Based on Range of Variable X @Extension
As I have mentioned I am not very knowledgeable in KM.
so I have imported the downloaded makro. when I run it , it works.
but I have my own script with the user entry with additional parameters.
so how do I incorporate your macro inside my own macro ?
in my case, I dont what the Qty variable at all. I want it be calculated based on the TRIGGER.
so my X is the TRIGGER and the Y is Qty, to be later used down bellow in the macro.
Well, I managed to do it by adding my variables in your “user input” screen and by execute a macro within a macro (from my own). apparently the variables are public and my macro got them as well.
is this the optimum solution? is there a better one ?