12-04-2022 05:48 AM
Hello,
in Labview, I Integrated with .net DLL, which has a function that returns an array of integers,
this function takes an initialized array by reference to be filled.
so, my problem is I can't do it with LabVIEW [I'm totally a beginner].
I need to retrieve this array and display it.
I attached the .net code and LabVIEW node
12-04-2022 08:58 AM
any idea?
12-04-2022 10:59 AM
@Peterboshra wrote:
I attached the .net code and LabVIEW node
All you did so far is attach two pictures.
12-05-2022 01:08 AM
I tried to display it on the array but the values didn't come to its still zeros.
so this is my question bcoz I don't know how to do this.
12-05-2022 03:20 AM
That .Net code looks strange to me. It seems that the parameter is really a function??
12-05-2022 05:17 AM
I would assume you either simply initialize an array and wire it to the input, or you need a "to.NET object" in between.
12-05-2022 07:48 AM - edited 12-05-2022 07:57 AM
@rolfk wrote:
That .Net code looks strange to me. It seems that the parameter is really a function??
its an interop DLL the original function written in c++ with "SafeArray(int)*" Argument
12-05-2022 07:54 AM
@Yamaeda wrote:
I would assume you either simply initialize an array and wire it to the input, or you need a "to.NET object" in between.
the problem is there is not input in the node
12-05-2022 08:32 AM - edited 12-05-2022 08:42 AM
@rolfk wrote:
That .Net code looks strange to me. It seems that the parameter is really a function??
this is how I can read the array in vb.net
this is what shown in dotpeek
12-05-2022 04:20 PM - edited 12-05-2022 04:23 PM
So how exactly is it failing? Is there an error that occurs?
@Peterboshra wrote:
@Yamaeda wrote:
I would assume you either simply initialize an array and wire it to the input, or you need a "to.NET object" in between.
the problem is there is not input in the node
My first question for you would be are you certain that the method signature is correct? A parameter with the out keyword is not required to be initialized prior to being passed to the method. Seeing "Int32[]&" when you hover over the terminal indicates that LabVIEW is correctly identifying it as an integer array. If the signature is correct, this should function properly.
If the array truly must be initialized first, then the parameter should be using the ref keyword.
Take this example class:
public class Class1
{
public static int GetSomeArray(out int[] arr)
{
arr = new int[] { 1, 2, 3, 4 };
return arr.Length;
}
public static int FillSomeArray(ref int[] arr)
{
for (int i = 0; i<arr.Length;i++)
{
arr[i] = i;
}
return arr.Length;
}
}
Note that if GetSomeArray() did not assign a new reference to arr that it would not compile.
ref = the parameter being passed may be modified by the method, and must be initialized prior to calling.
in = the parameter being passed will not be modified by the method and must be initialized prior to calling.
out = the parameter being passed must be modified and does not need to be initialized prior to calling.
LabVIEW will not generate an input terminal for out parameters, and shouldn't really need to.
You can call the methods from the example class in LabVIEW like this. (It could get more complex if there were different data types involved, but for primitives like Int32 that LabVIEW can automatically handle marshalling of, it's pretty simple.)