JayLee
(Jay)
November 2, 2021, 3:17pm
1
Hi all,
i am searching for a possibility , to group 4 boolean variables in a strategic order, to work then with a flow switch or something similar.
Example:
Var1 - False , Var2 - False , Var3 - False , Var4 - False >> outcome should be 1
Var1 - False , Var2 - False , Var3 - False , Var4 - True >> outcome should be 2
Var1 - False , Var2 - False , Var3 - True , Var4 - False >> outcome should be 3
ans so on - to the 16 variations
How would you solve this? don´t think with an IF activity …
ppr
(Peter Preuss)
November 2, 2021, 3:32pm
2
make a mask similar a bit mask and use it within a switch activity (string type)
So in your case:
arrFlags = {var1, var2, var3, var4} | DataType: Boolean( )
String.Join("",arrFlags.Select(Function (x) Convert.ToInt32(x).toString))
By using the default branch you can maybe omit some cases as well
JayLee
(Jay)
November 3, 2021, 8:14am
3
@ppr ,
thanks for the tip , how would you then proceed to assign these 16?
with a multiple assign ? - its not possible to have 0000 in the case of the flow switch
outcome = If(string=“0000”, “1”, “”)
or would you do something like that in a invoke code?
IF
caseID=1
ELSEIF
caseID=2
ELSEIF
caseID=3
…and so on to 16 variations.
thank you again for some support!
ppr
(Peter Preuss)
November 3, 2021, 8:52am
4
@JayLee
let me try to answer as I am not sure if I got you in all points.
A general flow would look like this:
Also working the flow switch
the invoke code and nested if/else approach is not recommended. The switch approach ius preferred
JayLee
(Jay)
November 3, 2021, 9:38am
5
@ppr
oh, yes , thats what i aim to do! General flow with those cases !
Many thanks for your time!
i overlooked the typeArgument String (because i wanted first to have the first case 0000 is my case 1 - then it is not working , cause i have int32 in the typeArgument)
Thanks again!
Jay
system
(system)
Closed
November 6, 2021, 9:39am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.