Page 3 of 3

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 8:25 am
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

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 8:52 am
by Silvio.Falconi
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

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 9:13 am
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

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 10:53 am
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

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 11:52 am
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 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

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 12:04 pm
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

Re: copy a row of xbrowse

PostPosted: Wed Dec 06, 2023 12:14 pm
by Silvio.Falconi
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