LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing boolean values to DLL



@JQ wrote:

thanks Rolf for pointing that out...

i've finally solved the problem (i think)... Smiley Very Happy 

it seems that VB .NET is much "smarter" compared to VB 6.0 as i do not need to convert the value to Byte before passing over the value Smiley Wink .. for some reason its seems as though i can declare the data type as Boolean and it still works to expectations Smiley Surprised ...

i'll post the codes here and if anybody is interested can take a look... if any bugs found please inform me and i'll do so if i found any... thanks to all who helped me out... great learning experience with you all Smiley Very Happy



That has not much todo with smartness. 32bit systems always use 32bits to pass parameters even if the parameter size is smaller than that. What is not defined for smaller types is how the unused MSBs are set. Usually they are not initialized at all and therefore left random. For LabVIEW that means not so much since passing any value LabVIEW will only examine the LSB and consider it FALSE if it is 0 and TRUE for any other value. Returning it to VB might be trickier since LabVIEW might place a 0 or 1 into the LSB but the compiler might also decide to use some shortcut that might change bits in higher Bytes too randomly. If VB is picky about interpreting the return value such as explicitedly requesting 0 and 1 in that register that might get a problem. Why someone would want to explicitedly restrict Boolean on register level to be only 0 and 1 I'm not sure.

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 11 of 13
(1,123 Views)


@rolfk wrote:

LabVIEW will only examine the LSB and consider it FALSE if it is 0 and TRUE for any other value.


Is this like JPD's "1 can not be represented in binary"?
How many other values can the least significant bit have? Smiley Very Happy

P.S. I'm kidding. I assume you meant the least significant byte, not bit.


___________________
Try to take over the world!
0 Kudos
Message 12 of 13
(1,100 Views)


@tst wrote:


@rolfk wrote:

LabVIEW will only examine the LSB and consider it FALSE if it is 0 and TRUE for any other value.


Is this like JPD's "1 can not be represented in binary"?
How many other values can the least significant bit have? Smiley Very Happy

P.S. I'm kidding. I assume you meant the least significant byte, not bit.


In my nomenclature LSB stands for "least significant byte" if you talk about multibyte values. 🙂

And that is also how LabVIEW since 5.0 treats native booleans.

Rolf Kalbermatter

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 13 of 13
(1,093 Views)