LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Yamaeda

Change Read Key - Double, Int, Bool

Status: Declined

Any idea that has received less than 3 kudos within 3 years after posting will be automatically declined.

Background:

"If the key does not exist, the VI returns the default value. "

 

What happens if the key is empty isn't described in the help, and in fact it results in "Error 19 - Read key.vi" or Error 1 - GPIB (sic) in the boolean case. Not a very helpful error message as it doesn't mention which section and key was faulty nor the call chain so it can be easily found.

 

Suggestion:

If the key is empty, return default. Alternativly add an input "Return error on empty" to make it optional.

Include section and key in error message

Include call chain (now that's a general improvement needed in many VIs)

 

How to reproduce?

Read an empty parameter from an ini-file as double, int or boolean.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
5 Comments
Yamaeda
Proven Zealot

Addition:

The default on float should be NaN since there's no number present.

For referrence you can check Bug-Inifile-read

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
AristosQueue (NI)
NI Employee (retired)

This is a good suggestion. We would have to introduce a new VI rather than change the behavior of the existing one in order to avoid breaking existing code, but some sort of change seems reasonable.

 

I have no idea when that API is next slated for review. In the meantime, you might want to create a wrapper VI around Read Key that checks for the error immediately and changes the outputs as you desire to make your issue easier to find in your own code.

Oligarlicky
Member

You mean if the value is empty, not if the key is empty.

 

=value  ;example of empty key

 

key=     ;example of empty value

 

Currently, it does return the default value on error. Are you saying if the value is empty and you ask for a number, it shouldn't throw an error? Seems like a valid error.

Yamaeda
Proven Zealot
@Oli yes, I mean if the key is empty, not missing. Yes, it is in a sense valid as it is (though bad error text), that's why i'm suggesting the "error on empty"-option, in which case it'd work like now else it would just return the default. /Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 3 kudos within 3 years after posting will be automatically declined.