FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FiveDBU
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
FiveDBU
Posted: Wed Jul 02, 2014 08:18 AM
Hello Antonio,
can you please provide a button for clipboard.




Thanks in advance
Otto
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveDBU
Posted: Wed Jul 02, 2014 06:20 PM
Otto,

In FiveDBU.prg please replace function TxtStruct( oBrw ) with this one:

Code (fw): Select all Collapse
function TxtStruct( oBrw )

   local cCode := "local aFields := { ", n, bClipboard

   if Empty( oBrw:oRs )
      for n = 1 to FCount()
         if n > 1
            cCode += Space( 27 )
         endif
         cCode += '{ "' + FieldName( n ) + '", "' + ;
                  FieldType( n ) + '", ' + ;
                  AllTrim( Str( FieldLen( n ) ) ) + ", " + ;
                  AllTrim( Str( FieldDec( n ) ) ) + " },;" + CRLF
      next
   else
      for n = 1 to oBrw:oRS:Fields:Count
         if n > 1
            cCode += Space( 27 )
         endif
         cCode += '{ "' + oBrw:oRS:Fields[ n - 1 ]:Name + '", "' + ;
                  FWAdoFieldType( oBrw:oRs, n ) + '", ' + ;
                  AllTrim( Str( FWAdoFieldSize( oBrw:oRs, n ) ) ) + ", " + ;
                  AllTrim( Str( FWAdoFieldDec( oBrw:oRs, n ) ) ) + ;
                  " },;" + CRLF
      next
   endif   

   cCode = SubStr( cCode, 1, Len( cCode ) - 4 ) + " }" + CRLF + CRLF

   if Empty( oBrw:oRs )
      cCode += 'DbCreate( "myfile.dbf", aFields, "' + RddName() + '" )'
   endif   

   bClipboard = { | oDlg | AddClipboardButton( oDlg, cCode ), cCode }

   MemoEdit( bClipboard, FWString( "Code" ) )

return nil

//----------------------------------------------------------------------------//

function CopyToClipboard( cText )

   local oClip := TClipBoard():New()
   
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   
   oClip:End()
   
return nil   

//----------------------------------------------------------------------------//

function AddClipboardButton( oDlg, cText )

   local oBtn

   @ 238, 6 BUTTON oBtn PROMPT FWString( "Copy to clipboard" ) ;
      OF oDlg SIZE 140, 28 PIXEL ;
      ACTION ( CopyToClipboard( cText ),;
               MsgInfo( FWString( "Code copied to the clipboard" ) ) )
      
return nil      

//----------------------------------------------------------------------------//


And this little change in FWH function MemoEdit() (source\function\memoedit.prg line 56):

If( bText != nil, oMemo:SetText( Eval( bText, oDlg ) ),),;

And here you have it :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveDBU
Posted: Wed Jul 02, 2014 06:23 PM

Included in next FWH build :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveDBU
Posted: Wed Jul 02, 2014 06:27 PM
If you make this little change in FiveDBU.prg line 1893, then it looks much better :-)

cCode += Space( 19 )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FiveDBU
Posted: Wed Jul 02, 2014 06:34 PM
Otto,

This version is better as it also saves the changes that you may do in the code:

Code (fw): Select all Collapse
   bClipboard = { | oDlg | AddClipboardButton( oDlg ), cCode }

   MemoEdit( bClipboard, FWString( "Code" ) )

return nil

//----------------------------------------------------------------------------//

function CopyToClipboard( cText )

   local oClip := TClipBoard():New()
   
   if oClip:Open()
      oClip:SetText( cText )
      oClip:Close()
   endif
   
   oClip:End()
   
return nil   

//----------------------------------------------------------------------------//

function AddClipboardButton( oDlg, cText )

   local oBtn

   @ 238, 6 BUTTON oBtn PROMPT FWString( "Copy to clipboard" ) ;
      OF oDlg SIZE 140, 28 PIXEL ;
      ACTION ( CopyToClipboard( oDlg:aControls[ 1 ]:GetText() ),;
               MsgInfo( FWString( "Code copied to the clipboard" ) ) )
      
return nil      

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion