numeric get

numeric get

Postby Detlef » Wed Jul 19, 2023 7:24 pm

I have an edit control in an rc file in which a user should enter a numeric value.
Maximum of six digits but no value assigned because I don't want the user suggest a Zero.
Just
local nRgNum
...
REDEFINE GET oGet VAR nRgNum OF oDlg ID 20 PICTURE "999999" RIGHTTOLEFT

When the get becomes active the cursor stands about in the middle of this control.
I want to place the cursor at the right end of the get.
But this is only possible if I initialize the variable with '0' ( which I don't want to show )

Is it possible to display an empty get with a cursor waiting for input at the right end?

Thanks for any idea
Detlef
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: numeric get

Postby karinha » Wed Jul 19, 2023 10:49 pm

Esto/This?

Code: Select all  Expand view

   LOCAL nRgNum := ( "      " )


   // in resource = RIGHT
   REDEFINE GET oGet VAR nRgNum OF oDlg ID 20 PICTURE "999999" RIGHTTOLEFT ;
      UPDATE

   oGet:bGotFocus = { || oGet:SetPos( 0 ), nil }

   REPLACE NUMBER WITH VAL( nRgNum )
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7794
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: numeric get

Postby Detlef » Thu Jul 20, 2023 9:13 am

Dear karinha,
unfortunately, this doesn't work.
Image
The cursor starts at the red arrow not at the very right position.
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: numeric get

Postby Antonio Linares » Thu Jul 20, 2023 9:57 am

Dear Detlef,

Please modify FWH\samples\testget.prg this way:

@ 2, 6 GET oGet VAR nNum OF oDlg SIZE 60, 10 PICTURE "9999999.99" RIGHTTOLEFT

it seems to work fine. Please try it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: numeric get

Postby Detlef » Thu Jul 20, 2023 10:46 am

Dear Antonio,
this doesn't work as I need it.
If I initialize my variable with a numeric Zero it works.
But I don’t want to show a '0' inside the get. It should be empty.

Regards, Detlef
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: numeric get

Postby Antonio Linares » Thu Jul 20, 2023 10:49 am

If nNum is declared as nil then this error is generated:

Error description: Error BASE/1122 Argument error: TRANSFORM
Args:
[ 1] = U
[ 2] = C 9999999.99

It must be a number
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: numeric get

Postby Detlef » Thu Jul 20, 2023 11:09 am

You are right, Antonio.

My problem is to let an user input an integer value with a maximum of 6 digits.
But without showing a zero in the get control.
I could take a string value with picture "999999" and after transform it to numeric with val( cVar ).
Then the cursor starts at the left side but I want an input mode from right to left.
I can't bring this to work. :(
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: numeric get

Postby Antonio Linares » Thu Jul 20, 2023 11:17 am

Dear Detlef,

Please modify this line in tget.prg this way:

FW_SayText( ::hDC, If( Empty( Eval( ::bSetGet ) ), "", Transform( Eval( ::bSetGet ), ::cPicture ) ), aRect, "R", ::oFont, ::nClrText )

now it works as you need :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: numeric get

Postby Detlef » Thu Jul 20, 2023 12:25 pm

Many thanks, Antonio.
This works fine now. :D
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 52 guests