From 08:00 PM CDT Friday, August 12 - 01:00 PM CDT Saturday, August 13, ni.com will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modulo operator in Labview? (As part of case selector)

Solved!
Go to solution

Hi all,

 

I'm trying get this bit in Labview:

 

If x % 2 == 0 then

      boolean_var = true

else

      boolean_var = false

(x is counting up by 1 after a certain operation has taken place)

 

My attempt at doing this can be seen in the file attached. It's part of a far bigger code, that's why I only attached a snippet of it. I'm not sure if quotient and remainder is the right function for it.

 

Thanks in advance!

0 Kudos
Message 1 of 3
(108 Views)

It is the correct operator. However, you simply cannot connect it directly to the case selector. The case selector must be a Boolean, an integer or a string. If you take the output of the Q&R you can either do a comparison for less then 1 (in your case the remainder will always be 0 or 1) or cast the output to an integer and wire that directly to the case selector.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 3
(102 Views)
Solution
Accepted by topic author jolli12

Hi jolli,

 


@jolli12 wrote:

My attempt at doing this can be seen in the file attached. It's part of a far bigger code, that's why I only attached a snippet of it. I'm not sure if quotient and remainder is the right function for it.


Why are there orange wires? Why are there 3 locals in your image?

And why is there a case structure?

 

See this:

You can use Q&T, but there are simpler methods…

Best regards,
GerdW


using LV2016/2019/2020 on Win8.1/10+cRIO
Message 3 of 3
(87 Views)