Use a switch with a range ( not a fix number )

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Use a switch with a range ( not a fix number )

Post by stefan.erni »

Hi
How to use a switch, but the case is a range ( not a fix number )
like 1-500,501-1000,1001-1500

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Use a switch with a range ( not a fix number )

Post by kersing »

That is not possible. You will need to use decision icons to check ranges.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Use a switch with a range ( not a fix number )

Post by Benj »

Yep Kersing is correct the switch case will only check for singular values.

In a decision icon you can use something like this to check for a range, val being the variable you're checking.

(val >= 1) && (val <= 500)

stefan.erni
Valued Contributor
Valued Contributor
Posts: 654
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 182 times
Been thanked: 179 times
Contact:

Re: Use a switch with a range ( not a fix number )

Post by stefan.erni »

Thanke You both

With this help I did a C Code...
It's small in the mainpart and the big part is easy to copy-paste.
FC7 is really nice to use
switch_range_in_main.PNG
(8.46 KiB) Downloaded 2929 times

switch_range.PNG
(27.63 KiB) Downloaded 86 times

Post Reply