FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Entering a negative number in tGet
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Entering a negative number in tGet
Posted: Tue Jun 06, 2006 10:29 AM

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

Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Entering a negative number in tGet
Posted: Tue Jun 06, 2006 01:39 PM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Entering a negative number in tGet
Posted: Tue Jun 06, 2006 02:18 PM

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
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Entering a negative number in tGet
Posted: Tue Jun 06, 2006 05:01 PM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Entering a negative number in tGet
Posted: Tue Jun 06, 2006 05:34 PM

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
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Entering a negative number in tGet
Posted: Wed Jun 07, 2006 07:11 AM

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() ?????

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Entering a negative number in tGet
Posted: Wed Jun 07, 2006 08:56 AM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Entering a negative number in tGet
Posted: Wed Jun 07, 2006 10:23 AM

Frank,

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

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Entering a negative number in tGet
Posted: Fri Jun 09, 2006 07:29 AM

Antonio,

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

Frank

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Entering a negative number in tGet
Posted: Fri Jun 09, 2006 08:09 AM

What was the problem?

EMG

Posts: 142
Joined: Sun Oct 09, 2005 10:59 AM
Entering a negative number in tGet
Posted: Fri Jun 09, 2006 10:47 AM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Entering a negative number in tGet
Posted: Fri Jun 09, 2006 12:13 PM

Ok, thank you.

EMG

Continue the discussion