09-15-2025 09:42 AM
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).
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 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!
09-15-2025 09:59 AM
Works fine in LabVIEW 2020.
(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)
09-16-2025 01:20 AM
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.
09-16-2025 08:26 AM
@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.)
09-17-2025 01:26 PM
In 2023 Q3 32-bit, I can copy the data from the indicator into the constant via "copy data" with no crash.
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."