copy a row of xbrowse

User avatar
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Post by Silvio.Falconi »

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: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Post by Silvio.Falconi »

As suggestion by Marcelo

Code: Select all | Expand

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: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Post by Silvio.Falconi »

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
Otto
Posts: 6380
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: copy a row of xbrowse

Post by Otto »

> 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
Silvio.Falconi
Posts: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Post by Silvio.Falconi »

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

 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: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Post by Silvio.Falconi »

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: 7104
Joined: Thu Oct 18, 2012 7:17 pm

Re: copy a row of xbrowse

Post by Silvio.Falconi »

try can run ok now

Code: Select all | Expand

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
Post Reply