[not a bug] cfgfile

Moderator: POL Developer

Locked
innominabile
Adept Poster
Posts: 85
Joined: Wed Aug 30, 2006 5:24 pm
Location: Italy

[not a bug] cfgfile

Post by innominabile »

I have found a very little bug reading cfg files (also on pol097)

If I read a cfg value with syntax
var elem := Cstr(elem_cfg.value);
if value contains a number with + sign before like
value +10
when I read
print(value[1]);
the output is
1
instead of
+

The only solution I have found (not a real problem anymore) is use "" syntax like this:
value "+10"
and after
var elem := Cstr(elem_cfg.value);
elem["\""] := " ";
elem["\""] := " ";
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Re: cfgfile

Post by Austin »

When you access config elems using the . operator it tries to automatically determine the type.
In your case it is coming out with + saying positive (if you had a - you would get a negative number) the odd part is you are getting 1 (1.0) rather than 10.

If you want it to keep the + sign then you need to use GetConfigString(elem_ref, "value")
innominabile
Adept Poster
Posts: 85
Joined: Wed Aug 30, 2006 5:24 pm
Location: Italy

Re: cfgfile

Post by innominabile »

Oh, tanks, sorry for bug declaration :-)
Locked