LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Return Values when Creating A DLL

I apologize in advance if this question has been already addressed; I could not find any related material.

 

The problem I have is that when I create a DLL, no problems here, I seemed to be restricted from selecting any of the outputs of my VI to be the return value. For instance, one simple case will be, add a text control as the input and then add a text indicator to be the output. One might think that the text indicator will be the return value by default since this variable has been assigned as the output; this is not the case. Instead I get a void function.

 

void DLLSTringTest(char String[], char String2[], int32_t len) 

 

The output string (String2) its placed as one the function's arguments??

 

Please let me know if there are any tricks that I'm missing here.

CAE

0 Kudos
Message 1 of 13
(4,388 Views)
I don't completely understand what you mean as "assigned as the output". A C function can have only one return value. In the function you provided the return value is void, meaning it doesn't return anything. Everything else is an argument. Whether it's an "input" or an "output" is irrelevant. It you argument is defined as a pointer, then it's really both. I would suggest you look at the "Call DLL" example that ships with LabVIEW. In the case where you're dealing with strings you have to make sure you pre-allocate the memory for the string in LabVIEW if the DLL does not do it.
0 Kudos
Message 2 of 13
(4,376 Views)

The "Call DLL" example shows how to call a DLL, right? I guess my question is how can I assigned a string or any output variable as the return value of the prototype when I create a DLL using LabView. When I drag the VI from the sources files and define the prototype, the return value is set to 'None' - no other options are given.

 

I apologize  - I'm new with this part of labview and I think I hit a stopping point here. I appreciate any provided help.

0 Kudos
Message 3 of 13
(4,363 Views)
The outputs are assigned to arguments as you already mentioned and not the return value. When you call the dll, the arguments will return the outputs of the VI.
0 Kudos
Message 4 of 13
(4,356 Views)
Thanks for you help - I got it figured out Smiley Happy
0 Kudos
Message 5 of 13
(4,337 Views)

I am sorry the I rehash an old topic. But it fits perfectly to my problem.

 

I have a predefined DLL interface which I cannot change. It needs a return values. So I have to pass a VI DLL output by return value instead of returning it by reference using parameters.

 

Is there a possibility to do this? I found at the DLL application builder a option which might fit but I cannot select a VI output to use (see attached image). Please let me know if I am missing any tricks here.

 

Steffen

0 Kudos
Message 6 of 13
(3,828 Views)

Hi Steffen,

 

as long as your DLL function is defined as "Void" it will not output any return value…

 

You have to change the definition of the function to something like "long function(param)"!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 13
(3,817 Views)

Hi Gerd,

 

thank you for your reply.

 

That is the thing. How do I change the function definition that it is return a long? I cannot change it directly at the "Function Prototype".  Is there a setting I have missed?

0 Kudos
Message 8 of 13
(3,812 Views)
You change the function definition by editing the dll source code and rebuilding the dll. There's nothing in LabVIEW that will make the dll return something that doesn't exist.
0 Kudos
Message 9 of 13
(3,807 Views)
Sorry, I didn't pay any attention to your image. Are you trying to create a LabVIEW that returns something other than void?
0 Kudos
Message 10 of 13
(3,798 Views)