Numeric Text Box

Moderator: Rathinagiri

Post Reply
MGOLDFARB
Posts: 71
Joined: Thu Jun 21, 2012 7:46 am

Numeric Text Box

Post by MGOLDFARB »

Anyone have any suggestion on how I can have a numeric textbox display as blank when the value is zero (instead of zero)?

Thanks
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Numeric Text Box

Post by Rathinagiri »

Just see this sample:

Code: Select all

#include <hmg.ch>

Function Main
   define window main at 0, 0 width 400 height 300 main
      define textbox num1
         row 10
         col 10
         width 100
         value 0
         numeric .t.
         inputmask "999.99"
      end textbox
      define textbox num2
         row 40
         col 10
         width 100
         value 0
         numeric .t.
         inputmask "999.99"
      end textbox
      define button but1
         row 70
         col 10
         caption 'Make empty'
         action main.num2.value := ''
      end button
   end window
  Main.Center
  Main.Activate

Return
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Numeric Text Box

Post by esgici »

Clipper 5.2e wrote:Picture Codes
------------------------------------------------------------------------------
  • Get Picture Functions
    --------------------------------------------------------------------------------
    A C Allow only alpha characters
    B N Display numbers left-justified
    C N Display CR after positive numbers
    D D,N Display dates in SET DATE format
    E D,N Display dates with day and month inverted
    independent of the current DATE SETting,
    numerics with comma and period reverse
    K All Delete default text if first key is not a cursor key
    R C Insert non-template characters in the display but do not
    save in the Get variable
    S<n> C Allows horizontal scrolling within a Get. <n> is an integer
    that specifies the width of the region
    X N Display DB after negative numbers
    Z N Display zero as blanks
    ( N Display negative numbers in parentheses with leading spaces
    ) N Display negative numbers in parentheses without leading spaces
    ! C Convert alphabetic character to upper case
20 years ago ... :(
Viva INTERNATIONAL HMG :D
MGOLDFARB
Posts: 71
Joined: Thu Jun 21, 2012 7:46 am

Re: Numeric Text Box

Post by MGOLDFARB »

I know about the picture options from 20+ years ago.
How do you simulate the picture options in HMG windows?

Thanks!

Mark
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Numeric Text Box

Post by esgici »

Hi Mark
MGOLDFARB wrote:I know about the picture options from 20+ years ago.
How do you simulate the picture options in HMG windows?

Thanks!

Mark
My reminder isn't to you, to HMG developers ;)

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Numeric Text Box

Post by Pablo César »

Good workaround, dear friend Rathinagiri ! I make another example based on your one:

Code: Select all

#include <hmg.ch>

Function Main()
define window main at 0, 0 width 400 height 300 main
   define textbox num1
      row 10
      col 10
      width 100
      value 0
      numeric .t.
      inputmask "999.99"
	 ON LOSTFOCUS (If(This.Value=0.0,This.Value:='',))
   end textbox
   define textbox num2
      row 40
      col 10
      width 100
      value 0
      numeric .t.
      inputmask "999.99"
	 ON LOSTFOCUS (If(This.Value=0.0,This.Value:='',))
   end textbox
end window
Main.Center
Main.Activate
Return Nil
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Numeric Text Box

Post by Pablo César »

esgici wrote:My reminder isn't to you, to HMG developers
Hola amigo, are you trying to call back attention for this missing inputmask resource in HMG ? And suggesting to HMG's contributors for developing ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Numeric Text Box

Post by esgici »

Pablo César wrote:... are you trying to call back attention for this missing inputmask resource in HMG ? And suggesting to HMG's contributors for developing ?
Hola Amigo Pablo :)

Thanks to your attention :)

No criticizing nor faultfinding; only a humble observation and only a wish.

And I want to call attention of developers, no contributors ;)

Me too I have same ideas, but you know :

- HMG doesn't accept contributions to the core of library,
- I not have capabilities nor desire to interfere to library,
- and I not have ability to solving problems by some hocus-pocus with some love-level interventions.

Anyway, If you have some ideas to solve this zero-suppressing problem I want learn it eagerly.

Saludos cordiales :D
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Numeric Text Box

Post by Pablo César »

Well our good friend Rathinaghiri appointed a simples solution.
To implement deep in HMG library, we should modified function _DefineMaskedTextbox at C:\hmg.3.1.1\SOURCE\h_textbox.prg, but as you said propbably is not be accepted "@Z" as INPUTMASK or FORMAT one.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Numeric Text Box

Post by esgici »

Pablo César wrote:Well our good friend Rathinaghiri appointed a simples solution.
To implement deep in HMG library, we should modified function _DefineMaskedTextbox at C:\hmg.3.1.1\SOURCE\h_textbox.prg, but as you said propbably is not be accepted "@Z" as INPUTMASK or FORMAT one.
Yes, agreed; it's a simple solution; until "@Z" will be accepted as INPUTMASK in TextBox control.

But I have some questions yet :(

There is a paradox in the

Code: Select all

If(This.Value=0.0,This.Value:='',)
statement for me:

Code: Select all

if valtype( This.Value ) = "N"
   This.Value:='' is wrong;
elseif valtype( This.Value ) = "C"
   If(This.Value=0.0 is wrong !
... and more important : ON CHANGE doesn't work instead of ON LOSTFOCUS; why ?

... and answer :

because whenever changed textbox value (by user or by program), ON CHANGE event re-triggered and program goes to endless loop :(


TIA
Viva INTERNATIONAL HMG :D
Post Reply