FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour copy a row of xbrowse
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: copy a row of xbrowse
Posted: Wed Dec 06, 2023 08: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 March-April 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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: copy a row of xbrowse
Posted: Wed Dec 06, 2023 08:52 AM
As suggestion by Marcelo
Code (fw): Select all Collapse
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 March-April 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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: copy a row of xbrowse
Posted: Wed Dec 06, 2023 09: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 March-April 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
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: copy a row of xbrowse
Posted: 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

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: copy a row of xbrowse
Posted: 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 (fw): Select all Collapse
 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 March-April 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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: copy a row of xbrowse
Posted: 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 March-April 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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: copy a row of xbrowse
Posted: Wed Dec 06, 2023 12:14 PM
try can run ok now
Code (fw): Select all Collapse
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 March-April 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

Continue the discussion