Entering a negative number in tGet

Post Reply
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Entering a negative number in tGet

Post by Frank Demont »

Hello,

3 weeks ago i asked the same question , but i was on vacation for two weeks , so i try it again

In mine main aplication i have a dialog from resources , with a lot of get's (numeric value)

Each numeric get has a picture clause :

REDEFINE GET oGet VAR nInp ID 157 PICTURE "@K #99" OF Odlg

Entering a value as -99 , give no problems (no reformatting is needed)

BUT :

entering -9 , pressing TAB or ENTER reformats the get WITHOUT '-' SIGN !!!

Testing with testget2 , changing the get in REDEFINE GET ... to have the same situation give no problems !!!!

So i tryed to change tget.prg in METHOD KeyChar( nKey, nFlags )

case nKey == VK_TAB .or. nKey == VK_RETURN
trace(::oget:buffer,::varget()) // Shows -9 , 0

Trace executes a msginfo , but the (wrong) reformatting is all ready executed

So it seems that something go wrong BEFORE this statement.but where ?

Using fw2.7 , march , last xhb

Frank
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

The last i found is that in method lostfocus

if ! ::oGet:BadDate .and. ! ::lReadOnly .and. ;
( ::oGet:changed .or. ::oGet:unTransform() <> ::oGet:original )
::oGet:Assign() // for adjust numbers
# ifdef TEST
if ! Empty( ::cPicture ) .and. ::oGet:type == "N"
trace(::Varget() , ::lPassword , GetWindowText( ::hWnd ) , ::oGet:buffer)
end
# endif
::oGet:UpdateBuffer()
endif

::varget() is changed from negative to positive after ::oGet:Assign()

Where is this method ? In tget i see only :

METHOD Assign() INLINE ::oGet:Assign()

I suppose it is a tClipGet method , but don't find it

Frank
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

Method VarGet() is implemented in Class TControl.

What value has nInp before using it ?
REDEFINE GET oGet VAR nInp ID 157 PICTURE "@K #99" OF Odlg
regards, saludos

Antonio Linares
www.fivetechsoft.com
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

Antonio

It is important to me that this is fixed : my customer can't agree with an aplication where no negative numbers can't be entered.

Now , i have the modifyed tget.prg i use to test , linked in testget2.prg.

Now , i see a difference in method lostfocus.

In mine aplication seems for some reason ::oGet:Baddate seems to be set on .T. . So (In method lostfocus) , the sequens :


if ! ::oGet:BadDate .and. ! ::lReadOnly .and. ;
( ::oGet:changed .or. ::oGet:unTransform() <> ::oGet:original )
....

endif

is executed , and as i posted before ::oGet:Assign() changes in this case oget:varget() from negative in positive.

I do not understand at this moment why and how ::oGet:baddate become .T. , but probably the get becomes a non numeric value before the get become focus

Frank
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

samples\TestGet2.prg using PICTURE "@K #99" works ok. Whats the difference with your code ? Do you store a number or a string in your variable ?

Could you provide a small and self contained sample to reproduce the problem ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

Antonio

Executing this code from method lostfocus give as difference :
if ! Empty( ::cPicture ) .and. ::oGet:type == "N"
//tracelog(::Varget())
::oGet:Assign()
::oGet:Picture := ::cPicture
::oGet:UpdateBuffer()
::oGet:KillFocus()
endif

::oGet:SetFocus() // to avoid oGet:buffer be nil

# ifdef TEST
trace( ::oGet:changed , ::oGet:unTransform() , ::oGet:original)
// Main aplication : .F. , 1 , -1
// testget2 /.F. , -1 , -1
# endif



In the main aplication :

Inputvalue 1 changed in -1 , ::oGet:untransform() gives 1 , so the next If .... then is executed

In testget2.prg

Inputvalue 0 is changed in -1 , ::oGet:untransform() gives -1 , so the next If .... then is NOT executed

In both aplications is the same tget linked in !

Placing the trace statement :

before killfocus gives correct result (.T. , -1 , 1 )
after killfocus .T. , nil , nil

I am testing on get with a numeric value. This valus is not changed by other mechanism

Frank


Where is the code from ::oget:untransform() ?????
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Frank, please take the time to build a reduced and self-contained sample of the problem. Otherwise it will be very difficult to help you.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Frank,

> Where is the code from ::oget:untransform() ?????

Its at harbour/xharbour (source code) Class Get.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

Antonio,

Thanks for the info , now i found it . It works as expected

Frank
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

Enrico

In mine main aplication was the xhb-function IsdIGIT(str) overwritten by isdigit(Str,count) , as in funcky .

This function gives a wrong result for str==CHR(32) , so in ::untransform ::minus wasn't set corectly

Frank
Post Reply