From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo 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: 

if a variable is "bool" how to specify it in call library function node?

I need to call some functions in a dll. but the input parameters are of the type bool, and I can only choose signed integer or unsigned ineger to be the variable type. What should I choose? and if I can pass "true" or "false" to the function? Also what is "null" in labview? thank you very much!
Can a computer learn how to program?
0 Kudos
Message 1 of 7
(5,514 Views)
You can transform a boolean to a 1 or 0 integer. See the function in Functions palette - Boolean - Boolean to (0,1). This takes a boolean input and converts it to an integer, False to 0, True to 1. The only NULL that I know of in Labview is NaN for a number, Not a Path for a path, and other Not's. There is also an empty string constant in the strings palette.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(5,510 Views)
Thank you tbob, I guess I did not make myself clear. the function requires me to pass down a boolean expression to it. My problem is: when I config the call library function node, I need to specify the parameter type, which is supposely, "bool"; however I can only make it an integer or an unsigned integer, I can't specify it as a "bool". What can I do to solve the problem? Thanks again!
Can a computer learn how to program?
0 Kudos
Message 3 of 7
(5,504 Views)
and by the way, how to create NaN for a number, and how to create an empty string?
Can a computer learn how to program?
0 Kudos
Message 4 of 7
(5,493 Views)
Select integer, then wire in 0 or 1. The same applies if your return value is a boolean.
An empty string constant, like Thob said, can be found in the string palette. To get a NaN constant, try using the sqrt VI on a negative number. You can use the VIs in the comparison palette to check for these states.

___________________
Try to take over the world!
0 Kudos
Message 5 of 7
(5,478 Views)
RE: bool -- the reason you would use an integer # here is that that's how the dll (likely) also stores it. It's been a while but if memory serves, a "bool" is usually the same size as an "int" which is in turn likely to be 32-bits. A typical convention is 0<-->False, 1<-->True. But I think any non-zero value should also map to True.

RE: NaN constant -- you can also just type "NaN" into a floating point constant or control.

ObTip: sometimes I use NaN's as default values for controls in certain subvi's. Then the subvi can detect when an input was left unwired and substitute whatever value it chooses at its own discretion. The usefulness is that 'discretion' can include more than just a constant -- it could query a value from a queue or functional global or something.

-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 7
(5,464 Views)
thanks you all for all these enlightening suggestion! They explain things crystal clear! Now I can move forward in writing my program, this forum ROCKS!
Can a computer learn how to program?
0 Kudos
Message 7 of 7
(5,450 Views)