Showing results for 
Search instead for 
Did you mean: 

GType with array gives type mismatch after index loop in NXG

Go to solution

I am programming a driver for a spectrum analyser. I created gtypes for different settings that I read from the device and write to the device. The Vi's that read the settings have an output of the corresponding gtype. The write Vi's have an input and an output of the gtype. The output is used to get any changes made by the device. On my main panel, I have a control instance for each gtype. After I have read the settings I take the output and wire it to an indicator terminal of the control or a duplicated terminal. To send the settings to the device, I create a reference of the control, use a value property node and feed it to the corresponding VI. This works well so far. However, for the traces setting I have something that looks like this:


I got an array a within this array I have a cluster of different control fields. If I send this item to a VI and start a for loop on the item using auto-indexing, the output of the for loop is a 1-D array of a cluster and not the gtype. This is certainly true, but if I want to use this to update my control values I get a type mismatch error.

I have created a simplified example with a gtype called dummy consisting of an array holding a cluster with 3 control elements.


I can display the output using a new indicator called output. But if I use a duplicated terminal or use a reference + property node, I get a type error.

Has anyone an idea how to fix this problem?


0 Kudos
Message 1 of 4
Accepted by DeWilk

It is expected and you will see the behavior in both LabVIEW 2019 and LabVIEW NXG 4.0. When LabVIEW auto-indexes an array in a loop, it is not casting to a specific Array TypeDef. Usually, the type definition will be the element of the array (the data type of the array) not the array itself.


Read more here: How to initialize typedef array without loosing the typedef 


All the best,

0 Kudos
Message 2 of 4

I s'pose you can type cast the resulting array back to the type def'd one.


G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
0 Kudos
Message 3 of 4

Thanks for your help. I haven't included the array in my gtype and everything works now.


The type cast vi is complaining as soon as I connect a gtype to its type input. I get the error "Polymorphic terminal cannot accept this data type. Wired type: dummy.gtype"

0 Kudos
Message 4 of 4