Page 1 of 1

Entering a negative number in tGet

Posted: Tue Jun 06, 2006 10:29 am
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

Posted: Tue Jun 06, 2006 1:39 pm
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

Posted: Tue Jun 06, 2006 2:18 pm
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

Posted: Tue Jun 06, 2006 5:01 pm
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

Posted: Tue Jun 06, 2006 5:34 pm
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 ?

Posted: Wed Jun 07, 2006 7:11 am
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() ?????

Posted: Wed Jun 07, 2006 8:56 am
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

Posted: Wed Jun 07, 2006 10:23 am
by Antonio Linares
Frank,

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

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

Posted: Fri Jun 09, 2006 7:29 am
by Frank Demont
Antonio,

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

Frank

Posted: Fri Jun 09, 2006 8:09 am
by Enrico Maria Giordano
What was the problem?

EMG

Posted: Fri Jun 09, 2006 10:47 am
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

Posted: Fri Jun 09, 2006 12:13 pm
by Enrico Maria Giordano
Ok, thank you.

EMG