Bug in TGet

Re: Bug in TGet

Postby nageswaragunupudi » Fri Dec 04, 2009 1:50 pm

This is my understanding of the behavior of non-template characters in the picture clause, consistent from the days of Clipper till now in (x)Harbour.

When a picture clause containing non-template characters is used to transform a numeric value, the non-template characters are inserted. But when a character value is transformed, the non-template characters are substituted unless '@R ' mask is used.

Transform( "12345678901", "999-999-999" ) --> "123-567-901"
Transform( "123456789", "@R 999-999-999" ) --> "123-456-789"
Transform( 123456789, "999-999-999" ) --> "123-456-789"
Transform( 123456789, "@R 999-999-999" ) --> "123-456-789"

The behavior reported by Mr. EMG is correct and that is what should be expected. I do not think there is any bug either in FWH or in (x)Harbour.

If I am still missing anything I am interested to know.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10482
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bug in TGet

Postby Antonio Linares » Fri Dec 04, 2009 2:16 pm

Rao,

Many thanks for the very valuables examples.

I think this may be the way to go:
Transform( 123456789, "999-999-999" ) --> "123-456-789"

We could check the type() of the pasted value and if numeric, then use Val()

thinking about it...
regards, saludos

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

Re: Bug in TGet

Postby Enrico Maria Giordano » Fri Dec 04, 2009 2:26 pm

You are right. But the following pure Clipper samples works fine if we paste in the console:

Code: Select all  Expand view
FUNCTION MAIN()

    LOCAL GetList := {}

    LOCAL cVar := SPACE( 39 )

    @ 1, 1 GET cVar;
           PICTURE "999-999-999-999-999-999-999-999-999-999"

    READ

    INKEY( 0 )

    RETURN NIL


// 123456789012345678901234567890


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8568
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TGet

Postby Antonio Linares » Fri Dec 04, 2009 2:27 pm

ops, cVar is character type, so we can't use Val()...
regards, saludos

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

Re: Bug in TGet

Postby Antonio Linares » Fri Dec 04, 2009 2:29 pm

Enrico,

I think thats because console's paste types each character, one by one.

Maybe thats the way to go: We could use a for next to type each pasted character
regards, saludos

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

Re: Bug in TGet

Postby Antonio Linares » Fri Dec 04, 2009 2:38 pm

Enrico,

This change in FWH Class TGet seems to work fine :-)
Code: Select all  Expand view

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TGet

   local oClp, cText, n
   ...
      case nMsg == WM_PASTE
           if GetFocus() == ::hWnd
              CallWindowProc( ::nOldProc, ::hWnd, WM_PASTE, 0, 0 )
              DEFINE CLIPBOARD oClp OF Self FORMAT TEXT
              cText = oClp:GetText()
              oClp:End()
              for n = 1 to Len( cText )
                 if Set( _SET_INSERT )
                    ::oGet:Insert( SubStr( cText, n, 1 ) )
                 else
                    ::oGet:Overstrike( SubStr( cText, n, 1 ) )
                 endif
              next  
              SetWindowText( ::hWnd, ::oGet:buffer )
              ::oGet:Assign()
           endif  
           return 0
   ...
 
regards, saludos

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

Re: Bug in TGet

Postby Antonio Linares » Fri Dec 04, 2009 2:50 pm

Cursor position was not properly set. Now it is fine:
Code: Select all  Expand view

      case nMsg == WM_PASTE
           if GetFocus() == ::hWnd
              CallWindowProc( ::nOldProc, ::hWnd, WM_PASTE, 0, 0 )
              DEFINE CLIPBOARD oClp OF Self FORMAT TEXT
              cText = oClp:GetText()
              oClp:End()
              for n = 1 to Len( cText )
                 if Set( _SET_INSERT )
                    ::oGet:Insert( SubStr( cText, n, 1 ) )
                 else
                    ::oGet:Overstrike( SubStr( cText, n, 1 ) )
                 endif
              next  
              SetWindowText( ::hWnd, ::oGet:buffer )
              ::SetPos( ::oGet:Pos )
              ::oGet:Assign()
           endif  
           return 0
 
regards, saludos

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


Re: Bug in TGet

Postby Enrico Maria Giordano » Sun Dec 06, 2009 3:11 pm

Works like a charm!

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8568
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TGet

Postby Massimo Linossi » Sun Dec 06, 2009 3:54 pm

Great Antonio !!!
User avatar
Massimo Linossi
 
Posts: 495
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

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

cron