copy a row of xbrowse

Re: copy a row of xbrowse

Postby Silvio.Falconi » Wed Dec 06, 2023 8:25 am

Marcelo Via Giglio wrote:try using aclone, aCopy := aclone( oBrw:aRow )



Marcelo,

No es el problema de copiar una fila, esto lo hace, el problema es que quiero copiar varias filas al mismo tiempo y si modifico una fila y guardo, las demás también modifican, es como si las filas copiadas tuvieran lo mismo. número de registros en la matriz
intenta compilar la última prueba, copia una línea y luego ve a editar la línea y verás qué sucede
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Wed Dec 06, 2023 8:52 am

As suggestion by Marcelo

Code: Select all  Expand view
MENUITEM "Copy" WHEN acopy=NIL .and. oBrw:IsSelectedRow();  // only when is seletected
   ACTION ( aCopy := aclone(oBrw:aRow),;
   oBrw:SetFocus() )


Seem run ok also if I modify the row But copy one row
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Wed Dec 06, 2023 9:13 am

Perhaps...


MENUITEM "Copy" WHEN acopy=NIL .and. oBrw:IsSelectedRow(); // only when is seletected
ACTION IIF(Len(oBrw:aseleted) >1,Aclone:=Giverows(oBrw),aCopy := aclone(oBrw:aRow)),;
oBrw:SetFocus() )



Function Giverows(oBrw)
local n,uBook,nAt
local aTmp:= {}
For n = 1 to len(oBrw:aselected)
uBook := Eval( oBrw:bBookMark )
nAt := Ascan( oBrw:aSelected, uBook )
aCopy:= aclone(oBrw:aArrayData[ nAt ])
Next
return acopy
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Otto » Wed Dec 06, 2023 10:53 am

> FOR EACH nRow IN oBrw:aSelectedRows
> NOT EXIST IN XBROWSE !!!!!!
> wich xbrowse you have ? I have the last release of fwh


Silvio,
Here you have the solution. But, look also into xbrowse.prg in C:\FWH\Source\Classes\xbrowse.prg.

MENUITEM "Copy" WHEN acopy=NIL ACTION ( aCopy := oBrw:aRow,;
oBrw:SetFocus(), xbrowse(oBrw:aSelected) )



All you need is there. This is the biggest benefit of FiveWin that you have source code of the classes.
And xbrowse() is so great for debugging.

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

Re: copy a row of xbrowse

Postby Silvio.Falconi » Wed Dec 06, 2023 11:52 am

Otto wrote:> FOR EACH nRow IN oBrw:aSelectedRows
> NOT EXIST IN XBROWSE !!!!!!
> wich xbrowse you have ? I have the last release of fwh


Silvio,
Here you have the solution. But, look also into xbrowse.prg in C:\FWH\Source\Classes\xbrowse.prg.

MENUITEM "Copy" WHEN acopy=NIL ACTION ( aCopy := oBrw:aRow,;
oBrw:SetFocus(), xbrowse(oBrw:aSelected) )



All you need is there. This is the biggest benefit of FiveWin that you have source code of the classes.
And xbrowse() is so great for debugging.

Best regards,
Otto



Otto,
For Only one Row this run ok (also on modify)

Code: Select all  Expand view
MENUITEM "Copy" WHEN acopy=NIL .and. oBrw:IsSelectedRow();  // only when is seletected
              ACTION ( aCopy := aclone(oBrw:aRow),;
              oBrw:SetFocus()   )


For many rows selected Not run ok

oBrw:aSelected give number or numbers not the row
oBrw:aRow is as ::aArrayData[ ::nArrayAt ]


you can make

For n= 1 to Len( oBrw:aselected)
nAt := oBrw:aArrayData[ oBrw:aselected[n] ]
aadd( acopy, aclone(nat))
next


just an idea
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Wed Dec 06, 2023 12:04 pm

MENUITEM "Copy" WHEN acopy=NIL .and. oBrw:IsSelectedRow(); // only when is seletected
ACTION ( IIF(Len(oBrw:aselected) >1,aClone:=Giverows(oBrw),;
aCopy := aclone(oBrw:aRow)),;
oBrw:SetFocus() )


Function Giverows(oBrw)
local n,atmp:={},nAt
For n= 1 to Len( oBrw:aselected)
nAt := oBrw:aArrayData[ oBrw:aselected[n] ]
aadd( aTmp, aclone(nat))
next
return aTmp



But then the paste is wrong
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Postby Silvio.Falconi » Wed Dec 06, 2023 12:14 pm

try can run ok now

Code: Select all  Expand view
function PopMenu( oCol, codsep )

   local oBrw  := oCol:oBrw
   local nCol
   local oPop

   MENU oPop POPUP 2010
   MENUITEM "Codsep:"+codsep
    SEPARATOR
        if oBrw:IsSelectedRow()
              MENUITEM "Deselect the current row" action (oBrw:SelectRow( 0 ) )
              MENUITEM "Deselect all"             action (oBrw:SelectRow( 0 ))
              else
              MENUITEM "Select the current row"   action ( oBrw:SelectRow( 2 ) )
              MENUITEM "Select All"               action (oBrw:SelectRow( 4 ) )
           endif
    SEPARATOR

   MENUITEM "Copy" WHEN acopy=NIL .and. oBrw:IsSelectedRow();  // only when is seletected
   ACTION ( aCopy:=Giverows(oBrw),;
           oBrw:SetFocus()   )
   MENUITEM "Paste" WHEN acopy!=NIL ACTION Paste(oBrw,codsep)
   ENDMENU

   return oPop
//------------------------------------------------------//
Function Paste(oBrw,codsep)
     oBrw:Lock()
              For n=1 to Len(acopy)
                aCopy[n][1] := codsep
                aCopy[n][8] := 0
                aadd( oBrw:aArrayData, aCopy[n] )
              Next
      oBrw:Unlock( .t. )
      acopy:=NIL
      oBrw:RefreshCurrent()
      oBrw:SetFocus()
     return nil
//------------------------------------------------------//
Function Giverows(oBrw)
      local n,atmp:={},nAt
        For n= 1 to Len( oBrw:aselected)
           nAt := oBrw:aArrayData[ oBrw:aselected[n] ]
           aadd( aTmp, aclone(nat))
        next
    return aTmp

 



Now run ok with one row and more rows


But if Nages found a good solution is wellcome
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Antonio Linares and 91 guests