[Gambas-user] Possible bug?: Regional formats, float, text and val() function

Willy Raets willy at ...2734...
Tue May 14 19:30:21 CEST 2013


On Tue, 2013-05-14 at 08:36 +0200, Rolf-Werner Eilert wrote:
> And then I just came across this one:
> 
> >
> > I have a valuebox and a gridview.
> >
> > I enter a number in the value box (let's say 1/2) and next add it to a
> > cell in gridview with a button
> >
> > When Regional settings are some European mainland country
> > Entering 5 1/2 in a valuebox looks like:
> > 5,5 (-> with a comma)
> > and ends up as 5,5 in gridview (as text)
> >
> > When I click a row the cell goes into a Float variable
> >
The example is an simplification of a more complex part of the project
> 
> So what you do is, you actually store the value in the GUI. The GUI 
> converts it to some locale, and you then want to retrieve the value from 
> there for further work on it.

What I actually do is have the data read from a .csv file into a
gridview when opening the form (see screenshot 1).
Users can then add data to the gridview or click a row and edit the data
of that row (see screenshot2 and 3 -> Note all yellow fields are read
only)

>From gridview I need some of the data to make a chart in a DrawingArea.
(See screenshot 5) That is where the Float comes in, in my project
it is a Float array that gets data from the gridview for further
calculations to draw the chart.

I have many different tabs with different gridviews and all have to
possibility to show the gridview data in a chart.

This is all for electricity, but there is more.
Each gridviews data is stored in a seperate .csv.
Usually every item has annual and periodical data. Items are
Electricity, natural gas, cylindered gas and water. But there will be a
lot more.

> 
> If you kept data storing and GUI clearly apart from each other, there 
> would be less trouble.

Data storing is on hard disk in .csv
GUI representation of data is reading .csv into a gridview
Data is needed for further calculations in Float arrays.

> 
> So my proposal is: Keep your data in some array or wherever they come 
> from (or poke them into one) which stores them safely in their genuine 
> way. Let GUI do its own job; GUI is for display only, and it makes the 
> user happy. When you have to evaluate some of the data in the GUI, the 
> user's action will point you to them, and you can easily peek the 
> genuine data from the data storage (array or whatever) in the background.

So what you are actually suggesting is I read the .csv into gridview and
I read it into some array and have everything double (once in the grid
and once in memory). I have quite some of those gridviews where csv
files are read into.

Then still reading a number from a .csv file (textbased) into a Float
array using Val() will give exactly the same trouble as it returns Null.

Is it not more simple to have Val() take regional settings into account,
or is that impossible to do?
Other solution is that I check regional settings and act accordingly.

But how to check regional setting from Gambas as this application will
be used in different countries, some with comma for decimal separator
others with dot.


-- 
Kind regards,

Willy (aka gbWilly)

http://gambasshowcase.org/
http://howtogambas.org
http://gambos.org



-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot1.png
Type: image/png
Size: 116694 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130514/e73f321d/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot2.png
Type: image/png
Size: 84953 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130514/e73f321d/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot3.png
Type: image/png
Size: 90816 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130514/e73f321d/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot5.png
Type: image/png
Size: 51489 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20130514/e73f321d/attachment-0003.png>


More information about the User mailing list