LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pass void variable to a function

Hi everybody...

i have to pass a void variable to a function but i have some problems.

The function that i have to pass is defined like this picture.

[IMG]http://i60.tinypic.com/2ut6l9d.jpg[/IMG]

Therefore i set my function in this mode:

[img]http://i62.tinypic.com/o0xa2o.png[/img]

But when i run the program i gives me this error

[img]http://i62.tinypic.com/2mobbxh.png[/img][/quote]

 

I think the problem is linked with pRes variable that in the definition of the function is a Void type, but in my program i don't know how to pass a void variable.

Can someone help me?!

 

0 Kudos
Message 1 of 10
(5,610 Views)

This forum allows you to post images directly. Please do that instead of posting links (especially since some of your links are broken) to unknown outside servers. Even better, when you are describing text code, post the TEXT!

0 Kudos
Message 2 of 10
(5,543 Views)

Just what nathan said. Links on external sides are pretty undesirable, especially on sites like the one you use, where one never can be sure that it doesn't try to "provide" one with scare ware or other undesirable stuff, when clicking somewhere by accident, besides that I don't really trust such sites to not try to download hidden programs, either as part of their "businessmodel" or unintentiionally since they are attractive targets to get hacked for such purposes.

 

Apart from that, you need to understand a bit about C programming. It's not a void parameter that your function has but a void pointer. That is a whole lot of a difference. (You can't define a function having a void parameter, as that would be completely useless). A void pointer in C is used to indicate a parameter that can get assigned any valid pointer datatype. Which actual pointer type the function actually expects usually depends on the actual context and often specific other parameters that tell the function what it should expect.

 

Just because you select adapt to type as datatype because LabVIEW uses there also void* as datatype does absolutely not mean that the datatypes match. Again void* can mean any kind of pointer. Which one has to be determined based on the funciton description and often depends on other parameters to your function. Once you know what the function expects you have to find the according datatype that LabVIEW can provide. This is almost certainly not an Adapt to Type type, since that is the datatype that will pass the LabVIEW variable as native datatype to the function. For skalars this means that LabVIEW passes a pointer to that skalar, for arrays and strings it will pass the LabVIEW handle, which is certainly not what the DLL expects unless the DLL is specifically written to interface to the LabVIEW Call Library Node, by someone who knows what native LabVIEW datatypes mean.

Rolf Kalbermatter
My Blog
Message 3 of 10
(5,534 Views)

I'm sorry for posting image wrongly...

Here i tried to pass some parameters to my function but it doesen't work correctly.

Can someone help me?! I don't know where i am making a mistake

 

Thank you very much

 

Giovanni

0 Kudos
Message 4 of 10
(5,501 Views)

You are talking about a  PviCom.dll:PviInitialize as "your function"  , I don't think anyone will be able to help you with this without the dll.

 

I would suggested you check the manual that comes with the dll and an example of how it's accesed.   Your vi looks ok.

 

pvicom.dll

0 Kudos
Message 5 of 10
(5,485 Views)

Yes!! Smiley Happy

I am talking about PviCom.dll, in particular PviInitialize function...

In atteachment there is the declaration of the function and also an example. I think i am not making mistakes... But i can't understand why labview returns me error 1517...

Download All
0 Kudos
Message 6 of 10
(5,475 Views)

Just what doesn't work? How do you determine that it doesn't work? By the way you are going to be in even deeper problems to get the Windows message mechanisme working that your DLL seems to require.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 10
(5,469 Views)

Because labview gives me the error 1517 meaning that there is a mismatch between function of the dll and parameters that i pass to the function... 

0 Kudos
Message 8 of 10
(5,460 Views)

Two things then:

 

1) Are you sure your function uses  cdecl and not stdcall?

 

2) I assume you run in 32 Bit LabVIEW but if you ever plan to use 64 bit LabVIEW it would be better to define the last parameter as pointer sized integer instead.

Rolf Kalbermatter
My Blog
Message 9 of 10
(5,452 Views)

You are wright!!!!!

The problem was that i used cdecl and not stdcall... Using stdcall it works correctly.

0 Kudos
Message 10 of 10
(5,447 Views)