FiveDBU

FiveDBU

Postby Otto » Wed Jul 02, 2014 8:18 am

Hello Antonio,
can you please provide a button for clipboard.


Image

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: FiveDBU

Postby Antonio Linares » Wed Jul 02, 2014 6:20 pm

Otto,

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

Code: Select all  Expand view
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 :-)

Image
regards, saludos

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

Re: FiveDBU

Postby Antonio Linares » Wed Jul 02, 2014 6:23 pm

Included in next FWH build :-)
regards, saludos

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

Re: FiveDBU

Postby Antonio Linares » Wed Jul 02, 2014 6:27 pm

If you make this little change in FiveDBU.prg line 1893, then it looks much better :-)

cCode += Space( 19 )

Image
regards, saludos

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

Re: FiveDBU

Postby Antonio Linares » Wed Jul 02, 2014 6:34 pm

Otto,

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

Code: Select all  Expand view
  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
User avatar
Antonio Linares
Site Admin
 
Posts: 41365
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 19 guests