FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in TGet
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 01: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 02: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 02:26 PM
You are right. But the following pure Clipper samples works fine if we paste in the console:

Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 02:27 PM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 02: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 02:38 PM
Enrico,

This change in FWH Class TGet seems to work fine :-)
Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TGet
Posted: Fri Dec 04, 2009 02:50 PM
Cursor position was not properly set. Now it is fine:
Code (fw): Select all Collapse
      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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Bug in TGet
Posted: Sun Dec 06, 2009 03:54 PM

Great Antonio !!!

Continue the discussion