Re: Cast from gchar* to int?
- From: Martyn Russell <ginxd btopenworld com>
- To: "William L. Thomson Jr." <support obsidian-studios com>
- Cc: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Re: Cast from gchar* to int?
- Date: Tue, 24 Sep 2002 23:38:09 +0100
William L. Thomson Jr. wrote:
Martyn,
On Tue, 2002-09-24 at 15:13, Martyn Russell wrote:
It looks to me like you are using the wrong control. Perhaps you want a
spin button? This would mean you could guarantee an integer and not a
string with other character (not 0-9) AND you can get an int using a gtk
function call:
I had thought about it, but prefer the look of the regular text field. I
have buttons that will handle the incrementing up or down, as well as
extracting the relevant data from a database and filling in all
appropriate fields
there is also a function to get it as a float. Remember if using this
control to call _gtk_spin_button_set_numeric_ to make sure it ONLY
accepts numeric values.
I like that the spin_button can be set to only accept numeric input. I
have not found a similar function call for the regular entry fields.
Now with that said, from playing with the spin_button, is there a way to
not specify a maximum size? The max size will be determined by seeing if
the table in the database has that many rows. I could set it at run
time, but it would be another query. One that I would like to avoid if
possible.
I dont think so, the max is what ever you specify and it is a double so
you could just make it the maximum possible for a double.?!
I really would like to stick with the standard gtk_entry widget, and not
use the spin_button if I can. It should be possible, no?
If you're not worried about actually entering anything into the textbox
(i.e just using the buttons to increment and decrement) you could always
just use a gtk_adjustment which isnt visible to the end user and you
could control it yourself and make your own simple version of the
spinbutton. ?
I am not really worried about non numeric input, because only
intelligent people will be using this app internally. We know to only
put numeric input in numeric fields.
I just really would like to know how to convert a char* to an int, and
why the atoi functions and others will not do this for me. Not to
mention why they output 0.
If I test with a regular numeric string and convert to an int/long/etc
using the atoi/atol/etc functions it works. If I swap out my hard coded
numeric string with the input from the gtk_entry field I get 0.
Really strange and a little frustrating.
Thanks for your input though, I may still have to use the spin_button,
so thanks for the suggestion.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]