LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView crash creating map constant

Hi everyone,

 

I've been working on a project recently where I use map structures to store certain types of information. In some cases, I define constant maps using the "Paste Data" tool, as it's the only method I've found to instantiate constant maps without having to use "Build Map" blocks (which helps keep the code cleaner and more organized).

 

image.png

I personally prefer B

 

However, when I try to define a constant map with key type (string) and value type (variant) using this method, LabVIEW crashes every time. This doesn’t happen with maps where the value is of another type (e.g., int, dbl, str...).

Create map constantCreate map constant

This method only works if value data is not variant

 

I imagine the issue is related to the variant data type, perhaps because it's more complex (though I'm not entirely sure). It seems that for some reason, constant values can't be assigned to a variant the same way they can be to simpler types.

 

Does anyone know why this happens? Are there any alternatives or workarounds I could use?

 

Thanks in advance!

0 Kudos
Message 1 of 5
(209 Views)

Works fine in LabVIEW 2020.

 

altenbach_0-1757948326096.png

 

(You are using LabVIEW 2019, which was the first version that had the map datatype. Maybe you encountered a bug that got fixed soon after)

 

Message 2 of 5
(197 Views)

Thanks for your reply.

However, I would also like to initialize the value of the variant — would that be possible?

I've seen that it is indeed possible to assign a value to a constant variant using copy/paste data.

0 Kudos
Message 3 of 5
(143 Views)

@pabolleta wrote:

However, I would also like to initialize the value of the variant — would that be possible?

I've seen that it is indeed possible to assign a value to a constant variant using copy/paste data.


Instead of having a variant constant, create a diagram constant of whatever the variant should contain, then use "to variant" before wiring to the built map node.

(Of course you need to be a bit more specific, because a variant can also contain attributes that have values.)

0 Kudos
Message 4 of 5
(104 Views)

In 2023 Q3 32-bit, I can copy the data from the indicator into the constant via "copy data" with no crash.

avogadro5_0-1758133490418.png

Since you asked for workaround, you can also do roughly the same thing by right clicking the indicator with the map value populated and doing "Change to Constant."

0 Kudos
Message 5 of 5
(52 Views)