StringGadget : #PB_String_Numeric

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

StringGadget : #PB_String_Numeric

Post by Flype »

just a little but annoying bug ( or inappropriate behavior )
just test the snippet below :

Code: Select all

;- A sort of bug with StringGadget & #PB_String_Numeric

If OpenWindow(0,0,0,300,230,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"StringGadget Test")
  
  
  CreateGadgetList(WindowID())
  StringGadget(0,5, 5,290,20,"123.45",#PB_String_Numeric)
  StringGadget(1,5,35,290,20,"#ALPHA*/\",#PB_String_Numeric)
  
  
  Msg$ = "Let's test one thing or two... with PB3.94 Update 1" + Chr(10) + Chr(10)
  Msg$ + "1/ do you think it's normal that a numeric stringgadget accept alpha cars at initialisation ?" + Chr(10) + Chr(10)
  Msg$ + "2/ copy an alpha car from the stringgadget above and 'paste' it to the other : it works but it shoudn't works !" + Chr(10) + Chr(10)
  Msg$ + "A friend makes one of my prog violently crash because of this 'available feature'."
  TextGadget(2,5,65,290,160,Msg$,#PB_Text_Border)
  
  
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
  
  
EndIf
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Post by Lebostein »

Why I can't input "." and "-" in a numeric StringGadget(), for example "-123.50"?
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

you can ! by copy-paste from clipboard... :lol:
ok that's not a serious way...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: StringGadget : #PB_String_Numeric

Post by PB »

The #PB_String_Numeric flag is just the equivalent of the Microsoft ES_NUMBER
flag, so it behaves the way Microsoft intended. Microsoft's description for this
flag states: Allows only digits to be entered into the edit control. Note that, even
with this set, it is still possible to paste non-digits into the edit control.


(Taken from: http://tinyurl.com/9bl7m ).

> do you think it's normal that a numeric stringgadget accept alpha cars at initialisation ?

As per the above, yes, it's normal -- it only stops TYPED (ie. "entered") characters,
and only allows digits (ie. 0-9) and nothing else to be typed (ie. - and . etc).

> copy an alpha car from the stringgadget above and 'paste' it to the other
> it works but it shoudn't works

Again, see the description by Microsoft above. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

ok PB thanx for the explanation, so i don't agree the Microsoft way...
:wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Post Reply