Página 1 de 1

dbedit e deleted()

Enviado: 12 Fev 2010 08:52
por lapinhazzz
Bom Dia amigos do forum

Desde já deixo as minhas desculpas por às vezes não responder agradecendo algum esclarecimento.

Bom, tenho um problema


Tenho uma base de dados com 10 registos (exemplo) e os 3 primeiros estão deletados.
Agora queria fazer um browse com o dbedit só mostrando os arquivos deletados.
Ou seja sempre que eu deleto um registo a base de dados fica marcada como del.
Tenho uma opção para recuperar o registo apagado.
Mas eu queria que os registos deletados fossem apresentados no ecra no modo de dbedit só filtrar os registos deletados.

A intenção é mostrar os registos deletados e depois escolher qual aqueles que deve desmarcar marcando de lado o chr quadrado nos cantos do registo no browse


Como faço,
Deêm-me um exemplo.

Obrigado.

lapinhazzz

Re: dbedit e deleted()

Enviado: 12 Fev 2010 11:36
por EANDRIOLI
Bom dia...

Creio que usando um SET FILTER ou INDEX vai resolver o problema

Erasmito.

Re: dbedit e deleted()

Enviado: 12 Fev 2010 11:40
por sygecom
Pode fazer assim:

Código: Selecionar todos

Function MAIN()
USE AGENDA ALIAS AGENDA SHARED
INDEX ON algum_campo for Deleted() TO nome_indice TEMPORARY
SELE AGENDA
dbedit()
Return

Re: dbedit e deleted()

Enviado: 12 Fev 2010 12:31
por lapinhazzz
amigo sygecom como farei para o seguinte


A base de dados tem os seguintes registos deletados


venda cliente data total Status
001 cliente 1 05/02/2010 5,00 Eur deleted ■
002 cliente 2 06/05/2010 10,00 Eur deleted
003 cliente 3 07/10/2010 25,00 Eur deleted ■

se carregando no espaço na venda 001 e venda 002 então aparece no browse ao lado do registo o codigo o chr(254) que significa que estas duas vendas é para recuperar ou seja tirar o deleted
chr(254) é um quadrado do ascii.

Como faço para fazer tal situação


Agradeço desde já

Obrigado a todos


lapinhazzz

Re: dbedit e deleted()

Enviado: 12 Fev 2010 13:10
por rochinha
Amiguinho,

Como voce usa DBEdit() voce pode configurar na função que é passada para ele uma tecla, exemplo DEL, para deletar ou recuperar o registro deletado.

Em seu DBEdit() voce pode colorizar o registro com cor diferente dos registros normais.

Para colorizar voce tera de criticar com iif() se deleted() ou não.

Para deletar ou recuperar voce pode usar iif( deleted(), dbRecall(), dbDelete() ) ou iif( deleted(), Recupera(), Deleta() )

Suas funções Recupera() e Deleta() devem perguntar se faz ou não a operação e produz o resultado.

Ou faça como o Sygecom apresentou, mas coloque a criação do indice que controla deletados como padrão em sua rotina de indexação e não temporariamente e crie uma opção que apresente os registros inativos/eliminados.

Re: dbedit e deleted()

Enviado: 12 Fev 2010 13:49
por lapinhazzz
Amigo Rochinha

poderá me apresentar uma pequena rotina para dar cor no registo que está a ser seleccionado para recuperação.
Se carregar na tecla espaço então o registo no dbedit muda de cor e fica pronto para recuperação (marca ou desmarca).

Muda de cor quando marca e quando desmarca volta ao normal, ou então no inicio e no inicio do registo quando marca aparece o chr(254) e quando desmarca desaparece o chr(254).

Não estou a ver como fazer isso.

Apresente-me uma pequenininha rotina por favor


obrigado

lapinhazzz

Re: dbedit e deleted()

Enviado: 12 Fev 2010 17:27
por rochinha
Amiguinho,

Acrescente este código ao .PRG principal e compile, veremos o que conseguir.

O DBEdit() no Clipper é uma facilidade de acesso ao TBrowse() portanto se verificar o código abaixo verá que o mesmo chama o TBrowse() para configura-lo.

Eu acrescentei as linhas que verificam a colorização dentro deste DBEdit(), verifique especialmente por ColorSpec e ColorBlock.

Atente para o fato que as alterações foram feitas por verificação deste código com outros para completa-lo e não fiz um teste real para verificar o resultado, mas com um pouco de afinco voce conseguirá aprender a manipula-lo e enfim passar a usar o TBrowse().

MyDBEdit.prg

Código: Selecionar todos

/*
* 
* DBEdit Source
* 
*/
#include "common.ch"
#include "inkey.ch"

//-----------------------------------------------------------------
//  file-wide static variables
// static Static1, Static2

function DBEDIT( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, ;
   Arg9, Arg10, Arg11, Arg12 )

   local Local1, Local2, Local3, Local4, Local5, Local6, Local7, ;
      Local8, Local9, Local10
   public Static1, Static2
   if ( EOF() )
      goto bottom
   endif
   Local1 := dbedsetup(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, ;
      Arg8, Arg9, Arg10, Arg11, Arg12)
   Local1:skipblock({ |_1| skipped(_1) })
   Local1:autolite(.F.)
   Local2 := setcursor(0)
   Local7 := {Static1, Static2}
   Static1 := .F.
   Static2 := .T.
   Local5 := .T.
   Local3 := .T.
   do while ( Local3 )
      do while ( !Local1:stabilize() )
         if ( ( Local4 := nextkey() ) == 0 )
         elseif ( Local4 != 1001 )
            exit
         endif
      enddo
      if ( ( Local4 := InKey() ) == 0 )
         if ( Local5 )
            Local3 := calluser(Local1, Arg6, 0)
            do while ( !Local1:stabilize() )
            enddo
         endif
         if ( Local3 .AND. Static2 )
            Local1:hilite()
            do while ( ( Local4 := InKey(0) ) == 1001 )
            enddo
            Local1:dehilite()
            if ( ( Local6 := SetKey(Local4) ) != Nil )
               eval(Local6, procname(1), procline(1), "")
               loop
            endif
         else
            Static2 := .T.
         endif
      endif
      Local5 := .T.
      do case
      case Local4 == 1002 .OR. Local4 == 1006
         do case
         case ( Local9 := mrow() ) < Local1:ntop()
         case ( Local10 := mcol() ) < Local1:nleft()
         case Local9 > Local1:nbottom()
         case Local10 <= Local1:nright()
            Local8 := Local1:mrowpos() - Local1:rowpos()
            do while ( Local8 < 0 )
               Local8++
               Local1:up()
            enddo
            do while ( Local8 > 0 )
               Local8--
               Local1:down()
            enddo
            Local8 := Local1:mcolpos() - Local1:colpos()
            do while ( Local8 < 0 )
               Local8++
               Local1:left()
            enddo
            do while ( Local8 > 0 )
               Local8--
               Local1:right()
            enddo
         endcase
      case Local4 == 0
      case Local4 == 24
         if ( Static1 )
            Local1:hitbottom(.T.)
         else
            Local1:down()
         endif
      case Local4 == 5
         if ( Static1 )
            Local1:hittop(.T.)
         else
            Local1:up()
         endif
      case Local4 == 3
         if ( Static1 )
            Local1:hitbottom(.T.)
         else
            Local1:pagedown()
         endif
      case Local4 == 18
         if ( Static1 )
            Local1:hittop(.T.)
         else
            Local1:pageup()
         endif
      case Local4 == 31
         if ( Static1 )
            Local1:hittop(.T.)
         else
            Local1:gotop()
         endif
      case Local4 == 30
         if ( Static1 )
            Local1:hitbottom(.T.)
         else
            Local1:gobottom()
         endif
      case Local4 == 4
         Local1:right()
      case Local4 == 19
         Local1:left()
      case Local4 == 1
         Local1:home()
      case Local4 == 6
         Local1:end()
      case Local4 == 26
         Local1:panleft()
      case Local4 == 2
         Local1:panright()
      case Local4 == 29
         Local1:panhome()
      case Local4 == 23
         Local1:panend()
      otherwise
         Local3 := calluser(Local1, Arg6, Local4)
         Local5 := .F.
      endcase
   enddo
   setcursor(Local2)
   Static1 := Local7[ 1 ]
   Static2 := Local7[ 2 ]
   return .T.

static function DBEDSETUP(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, ;
   Arg8, Arg9, Arg10, Arg11, Arg12)

   local Local1, Local2, Local3, Local4, Local5, Local6, Local7, ;
      Local8
   if (ValType(Arg1) != "N" .OR. Arg1 < 0)
      Arg1:= 0
   endif
   if (ValType(Arg2) != "N" .OR. Arg2 < 0)
      Arg2:= 0
   endif
   if (ValType(Arg3) != "N" .OR. Arg3 > MaxRow() .OR. Arg3 < Arg1)
      Arg3:= MaxRow()
   endif
   if (ValType(Arg4) != "N" .OR. Arg4 > MaxCol() .OR. Arg4 < Arg2)
      Arg4:= MaxCol()
   endif
   if ((Arg4 - Arg2) * (Arg3 - Arg1) > MaxRow() * MaxCol())
      Arg1:= Arg2:= 0
      Arg3:= MaxRow()
      Arg4:= MaxCol()
   endif
   Local1:= tbrowsedb(Arg1, Arg2, Arg3, Arg4)
   if (ISARRAY(Arg5))
      Local3:= Len(Arg5)
      Local2:= 1
      do while (Local2 <= Local3)
         if (ValType(Arg5[Local2]) != "C" .OR. Empty(Arg5[Local2]))
            exit
         endif
         Local2++
      enddo
      Local3:= Local2 - 1
   else
      Local3:= FCount()
   endif
   if (Local3 == 0)
      return .F.
   endif
   Local1:headsep("ÍÑÍ")
   Local1:colsep(" ³ ")
   Local1:ColorSpec := "N/W,N/BG,B/W,B/BG,B/W,B/BG,R/W,B/R"
   Local4:= array(Local3, 6)
   if (ISARRAY(Arg5))
      for Local2:= 1 to Local3
         if ("->" $ Arg5[Local2])
            Local6:= At("->", Arg5[Local2])
            Local4[Local2][3]:= SubStr(Arg5[Local2], 1, Local6 - 1)
            Local4[Local2][4]:= SubStr(Arg5[Local2], Local6 + 2)
            Local4[Local2][1]:= Local4[Local2][3] + "->;" + ;
               Local4[Local2][4]
         else
            Local4[Local2][3]:= Nil
            Local4[Local2][4]:= Nil
            Local4[Local2][1]:= Arg5[Local2]
         endif
         Local4[Local2][2]:= Arg5[Local2]
      next
   elseif (FCount() > 0)
      for Local2:= 1 to Local3
         Local4[Local2][3]:= Nil
         Local4[Local2][4]:= Nil
         Local4[Local2][1]:= FieldName(Local2)
         Local4[Local2][2]:= FieldName(Local2)
      next
   else
      return .F.
   endif
   for Local2:= 1 to Local3
      Local5:= ""
      if (ISARRAY(Arg7))
         if (Len(Arg7) >= Local2 .AND. ISCHARACTER(Arg7[Local2]) ;
               .AND. !Empty(Arg7[Local2]))
            Local5:= Arg7[Local2]
         endif
      elseif (ISCHARACTER(Arg7) .AND. !Empty(Arg7))
         Local5:= Arg7
      endif
      Local7:= Nil
      if (ISMEMO(&(Local4[Local2][2])))
         Local7:= "{|| '  <Memo>  '}"
      elseif (Empty(Local5))
         if ("->" $ Local4[Local2][2])
            if (Upper(Local4[Local2][3]) == "M")
               Local7:= memvarbloc(Local4[Local2][2])
            elseif (Upper(Local4[Local2][3]) == "FIELD")
               Local7:= fieldwbloc(Local4[Local2][4], Select())
            else
               Local7:= fieldwbloc(Local4[Local2][4], ;
                  Select(Local4[Local2][3]))
            endif
         elseif (!Empty(fieldpos(Local4[Local2][2])))
            Local7:= fieldwbloc(Local4[Local2][2], Select())
         endif
      endif
      if (ISNIL(Local7))
         if (Empty(Local5))
            Local7:= "{||" + Local4[Local2][2] + "}"
         else
            Local7:= "{|| Transform(" + Local4[Local2][2] + ",'" + ;
               Local5 + "')}"
         endif
      endif
      if (ISCHARACTER(Local7))
         Local4[Local2][2]:= &Local7
      elseif (ISBLOCK(Local7))
         Local4[Local2][2]:= Local7
      endif
      if (ISARRAY(Arg8))
         if (Len(Arg8) >= Local2 .AND. ISCHARACTER(Arg8[Local2]))
            Local4[Local2][1]:= Arg8[Local2]
         endif
      elseif (ISCHARACTER(Arg8))
         Local4[Local2][1]:= Arg8
      endif
      Local4[Local2][3]:= Nil
      if (ISARRAY(Arg9))
         if (Len(Arg9) >= Local2 .AND. ISCHARACTER(Arg9[Local2]))
            Local4[Local2][3]:= Arg9[Local2]
         endif
      elseif (ISCHARACTER(Arg9))
         Local4[Local2][3]:= Arg9
      endif
      Local4[Local2][4]:= Nil
      if (ISARRAY(Arg10))
         if (Len(Arg10) >= Local2 .AND. ISCHARACTER(Arg10[Local2]))
            Local4[Local2][4]:= Arg10[Local2]
         endif
      elseif (ISCHARACTER(Arg10))
         Local4[Local2][4]:= Arg10
      endif
      Local4[Local2][5]:= Nil
      if (ISARRAY(Arg11))
         if (Len(Arg11) >= Local2 .AND. ISCHARACTER(Arg11[Local2]))
            Local4[Local2][5]:= Arg11[Local2]
         endif
      elseif (ISCHARACTER(Arg11))
         Local4[Local2][5]:= Arg11
      endif
      Local4[Local2][6]:= Nil
      if (ISARRAY(Arg12))
         if (Len(Arg12) >= Local2 .AND. ISCHARACTER(Arg12[Local2]))
            Local4[Local2][6]:= Arg12[Local2]
         endif
      elseif (ISCHARACTER(Arg12))
         Local4[Local2][6]:= Arg12
      endif
   next
   for Local2:= 1 to Local3
      Local8:= tbcolumnne(Local4[Local2][1], Local4[Local2][2])
      if (Local4[Local2][3] != Nil)
         Local8:headsep(Local4[Local2][3])
      endif
      if (Local4[Local2][4] != Nil)
         Local8:colsep(Local4[Local2][4])
      endif
      if (Local4[Local2][5] != Nil)
         Local8:footsep(Local4[Local2][5])
      endif
      if (Local4[Local2][6] != Nil)
         Local8:footing(Local4[Local2][6])
      endif
      Local8:ColorBlock := { || iif( Deleted(), { 3, 2 }, { 1, 2 } ) } // -> Definicao das cores do BROWSE e registros DELETADOS
      Local1:addcolumn(Local8)
   next
   return Local1

static function CALLUSER( Arg1, Arg2, Arg3 )

   local Local1, Local2, Local3, Local4
   do case
   case Arg3 != 0
      Local1 := 4
   case !Static1 .AND. emptyfile()
      Local1 := 3
   case Arg1:hitbottom()
      Local1 := 2
   case Arg1:hittop()
      Local1 := 1
   otherwise
      Local1 := 0
   endcase
   do while ( !Arg1:stabilize() )
   enddo
   Local3 := RecNo()
   if ( ValType(Arg2) != "C" .OR. Empty(Arg2) )
      if ( Arg3 == 13 .OR. Arg3 == 27 )
         Local2 := 0
      else
         Local2 := 1
      endif
   else
      Local2 := &Arg2(Local1, Arg1:colpos())
   endif
   Local4 := Local2 != 0
   if ( !Static1 .AND. EOF() .AND. !emptyfile() )
      skip -1
   endif
   if ( Local2 == 3 )
      Static1 := !( Static1 .AND. EOF() )
      if ( Static1 )
         goto bottom
         Arg1:down()
      else
         Arg1:refreshcur()
      endif
      Static2 := .F.
   elseif ( Local2 == 2 .OR. Local3 != RecNo() )
      if ( Local4 )
         Static1 := .F.
         if ( Set(_SET_DELETED) .AND. Deleted() .OR. ;
               !Empty(dbfilter()) .AND. !&( dbfilter() ) )
            skip 
         endif
         if ( EOF() )
            goto bottom
         endif
         Local3 := RecNo()
         Arg1:refreshall()
         do while ( !Arg1:stabilize() )
         enddo
         do while ( Local3 != RecNo() )
            Arg1:up()
            do while ( !Arg1:stabilize() )
            enddo
         enddo
         Static2 := .F.
      endif
   else
      Arg1:refreshcur()
   endif
   return Local4

static function EMPTYFILE
   if ( LastRec() == 0 )
      return .T.
   endif
   if ( ( EOF() .OR. RecNo() == LastRec() + 1 ) .AND. BOF() )
      return .T.
   endif
   return .F.

static function SKIPPED( Arg1 )
   local Local1 := 0
   if ( LastRec() != 0 )
      if ( Arg1 == 0 )
         if ( EOF() .AND. !Static1 )
            skip -1
            Local1 := -1
         else
            skip 0
         endif
      elseif ( Arg1 > 0 .AND. RecNo() != LastRec() + 1 )
         do while ( Local1 < Arg1 )
            skip 
            if ( EOF() )
               if ( Static1 )
                  Local1++
               else
                  skip -1
               endif
               exit
            endif
            Local1++
         enddo
      elseif ( Arg1 < 0 )
         do while ( Local1 > Arg1 )
            skip -1
            if ( BOF() )
               exit
            endif
            Local1--
         enddo
      endif
   endif
   return Local1

Re: dbedit e deleted()

Enviado: 12 Fev 2010 17:29
por rochinha
Amiguinhos,

Eis um exemplo original, tirado de material da antiga CA, produtora do Clipper.

Código: Selecionar todos

/***
*
*  Tbdemo.prg
*
*  Illustration of TBROWSE and GET objects.
*
*  Copyright (c) 1990-1993, Computer Associates International Inc.
*  All rights reserved.
*
*  Compile:  CLIPPER Tbdemo /m /n /w
*  Link:     RTLINK FILE Tbdemo
*  Execute:  Tbdemo <dbf> [<ntx>]
*
*/

#include "Common.ch"
#include "Inkey.ch"
#include "Setcurs.ch"
#include "Error.ch"


/* 
*  These #defines use the browse's "cargo" slot to hold the
*  "append mode" flag for the browse. The #defines make it
*  easy to change this later (e.g. if you need to keep
*  several items in the cargo slot).
*/
#define APP_MODE_ON( b )      ( b:cargo := TRUE  )
#define APP_MODE_OFF( b )     ( b:cargo := FALSE )
#define APP_MODE_ACTIVE( b )  ( b:cargo )

// Separator strings for the browse display
#define MY_HEADSEP      "ÍÑÍ"
#define MY_COLSEP       " ³ "



/***
*
*  Tbdemo <dbf> [<index>]
*
*/
PROCEDURE Tbdemo( dbf, index )

   LOCAL bSaveHandler
   LOCAL oError
   LOCAL cScreen
   LOCAL cSavClr
   
   // Lazy man's error checking
   bSaveHandler := errorblock( { |x| break(x) } )

   BEGIN SEQUENCE
      use (dbf) index (index)

   RECOVER USING oError
      if ( oError:genCode == EG_OPEN )
         ?? "Error opening file(s)"

      else
         // Assume it was a problem with the params
         ?? "Usage: Tbdemo <dbf> [<index>]"

      endif

      QUIT     // NOTE
   END

   // Restore the default error handler
   errorblock( bSaveHandler )

   // Save screen, set color, etc.
   set scoreboard off
   cScreen := savescreen()
   cSavClr := setcolor("N/BG")
   cls

   MyBrowse( 3, 6, maxrow() - 2, maxcol() - 6 )

   // Put things back
   setcolor  ( cSavClr )
   setpos    ( maxrow(), 0 )
   restscreen( ,,,, cScreen )

   QUIT

   RETURN



/***
*   
*  MyBrowse()
*
*  Create a Tbrowse object and browse with it.
*
*/
STATIC PROCEDURE MyBrowse(nTop, nLeft, nBottom, nRight)

   LOCAL oBrowse                          // The TBrowse object
   LOCAL cColorSave, nCursSave            // State preservers
   LOCAL nKey                             // Keystroke
   LOCAL lMore := TRUE                    // Loop control
   LOCAL lSavReadExit := READEXIT( .T. )  // Enable Up/Down as READ exit keys

   // Make a "stock" Tbrowse object for the current workarea
   oBrowse := StockBrowseNew( nTop, nLeft, nBottom, nRight )

   /*
   *  This demo uses the browse's "cargo" slot to hold a logical
   *  value of true (.T.) when the browse is in "append mode",
   *  otherwise false (.F.) (see #defines at top).
   */
   APP_MODE_OFF( oBrowse )

   // Use a custom 'skipper' to handle append mode (see below)
   oBrowse:skipBlock := { |x| Skipper( x, oBrowse ) }

   // Change the heading and column separators
   oBrowse:headSep := MY_HEADSEP
   oBrowse:colSep  := MY_COLSEP

   // Play with the colors and picture
   FormatColumns( oBrowse )

   // Insert a column at the left for "Rec #" and freeze it
   AddRecno( oBrowse )

   // Draw a window shadow
   dispbegin()

   cColorSave := setcolor( "N/N" )
   scroll( nTop + 1, nLeft + 2, nBottom + 1, nRight + 2 )

   setcolor( "W/W" )
   scroll( nTop, nLeft, nBottom, nRight )

   dispend()

   setcolor( cColorSave )

   // Save cursor shape, turn the cursor off while browsing
   nCursSave := setcursor( SC_NONE )

   // Main loop
   while lMore
      
      // Don't let the cursor move into frozen columns
      if ( oBrowse:colPos <= oBrowse:freeze )
         oBrowse:colPos := ( oBrowse:freeze + 1 )
      
      endif

      // Stabilize the display until it's stable or a key is pressed
      oBrowse:forceStable()

      if ( oBrowse:hitBottom .and. !APP_MODE_ACTIVE( oBrowse ) )
         // Banged against EOF; go into append mode
         APP_MODE_ON( oBrowse )
         nKey := K_DOWN

      else
         if ( oBrowse:hitTop .or. oBrowse:hitBottom )
            tone( 125, 0 )

         endif

         /*
         *  Make sure that the current record is showing
         *  up-to-date data in case we are on a network.
         */
         oBrowse:refreshCurrent():forceStable()

         // Everything's done -- just wait for a key
         nKey := inkey( 0 )

      endif

      if ( nKey == K_ESC )
         // Esc means leave
         lMore := .F.

      else
         // Apply the key to the oBrowse
         applyKey( oBrowse, nKey )

      endif
   enddo

   setcursor( nCursSave )
   READEXIT( lSavReadExit )

   RETURN



/***
*   
*  Skipper()
*
*  Handle record movement requests from the Tbrowse object.
*
*  This is a special "skipper" that handles append mode. It
*  takes two parameters instead of the usual one. The second
*  parameter is a reference to the Tbrowse object itself. The
*  Tbrowse's "cargo" variable contains information on whether
*  append mode is turned on.
*
*  NOTE: uses the cargo #defines shown at the top of Tbdemo.prg
*
*/
STATIC FUNCTION Skipper( nSkip, oBrowse )

   LOCAL lAppend := APP_MODE_ACTIVE( oBrowse )
   LOCAL i       := 0

   do case
   case ( nSkip == 0 .or. lastrec() == 0 )
      // Skip 0 (significant on a network)
      dbSkip( 0 )

   case ( nSkip > 0 .and. !eof() )
      while ( i < nSkip )           // Skip Foward

         dbskip( 1 )

         if eof()
            iif( lAppend, i++, dbskip( -1 ) )
            exit

         endif

         i++

      enddo

   case ( nSkip < 0 )
      while ( i > nSkip )           // Skip backward

         dbskip( -1 )

         if bof()
            exit

         endif

         i--

      enddo

   endcase

   RETURN i



/***
*
*   ApplyKey()
*
*   Apply one keystroke to the oBrowse.
*
*   NOTE: uses the cargo #defines shown at the top of Tbdemo.prg
*
*/
STATIC PROCEDURE ApplyKey( oBrowse, nKey )

   do case
   case nKey == K_DOWN
      oBrowse:down()

   case nKey == K_PGDN
      oBrowse:pageDown()

   case nKey == K_CTRL_PGDN
      oBrowse:goBottom()
      APP_MODE_OFF( oBrowse )

   case nKey == K_UP
      oBrowse:up()

      if APP_MODE_ACTIVE( oBrowse )
         APP_MODE_OFF( oBrowse )
         oBrowse:refreshAll()

      endif

   case nKey == K_PGUP
      oBrowse:pageUp()

      if APP_MODE_ACTIVE( oBrowse )
         APP_MODE_OFF( oBrowse )
         oBrowse:refreshAll()

      endif

   case nKey == K_CTRL_PGUP
      oBrowse:goTop()
      APP_MODE_OFF( oBrowse )

   case nKey == K_RIGHT
      oBrowse:right()

   case nKey == K_LEFT
      oBrowse:left()

   case nKey == K_HOME
      oBrowse:home()

   case nKey == K_END
      oBrowse:end()

   case nKey == K_CTRL_LEFT
      oBrowse:panLeft()

   case nKey == K_CTRL_RIGHT
      oBrowse:panRight()

   case nKey == K_CTRL_HOME
      oBrowse:panHome()

   case nKey == K_CTRL_END
      oBrowse:panEnd()

   case nKey == K_RETURN
      DoGet( oBrowse )

   otherwise
      KEYBOARD chr( nKey )
      DoGet( oBrowse )

   endcase

   RETURN



/***
*
*   DoGet()
*
*   Do a GET for the current column in the browse.
*
*   NOTE: uses the cargo #defines shown at the top of Tbdemo.prg
*
*/
PROCEDURE doGet( oBrowse )

   LOCAL lFlag := TRUE
   LOCAL oCol
   LOCAL GetList
   LOCAL nKey
   LOCAL nLen
   LOCAL lAppend
   LOCAL bSavIns
   LOCAL nSavRecNo := recno()
   LOCAL xNewKey
   LOCAL xSavKey

   // If we're at EOF we're adding the first record, so turn on append mode
   if EOF()
      lAppend := APP_MODE_ON( oBrowse )
   else
      lAppend := APP_MODE_ACTIVE( oBrowse )
   endif

   // Make sure screen is fully updated, dbf position is correct, etc.
   oBrowse:forceStable()

   if ( lAppend .and. ( recno() == lastrec() + 1 ) )
      dbAppend()

   endif

   // Save the current record's key value (or NIL)
   xSavKey := iif( empty( indexkey() ), NIL, &( indexkey() ) )

   // Get the current column object from the browse
   oCol := oBrowse:getColumn( oBrowse:colPos )

   // Get picture len to force scrolling if var is larger than window
   nLen := oBrowse:colWidth( oBrowse:colPos )

   // Create a corresponding GET
   GetList := { getnew( row(), col(),     ;
                        oCol:block,       ;
                        oCol:heading,     ;
                        oCol:picture,     ;
                        oBrowse:colorSpec ) }

   // Set insert key to toggle insert mode and cursor shape
   bSavIns := setkey( K_INS, { || InsToggle() } )

   // Set initial cursor shape
   setcursor( iif( ReadInsert(), SC_INSERT, SC_NORMAL ) )
   READ
   setcursor( SC_NONE )
   setkey( K_INS, bSavIns )

   // For this demo, we turn append mode off after each new record
   APP_MODE_OFF( oBrowse )

   // Get the record's key value (or NIL) after the GET
   xNewKey := if( empty( indexkey() ), NIL, &( indexkey() ) )

   oBrowse:inValidate()
   oBrowse:refreshAll():forceStable()

   // if the key has changed (or if this is a new record)
   if !( xNewKey == xSavKey ) .or. ( lAppend .and. xNewKey != NIL )

      // do a complete refresh
      oBrowse:refreshAll():forceStable()

      // Make sure we're still on the right record after stabilizing
      while &( indexkey() ) > xNewKey .and. !oBrowse:hitTop()
         oBrowse:up():forceStable()

      enddo

   endif

   // Check exit key from get
   nKey := lastkey()
   if nKey == K_UP   .or. nKey == K_DOWN .or. ;
      nKey == K_PGUP .or. nKey == K_PGDN

      // Ugh
      keyboard( chr( nKey ) )

   endif

   RETURN



/***
*
*   InsToggle()
*
*   Toggle the global insert mode and the cursor shape.
*
*/
STATIC PROCEDURE InsToggle()

   if readinsert()
      readinsert( FALSE )
      setcursor( SC_NORMAL )

   else
      readinsert( TRUE )
      setcursor( SC_INSERT )

   endif

   RETURN



/***
*
*   StockBrowseNew()
*
*   Create a "stock" Tbrowse object for the current workarea.
*
*/
STATIC FUNCTION StockBrowseNew( nTop, nLeft, nBottom, nRight )

   LOCAL oBrowse
   LOCAL n
   LOCAL oColumn
   LOCAL cType

   // Start with a new browse object from TBrowseDB()
   oBrowse := TBrowseDB( nTop, nLeft, nBottom, nRight )

   // Add a column for each field in the current workarea
   for n := 1 to fcount()

      // Make a new column
      oColumn := TBColumnNew( field( n ),                         ;
                              FieldWBlock( field( n ), select() ) )

      // Add the column to the browse
      oBrowse:addColumn( oColumn )

   next

   RETURN oBrowse



/***
*
*   FormatColumn()
*
*   Set up some colors and pictures for the column.
*
*/
STATIC PROCEDURE FormatColumn( oBrowse )

   LOCAL n
   LOCAL oColumn
   LOCAL xValue

   // Set up a list of colors for the browse to use
   oBrowse:colorSpec := "N/W,N/BG,B/W,B/BG,B/W,B/BG,R/W,B/R"

   // Loop through the columns, choose some colors for each
   for n := 1 to oBrowse:colCount
      
      // Get (a reference to) the column
      oColumn := oBrowse:getColumn( n )

      // Get a sample of the underlying data by evaluating the codeblock
      xValue := eval( oColumn:block )

      do case
      case ISNUM( xValue )
          // For numbers, use a color block to highlight negative values
          oColumn:picture    := "999,999"
          oColumn:colorBlock := { |x| iif( x < 0, { 7, 8 }, { 5, 6 } ) }

          // Set default colors also (controls the heading color)
          oColumn:defColor := {7, 8}

      case ISCHAR( xValue )
         // For non-numeric, just use colors 3 and 4 ("B/W" and "B/BG")
         oColumn:picture  := repl( "!", len( xValue ) )
         oColumn:defColor := { 3, 4 }

      otherwise
         // For non-numeric, just use colors 3 and 4 ("B/W" and "B/BG")
         oColumn:defColor := { 3, 4 }

      endcase

   next

   RETURN



/***
*
*   AddRecno()
*
*   Insert a frozen column at the left that shows current record number
*
*/
STATIC PROCEDURE AddRecno( oBrowse )

   LOCAL oColumn

   // Create the column object
   oColumn := TBColumnNew( "  Rec #", { || recno() } )

   // Insert it as the leftmost column
   oBrowse:insColumn( 1, oColumn )

   // Freeze it at the left
   oBrowse:freeze := 1

   RETURN

Re: dbedit e deleted()

Enviado: 13 Fev 2010 10:53
por lapinhazzz
Bom Dia

E agora com estes prgs terei de modificar o meu programa de alto a baixo.

É que eu uso muito o dbedit.
Pelo que sei o tbrowse é poderoso, mas eu não sei trabalhar com codeblocks
Vou testar aquilo que postaste.

Um abraço e obrigado.

lapinhazzz

Re: dbedit e deleted()

Enviado: 13 Fev 2010 16:56
por rochinha
Amiguinho,

O código que postei acima corresponde ao DBEdit() original, que foi obtido através de descompilação de um aplicativo simples que fazia chamada ao DBEdit().

Portanto não havera de ter alterações de cabo a rabo como voce diz. Apenas inclua o código em seu .PRG principal que ele suprimi o DBEdit(0 do Clipper.

E com as alterações que deixei neste código voce poderá obter e proporcionar mais caracteristicas ao pobre DBEdit().

O DBEdit é apenas uma carcaça para acesso ao principal que é o TBrowse().

Re: dbedit e deleted()

Enviado: 14 Fev 2010 18:24
por lapinhazzz
Boa noite amigos do forum
O procedure do amigo sygecom não funcionou

Aqui vai parte de duas sub rotinas a primeira é a do dbedit dos campos e a segunda é a rotina que controla o dbedit

Mas não funciona porque quando carrego no espaço chr(32) o quadrado aparece mas logo desaparece. Já tentei de tudo e não consigo entender porque não se fixa lá o chr(254)

Aqui vai as rotinas:

Código: Selecionar todos


/*
 ÚÄ Program ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
 ³    Aplica‡„o:                                                            ³
 ³    Descri‡„o:                                                            ³
 ³         Nome: MV.PRG                                                     ³
 ³        Autor: Carlos Lapa                                                ³
 ³       Vers„o:                                                            ³
 ³ Data cria‡„o: 04-02-10              Actualizado em   : þ04-02-10         ³
 ³ Hora cria‡„o: 23:17:50              Hora actualiza‡„o: þ23:17:50         ³
 ³   Fich. Make:                                                            ³
 ³  Fich. Exec.:                       Doc.s por: Carlos Lapa               ³
 ³          Copyright: (c) 1910 by (c) Carlos Lapa, Inc.                    ³
 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
*/
function mv
   public vprecov
   rot="MV"
   priv l
   sele 2
   use dvendas inde dvendas1 alia b2
   set filt to recno()>1
   go top
   sele 1
       use vendas inde vendas1,vendas2 alia a1
     set filt to recno()>1
   go top

   do whil .t.
      publ v1a[1],v2a[1],v3a[1],v4a
      if indexord()=1
         tit("Vendas (por VENDA)")
         v1a[1]="strzero(VENDA,5,0)+' '+dtoc(datactual)+' '+utente+' '+proc+' '+hora+' '+letraesc+cursoabv+str(tcopias)+tran(total,'@E 999,999.99')"

         v3a[1]="Venda DataREFER  Utente                Proc    Hora   Esc  Curso Copias   Total"
         *       12345 10/10/2009 12345678901234567890 123456 13:15:15 A    CEF1A1       12345.12
         *                 1         2         3         4         5         6         7         8
         *       012345678901234567890123456789012345678901234567890123456789012345678901234567890
         pfs("[ENTER]EditaVenda,F4NovaVenda,F5ExcluiVenda,F7ReordenaLista")
      elseif indexord()=2
         tit("Vendas (por utente)")
         v1a[1]="utente+' '+strzero(venda,5,0)+' '+dtoc(datactual)+' '+proc+' '+hora+' '+letraesc+cursoabv+str(tcopias)+tran(total,'@E 999,999.99')"
         *                 1         2         3         4         5         6         7         8
         *       012345678901234567890123456789012345678901234567890123456789012345678901234567890

         v3a[1]="Utente               Venda DataREFER  Proc    Hora    Esc  Curso  Copias   Total"
         *       12345678901234567890 12345 10/10/2009 123456 13:15:50 A    CEF1A1       12345.12
         pfs("[ENTER]EditaVenda,F4NovaVenda,F5ExcluiVenda,F7ReordenaLista")
      endi
      v2a[1]="@"
      v4a=""
      cor(2)
      keyb chr(26)
      dbedit(04,00,22,80,v1a,"fc",v2a,v3a,v4a)
      l=lastkey()
      do case
         case l=27
            exit
         case l=13
            mv_e()                                              // edita venda
         case l=-3
            mv_n()                                              // inclui nova venda
         case l=-4
            mv_d()                                              // deleta venda
         case l=-6
            mv_r()                                              // reordena
      endc
   endd
   rele v1a,v2a,v3a,v4a
   rot="MV"


/*
 ÚÄ Program ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
 ³    Aplica‡„o:                                                            ³
 ³    Descri‡„o:                                                            ³
 ³         Nome: X_DBE.PRG                                                  ³
 ³        Autor: Carlos Lapa                                                ³
 ³       Vers„o:                                                            ³
 ³ Data cria‡„o: 04-02-10              Actualizado em   : þ04-02-10         ³
 ³ Hora cria‡„o: 23:16:05              Hora actualiza‡„o: þ23:16:05         ³
 ³   Fich. Make:                                                            ³
 ³  Fich. Exec.:                       Doc.s por: Carlos Lapa               ³
 ³          Copyright: (c) 1910 by (c) Carlos Lapa, Inc.                    ³
 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
*/
FUNCTION FC
   public rapaga,flag
   priv l,m,f,x,cp,y,z,ix,ordem

   cp=fcount()
   l=0
   for x=1 to cp
      f=fieldname(x)
      if !empty(&f)
         l=1
         exit
      endi
   next
   f=l
   l=lastkey()
   x=1
   do case
      case l=26
      case l=27
         x=0
      case l=13 .and. f=1
         IF ifrot("rot,ORDENAP")
            vcodigo=codigoprod
            X=0
         ENDIF
         IF ifrot("rot,ORDENAPES")
            rproc=proc
            X=0
         ENDIF
         IF IFROT("rot,INCLUI_ITEM")
            X=0
            TECLA(13,1)
         ENDIF
         tecla(26,1)
         if ifrot("rot,MV,VENTRA")
            x=0
            *        tecla(26,1)
         endi
         IF ifrot("rot,INCLUI_ITEM,ENTRA_E")
            IF vprecov=0
               x=1
            elseif vprecov<>0
               x=0
            ENDIF
         ENDIF
         IF ifrot("rot,MV_E")
            X=0
         ENDIF
         if l=13
            x=0
         endi
      /*   IF ifrot("rot,INCLUI_ITEM")
            keyboard(13)
            X=0
         ENDIF
        */
      case l=27
      case l=28                                                 && F1  case l=28        F1
         tecla(26,1)
      case l=-2
         * case l="P"
         *   x=0
      case l=-1
         IF ifrot("rot,INCLUI_ITEM,ORDENAP,ORDENAPES")
            IF ifrot("rot,ORDENAP")
            ENDIF
            X=0
         ELSE
            tecla(26,1)
         endif
      case l=-3
         if ifrot("rot,INCLUI_ITEM,ENTRA_E")
            x=0
         else
            tecla(26,1)
         endi
         if ifrot("rot,MV,VENTRA")
            * mv_n()
            x=0
         else
            tecla(26,1)
         endi
      case l=-4 .and. f=1
         && F5 exclui item
         IF ifrot("rot,MV_E")
            KEYB CHR(26)
            X=2
            tecla(26,1)
         ELSE
            tecla(26,1)
         ENDIF

         IF ifrot("rot,INCLUI_ITEM,ENTRA_E")                    && .AND. rvtotal>=0
            sele b21
            set orde to 1
            IF b21->cor="COR"
               rplafc=rplafc+quant
               RQUANTC=RQUANTC-QUANT
               RTOTALC=RTOTALC-total
               rgastoc=rquantc
            elseif b21->cor="PRE"
               rplafp=rplafp+quant
               RQUANTP=RQUANTP-QUANT
               RTOTALP=RTOTALP-total
               rgastop=rquantc
            ENDIF
            /*@16,40 SAY "rtotalp"+STR(rtotalp)
            @17,40 SAY "rtotalC"+STR(rtotalC)
            @18,40 SAY "RQUANTP"+STR(RQUANTP)
            @19,40 SAY "RQUANTC"+STR(RQUANTC)
            aa=inkey(0)
            wait ""*/
            set deleted on
            rvtotal=RVtotal-total
            @05,70 say tran(rvtotal,'@E 999,999.99')
            delete
            dbcommit()
            cor(21)
            @ 21,47 say rplafp PICT "99999"
            @ 21,55 say rplafc PICT "99999"
            cor(2)
            X=2
         else
            tecla(26,1)
         endi
         if ifrot("rot,MV")
            sele 1
            rproc=proc
            SELE 5
            use pessoal inde pessoa1
            seek rPROC
            rplafc=plafc+a1->quantc
            Rplafp=plafp+a1->quantp
            REPL plafP WITH RPLAFP
            REPL PLAFC WITH RPLAFC
            rgastop=gastop-a1->quantp
            rgastoc=gastoc-a1->quantc
            repl gastop with rgastop
            repl gastoc with rgastoc
            sele 1
            mv_d()
            x=2
            inkey()

        tecla(26,1)
         else
            tecla(26,1)
         endi

         if ifrot("rot,VENTRA")
            mv_dD()
            x=2
            inkey()
            tecla(26,1)
         endi
      case l=-5 .and. f=1
         tecla(26,1)
      case l=-6 .and. f=1                                       && F7
         if ifrot("rot,MV,VENTRA")
            x=0
         else
            tecla(26,1)
         endi
      case l=-7
         tecla(26,1)
      case l=-8
         tecla(26,1)
      case l=-9                                                 && F10
         IF ifrot("rot,MV_E")
            KEYB CHR(26)
            X=2
            tecla(26,1)
         ELSE
            tecla(26,1)
         ENDIF
         IF ifrot("rot,MV_N")
            X=2
         ENDIF
         IF ifrot("rot,MAIN")
            X=0
         ELSE
            TECLA(26,1)
         ENDIF
         sele 21
         count to ntotal for !deleted()
         IF ifrot("rot,INCLUI_ITEM") .AND. ntotal>=1
            set cursor off
            mv_gr(v)
            set cursor on
            IF vali=.t.
               rvtotal=0
               set deleted off
               sele 1
               go bott
               vvenda=venda+1
               go top
               append blank
               repl venda   with vvenda
               repl tcopias with rquantp+rquantc
               repl datactual with date()
               repl proc with e->proc
               repl utente with e->utente
               repl letraesc with letrat
               repl cursoabv with g->cursoabv
               repl hora with time()
               repl quantp with RQUANTP
               repl quantc with RQUANTC
               repl totalp with RTOTALP
               repl totalc with RTOTALC
               REPL TCOPIAS WITH RQUANTC+RQUANTP
               sele 5
               rgastop=rquantp+gastop
               rgastoc=rquantc+gastoc
               repl gastop with rgastop
               repl gastoc with rgastoc
               sele 1
           /* @16,40 SAY "rtotalp"+STR(rtotalp)
            @17,40 SAY "rtotalC"+STR(rtotalC)
            @18,40 SAY "RQUANTP"+STR(RQUANTP)
            @19,40 SAY "RQUANTC"+STR(RQUANTC)
            @20,40 SAY "rquantp+rquantc"+STR(RQUANTP)+' '+STR(RQUANTC)
            aa=inkey(0)
            wait ""  */
               sele 21
               set orde to 2
               reind
               do whil .T.
                  IF eof()
                     exit
                  ENDIF
                  seek venda
                  IF found()
                     sele 2
                     go bott
                     appe blan
                     repl proc with b21->proc
                     repl cursoabv with b21->cursoabv
                     repl cescalao with b21->cescalao
                     repl letraesc with b21->letraesc
                     repl venda   with vvenda
                     repl item    with b21->item
                     repl codigoprod  with b21->codigoprod
                     repl quant   with b21->quant
                     repl prod    with b21->prod
                     repl precov  with b21->precov
                     repl datactual with b21->datactual
                     repl cursoabv with b21->cursoabv
                     repl codigocur with b21->codigocur
                     repl cor with b21->cor
                     dbcommit()
                     SELE 5
                     inde on proc to rproc4
                     seek b21->proc
                     IF found()
                        *   REPL QUANT WITH B21->QUANT
                        REPL plafP WITH RPLAFP
                        REPL PLAFC WITH RPLAFC
                   /*     FOR n := 1 TO 1
                           @ 15,3 say rquantp
                           @ 16,3 say rquantc
                           @ 17,1 say gastop
                           @ 18,1 say gastoc
                        next
                        wait ""*/
                     endi
                     sele b21
                     vquant=quant
                     vprecov=precov
                     dbcommit()
                     sele 2
                     repl total with (round(vquant*vprecov,2))
                     repl datactual with date()
                     dbcommit()
                     rvtotal=rvtotal+total
                     sele 1
                     repla total with rvtotal
                     sele 21
                     IF deleted()
                        sele 2
                        dele
                        rvtotal=rvtotal-total
                     ENDIF
                     sele 1
                     replace total with rvtotal
                     sele 2
                  endi
                  sele 21
                  skip
               endd
               sele 1
               set dele on
               sele 21
               reind
               rot="MV"
            endi
            IF vali=.f.
               x=0
               cor(2)
               l=lastkey()
               IF l=13
                  return x
               ENDIF
            endi
            set orde to 1
            go top
            *  saida=.t.
         endif
         cor(2)
         IF ifrot("rot,ENTRA_E") .AND. ntotal>=1
            rvtotal=0
            set deleted off
            sele 1
            go bott
            vvenda=entra+1
            append blank
            repl entra   with vvenda
            sele 1
            *replace datactual with vdata
            sele 21
            set orde to 2
            reind
            do whil .T.
               IF eof()
                  exit
               ENDIF
               seek entra
               IF found()
                  sele 4
                  go bott
                  appe blan
                  repl entra   with vvenda
                  repl item    with b21->item
                  repl codigoprod  with b21->codigoprod
                  repl quant   with b21->quant
                  repl prod    with b21->prod
                  repl precov  with b21->precov
                  * repl stock   with b21->stock

                  SELE 3
                  seek b21->codigoprod
                  IF found()
                     REPL QUANT WITH B21->QUANT
                     * REPL STOCK WITH B21->STOCK
                  endi
                  sele b21
                  vquant=quant
                  vprecov=precov
                  dbcommit()
                  sele 4
                  repl total with (round(vquant*vprecov,2))
                  repl datactual with date()
                  dbcommit()
                  rvtotal=rvtotal+total
                  sele 1
                  repl datactual with date()
                  repl quant with b21->quant
                  * repl stock with b21->stock
                  repla total with rvtotal
                  sele 21
                  IF deleted()
                     sele 4
                     dele
                     rvtotal=rvtotal-total
                  ENDIF
                  sele 1

                  replace total with rvtotal
                  replace datactual with date()
                  sele 4
               endi
               sele 21
               skip
            endd
            set dele on
            sele 21
            reind
            rot="MV"
         else
            sele 21
            rot="MV"
            tecla(26,1)
         endi
         set orde to 1
         go top
         saida=.t.
      case l=-40
         tecla(26,1)
      case l=-41
         tecla(26,1)
         *************************************************
      case l=8                                                  // Backspace
      case l=127                                                // Crtl-Backspace
      [color=#FF4040]case l=32
        @ recno()-1,79 say  IIF(venda=5,chr(254) ,"" )[/color]
        
      case l=30 .or. l=31
      case l=1 .or. l=6 .or. l=7 .or. l=22 .or. l=4 .or. l=19
         *      HOME     END      DEL      INSERT    DIR      ESQ
      case l=5 .or. l=24 .or. l=18 .or. l=3
         *      CIMA     BAIXO     PGUP      PGDN
         * case (l>47 .and. l<58)                               //===> 0/9
      case l=13
         IF ifrot("rot,INCLUI_ITEM,ENTRA_E")
            X=0
         ENDIF

         if ifrot("rot,MVI")
            count to l for !deleted()
            go top
            if l=20
               save scre to l
               men(0,4,0,402,0,0,0,0)
               inkey(2)
               rest scre from l
               tecla(26,1)
            else
               x=0
            endi
         else
            tecla(26,1)
         endi
      otherwise
         tecla(26,1)
   endc
   retu x

Bom dia de namorados e cumprimentos a todos

Agradeço a vossa atenção para com estes problemas.
lapinhazzz

Re: dbedit e deleted()

Enviado: 15 Fev 2010 02:34
por rochinha
Amiguinho,

Duas coisas:

Primeira - Analise este trecho e altere o original:

Código: Selecionar todos

function mv
   public vprecov
   rot="MV"
   priv l
   sele 2
   use dvendas inde dvendas1 alia b2
   set filt to recno()>1
   go top
   sele 1
       use vendas inde vendas1,vendas2 alia a1
     set filt to recno()>1
   go top

   do whil .t.
      publ v1a[1],v2a[1],v3a[1],v4a
      if indexord()=1
         tit("Vendas (por VENDA)")
         v1a[1]="IIF( DELETED(),'-*-','---')+' '+strzero(VENDA,5,0)+' '+dtoc(datactual)+' '+utente+' '+proc+' '+hora+' '+letraesc+cursoabv+str(tcopias)+tran(total,'@E 999,999.99')"

         v3a[1]="DEL Venda DataREFER  Utente                Proc    Hora   Esc  Curso Copias   Total"
Segunda - Salve o código DBEdit() que te passei como MyDBEdit.prg e inclua uma chamada no final de seu .PRG original, assim:

Código: Selecionar todos

#include "MyDBEdit.prg"
A primeira opção irá te mostrar o registro deletado ou não através de um "*"(asterisco) e a segunda opção permitirá que voce possa colorizar linhas de seu DBedit, ou deixá-lo com aspecto zebrado, etc.

Re: dbedit e deleted()

Enviado: 15 Fev 2010 14:54
por lapinhazzz
Boa tarde a todos

Rochinha aquele iif funcionou. Mas o teu mydbedit não consigo incluilo no mv.prg nem no principio nem no fim.
faco #include "mydbedit.prg"

É o primeiro programa que tentei que estava neste post não é o tbdemo.prg do clipper ?

Ajuda-me.
Para ver se aquilo funciona.

Mas exprimentei com o primeiro programa que tu postaste e não deu. Apareceu uma data de erros.

Cumprimentos.

Fico à espera de resposta

Obrigado

lapinhazzz

Re: dbedit e deleted()

Enviado: 16 Fev 2010 15:36
por rochinha
Amiguinho,

Clique neste link que ele caira exatamente sobre o post que contém o código que voce precisa.

Eu revisei o código e coloquei o conteúdo completo novamente.

Voce consegue criar um pequeno .PRG contendo seu código e este DBEdit() modificado com sua tabela e sua configuração para testes?

Neste caso fica mais fácil detectar quais são os erros.

Aqui coloquei um trecho de código que fiz teste do mesmo:

Código: Selecionar todos

/*
 *
 */
function mv
   publ v1a[1],v2a[1],v3a[1],v4a
   public vprecov
   rot="MV"
   priv l
   //
   //
   USE CEPSP
   GO TOP
   //
   v1a[1]="str(IDCIDADE,5,0)+'  '+CEP+'      '+RUA"
   v2a[1]="@"
   v3a[1]="CIDADE CEP      RUA"
   v4a=""
   //
   //keyb chr(26)
   dbedit(04,00,22,80,v1a,"fc",v2a,v3a,v4a)
   //
   return .t.

FUNCTION FC
   public rapaga,flag
   priv l,m,f,x,cp,y,z,ix,ordem
   f=l
   l=lastkey()
   x=1
   do case
      case l=26
      case l=27
           x=0
   endcase
   return x 

#include "MyDBEdit.prg"
Este exemplo faz uso do código DBEdit modificado e apresenta os registros deletados em cor azul marinho.

Um exemplo funcional esta aqui.

Dai para montar DBedit´s mais elaborados bastará fazer as alterações na função DBEDSetup() e por exemplo mostrá-los zebrados, filtrá-los, enviar o conteúdo para XML, HTML, etc.

Tem exemplos aqui no forum que usam o TBrowse para dar este resultado.

Vai da imaginação.

Re: dbedit e deleted()

Enviado: 16 Fev 2010 20:13
por lapinhazzz
uahu vou experimentar.

Obrigadão.
Vai dar um jeitão eu depois logo lhe digo como correu

Um abraço amiguinho

lapinhazzz

:xau