LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug: Inifile read

So, i had an ini-file with an empty parameter with the following code:

IniReadBug.png

 

and got Error 19: "Read Key (Double).vi".

It says in the help that if the key doesn't exist the default is used, but if the parameter is missing (i.e. "parameter=")? I'd say it's a bug that the default isn't used (maybe accompanied with a warning). If it's not, the error text isn't exactly helpful as you can see, the text above is all info you get. It should atleast have the section and key included (i'd say that's a bug also).

 

The extended error text suggests a GPIB-error (sic).

Tested in 2010 and 2014.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 1 of 14
(3,861 Views)

Can you post the ini-file and the VI?

 

It seems to me that the error 19 indicates a type mismatch rather than a missing key.

Are you sure that there is no equally named key using some other value than numeric?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 14
(3,855 Views)

Setting the parameter to 1 makes it run without error. I'll change the vi some so i can post it.

Edit: added example files

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Download All
0 Kudos
Message 3 of 14
(3,853 Views)

I opened the Read Key (Double).vi and the code reveals the source of error 19:

ReadKeyDouble.PNG

If the double input to the case structure is '0', both casts are zero as well which will pass the "Config type invalid" error to the error output.

I don't know why it is like this and if it is really on purpose, but obviously, Read Key (Double).vi doesn't accept a '0' as default value.

 

Norbert

 

EDIT: I do concur that this seems to be an issue of at least the documentation. Do you have a specific need for '0' being the default value?

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 14
(3,841 Views)

Setting the default to 1 still generates Error 19, but i do get a 1 out. 🙂

To me the solution is simple, if the string is empty (missing parameter), return the Default.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 14
(3,834 Views)

Arg, OK, i should think before posting...

 

The case structure i posted the screenshot takes the "found?" parameter from the parsing function. As it is the TRUE case, it is an indiciation that the key is found in your ini file. But it doesn't match a numeric value (offset past match is '0', as THIS is the comparison!)

 

So please review your ini-file as it has to contain the key you are trying to load as double value, but the key does NOT cast into a floating point number.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 14
(3,827 Views)

@Norbert_B wrote:

Arg, OK, i should think before posting...

 

The case structure i posted the screenshot takes the "found?" parameter from the parsing function. As it is the TRUE case, it is an indiciation that the key is found in your ini file. But it doesn't match a numeric value (offset past match is '0', as THIS is the comparison!)

 

So please review your ini-file as it has to contain the key you are trying to load as double value, but the key does NOT cast into a floating point number.

 

Norbert


I know what the problem with the ini-file was, the parameter was empty. Scan from string can't scan a double from an empty string. That's the bug and the error text is lousy. 🙂

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 14
(3,817 Views)

@Yamaeda wrote:
[...] the parameter was empty. Scan from string can't scan a double from an empty string. That's the bug and the error text is lousy. 🙂

/Y


Ah, yes i understand your remark about empty string in your post before.

I think it is best if you would enter a idea exchange for modification of that Read Key (Double).vi. I think that there should be a difference between incompatible data type vs. "empty key" (you do think the same obviously).

 

thanks,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 14
(3,814 Views)

0 is a poor choise for a deaut value for scan from empty string.  Wire a NaN to that scan from string as default!  Your ini will thank you


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 14
(3,763 Views)
Good point, Jeff, maybe it ought to be the default of the function. After discussing it with a coworker it should ve an option with "set error if empty" (which is similar to the NaN-solution). Maybe i should make a suggestion out of it.
/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 14
(3,745 Views)