LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In-place Map Access returns previous Class data not Class default value if not found

I am using LabVIEW 2020

When I use the In-place Map Get/Replace node to insert entries into a map (if they don't already exist), the data returned is the previously added value, and not the class's default value, unless the class constant is wired to the node as the default value. I do not expect this behaviour.  I have attached a simple example.

WrongClassData%20Snippet

Front Panel showing the Previous Values instead of Default ValuesFront Panel showing the Previous Values instead of Default Values

Download All
0 Kudos
Message 1 of 4
(1,668 Views)

Does it help if you wire the "default value" of the left IPE node?

 

It seems like the returned value is undefined if the default value isn't wired. Can't find a reference though.

 

Why wouldn't you wire the "default value" of the left IPE node?

 

 

 

0 Kudos
Message 2 of 4
(1,621 Views)

Yes wiring the left node avoids the issue.

 

Why wouldn’t I wire it? Laziness. But in my defence, it doesn’t behave this way with simple data types and there is no explicit documentation of this behaviour.

I think it at least warrants some more detailed documentation, but honestly I think it is a bug (even if it is sloppy programming).

0 Kudos
Message 3 of 4
(1,610 Views)

@pauldavey wrote:

Yes wiring the left node avoids the issue.

 

Why wouldn’t I wire it? Laziness. But in my defence, it doesn’t behave this way with simple data types and there is no explicit documentation of this behaviour.

I think it at least warrants some more detailed documentation, but honestly I think it is a bug (even if it is sloppy programming).


IIRC, there is an idea that the default value should be required. It might have evaluated to a BUG already. Can't find it...

 

I could be mixing things up with The-key-input-of-the-IPE-s-Map-Get-Replace-Value-node-should-be or a thread somewhere else... EDIT: I put a comment there, maybe the can address the issues in one go.

 

I'm not sure what I prefer, having to wire it or getting undefined values. I don't have much map milage.

0 Kudos
Message 4 of 4
(1,607 Views)