Eof() en xBrowse

Eof() en xBrowse

Postby acuellar » Fri Sep 06, 2013 4:07 pm

Distinguidos
Cómo se controla el fin del xBrowse, tengo este código pero no funciona:
Code: Select all  Expand view

 Do While .T.
    If Lastkey()=27
        oDlgP:End()
        Exit
     Endif
       oBrw:GoDown()
         If oBrw:Eof()
             ?"fin"
           oBrw:GoTop()
         Endif
   EndDo
 

El contenido del xBrowse es de una BASE.DBF y está indexado
Existe Recno() para xBrowse?

Gracias por la ayuda

Saludos,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1593
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Eof() en xBrowse

Postby cmsoft » Fri Sep 06, 2013 6:13 pm

Y por que no:
Code: Select all  Expand view

 Do While .T.
    If Lastkey()=27
        oDlgP:End()
        Exit
     Endif
       oBrw:GoDown()
         If oBrw:Eof()
           MsgInfo("Fin")
           oBrw:GoTop()
           oBrw:Refresh()
           EXIT
         Endif
   EndDo
User avatar
cmsoft
 
Posts: 1191
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Eof() en xBrowse

Postby acuellar » Fri Sep 06, 2013 6:19 pm

Distinguido

Lo que pasa es que no entra en el If oBrw:Eof(), no muestra el mensaje.

Gracias

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1593
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Eof() en xBrowse

Postby FranciscoA » Sat Sep 07, 2013 12:46 am

Hola Adhemar, y si intentas con oBrw:bPastEof:={||msginfo("fin")}?
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2111
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Eof() en xBrowse

Postby FranciscoA » Sat Sep 07, 2013 1:06 am

Prueba tambien asi:
n:=1
Do While .T.
If Lastkey()=27
oDlgP:End()
Exit
Endif
oBrw:GoDown()
n+=1
If n = oBrw:nLen
?"fin"
oBrw:GoTop()
Endif
EndDo
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2111
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Eof() en xBrowse

Postby nageswaragunupudi » Sat Sep 07, 2013 3:29 am

Mr Acuellar

Eval( oBrw:BookMark ) --> RecNo() // in case of DBF
( Except in very old versions, oBrw:BookMark returns RecNo() for DBF browse)

oBrw:GoDown() or Eval( oBrw:bSkip, 1 ) never go past eof and oBrw:eof() will never be true. This is due to the way oBrw:bSkip is defined.

I do not know which version of FWH you are using. I advise you to see the souce code of your version of xbrowse method GoDown()

In older versions ( including some versions in the year 2012 ), method GoDown(nDown) was returning NIL. If your version's method GoDown(nDown) is returning NIL, please correct this to return nDown.

If your original code is
Code: Select all  Expand view
METHOD GoDown( nDown )

...
...
return nil
 

Please modify as :
Code: Select all  Expand view
METHOD GoDown( nDown )
.....
.....
return nDown
 


Then you can have a loop like this:
do while oBrw:GoDown() == 1
<do something>
enddo
// reached the last row
oBrw:GoTop()

Alternatively, oBrw:Eval( bBlock ) also does the same thing.
Note: The correction I suggested above is important.

Comparison with oBrw:nLen also can be used. But this is not always reliable because OrdKeyCount() does not return the accurate count of records when SET DELETED IS ON and there are deleted records and filter expression does not include "!DELETED()"
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Eof() en xBrowse

Postby nageswaragunupudi » Sat Sep 07, 2013 4:12 am

This is a sample to demonstrate use of oBrw:Eval() method.
(Note: The above correction to GoDown() method is NECESSARY for Eval method to work correctly)

Code: Select all  Expand view

#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local oDlg, oBrw, oFont

   USE CUSTOMER NEW VIA "DBFCDX"
   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 800,400 PIXEL FONT oFont TITLE FWVERSION
   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg DATASOURCE "CUSTOMER" ;
      AUTOCOLS LINES AUTOSORT NOBORDER

   WITH OBJECT oBrw
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS
      :bRClicked        := { || xbrowse( oBrw:aSelected ) }
      //
      :CreateFromCode()
   END

   @ 10,10 BUTTON "EvalTest" SIZE 40,12 PIXEL OF oDlg ACTION EvalTest( oBrw )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

static function EvalTest( oBrw )

   local oDlg, oFont
   local lContinue := .t.

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14 BOLD
   DEFINE DIALOG oDlg SIZE 300,100 PIXEL FONT oFont
   @ 10,10 SAY oBrw:BookMark PICTURE "9999" SIZE 30,10 PIXEL OF oDlg RIGHT UPDATE
   @ 10,45 SAY oBrw:aCols[ 1 ]:Value SIZE 60,10 PIXEL OF oDlg UPDATE

   @ 30,10 BUTTON "Start"  SIZE 40,12 PIXEL OF oDlg ACTION ;
      (  oDlg:Update(), lContinue := .t., ;
         oBrw:Eval( { || SysRefresh(), oDlg:Update() },nil, { || lContinue } ) )
   @ 30,55 BUTTON "Stop" SIZE 40,12 PIXEL OF oDlg  ACTION ( lContinue := .f., SysRefresh(), oDlg:Update() )
   @ 30,100 BUTTON "Close" SIZE 40,12 PIXEL OF oDlg  ACTION ( oDlg:End() )

   ACTIVATE DIALOG oDlg CENTERED ;
      VALID ( lContinue := .f., SysRefresh(), .t. )
   RELEASE FONT oFont

   // No need to assign key action for ESC

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Eof() en xBrowse

Postby acuellar » Sat Sep 07, 2013 12:33 pm

Thanks friends

I have FWH1212

Mr. G. N. Rao.
The sample is with error

Time from start: 0 hours 0 mins 2 secs
Error occurred at: 09/07/13, 08:32:03
Error description: Error BASE/1073 Argument error: <
Args:
[ 1] = U
[ 2] = N 1

Thanks

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1593
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Eof() en xBrowse

Postby nageswaragunupudi » Sat Sep 07, 2013 1:44 pm

acuellar wrote:Thanks friends

I have FWH1212

Mr. G. N. Rao.
The sample is with error

Time from start: 0 hours 0 mins 2 secs
Error occurred at: 09/07/13, 08:32:03
Error description: Error BASE/1073 Argument error: <
Args:
[ 1] = U
[ 2] = N 1

Thanks

Adhemar

As I said above, you have to make a small correction in your xbrowse.prg.

Please see METHOD GoDown ( nDown )

In your version the return value of the method is NIL
Please change this as
Code: Select all  Expand view
return nDown


Please do this correction first. Please see my posting above for the correction,
After that you can use the condition oBrw:GoDown() == 1
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Eof() en xBrowse

Postby acuellar » Sat Sep 07, 2013 3:24 pm

Mr.
I modify the METHOD GoDown, but always return 0

Thanks

Regards

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1593
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Eof() en xBrowse

Postby nageswaragunupudi » Sat Sep 07, 2013 3:26 pm

1. Please tell me the version of your FWH
2. Copy and paste here the METHOD GoDown() in your version of XBrowse.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Eof() en xBrowse

Postby acuellar » Sat Sep 07, 2013 3:50 pm

Mr.
FWH1212
Code: Select all  Expand view

METHOD GoDown( nDown ) CLASS TXBrowse

   local nLines, n, oCol, nAt

   if ::nLen == 0 .or. ::Eof()
      if ::bPastEof != nil
         Eval( ::bPastEof )
      endif
      return nil
   endif

   ::CancelEdit()
   ::Seek()

   DEFAULT nDown := 1

   if ( oCol := ::SelectedCol() ):lMergeVert
      nAt         := ::KeyNo()
      nDown       := oCol:aMerge[ nAt ][ 2 ] + 1
      if ( nAt + nDown ) < ::nLen
         nDown    += oCol:aMerge[ nAt + nDown ][ 2 ]
      endif
   endif

   nLines := ::RowCount()

   if ! ::FullPaint()
      ::DrawLine()
   endif

   for n := 1 to nDown

      if ::Skip( 1 ) == 1           //Eval( ::bSkip, 1 ) == 1
         if ::nRowSel < nLines
            ::nRowSel++
         else

            if ! ::FullPaint()
               XBrwScrollRow( ::hWnd, ::nRowHeight, ::HeaderHeight(), nLines * ::nRowHeight )
               if n < nDown
                  ::DrawLine( .f. )
               endif
            endif

         endif
         if ::oVScroll != nil
            ::VGoDown()
         endif
      else
         if ::bPastEof != nil .and. nDown == 1
            Eval( ::bPastEof )
         endif
         if ::oVScroll != nil
            ::VGoBottom()
         endif
         exit        // 2008-07-24
      endif

   next
   nDown    := n - 1

   if ! ::FullPaint()
      ::DrawLine( .t. )
   endif

   if nDown > 0
      ::Change( .t. )
      if ::FullPaint()
         ::Super:Refresh( .t. )
      endif
   endif

return nDown

 


This is my code
Code: Select all  Expand view

Function PlayMusic()

   lBdr:=.T.
   oActiveX = TActiveX():New( oDlgP, "WMPlayer.OCX" )
    __KeyBoard(chr(13))
   oActiveX&#058;Settings:Volume = 100
 
  Do While .T.
     oActiveX&#058;url =VideoPath
    While oActiveX&#058;Playstate != 1
      SysRefresh()
      If Lastkey()=27
         Exit
      Endif
    EndDo
    If Lastkey()=27
        oDlgP:End()
        Exit
     Endif
    If oActiveX&#058;Playstate=1
       If lAzar
         AlAzar()
       Else
         oBrw:GoDown()
         ?oBrw:GoDown()
         If oBrw:GoDown()==1
               oBrw:GoTop()
         Endif
       Endif  
       Nombre()
     Endif
   EndDo
 
Return nil
 

Image
The idea is when !lAzar after end go to top

Thanks.

Regards,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1593
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Eof() en xBrowse

Postby nageswaragunupudi » Sat Sep 07, 2013 4:17 pm

1. Your modification to xbrowse is correct.
2. If oBrw:GoDown() == 1 means that we did not reach end of file.
If oBrw:GoDown() == 0 it means we reached end of file

So the logic must be

Play Music
if oBrw:GoDown() == 0
oBrw:GoTop()
endif
LOOP
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10254
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Eof() en xBrowse

Postby acuellar » Sat Sep 07, 2013 4:31 pm

Perfect

Thanks Mr.

Regards,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1593
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Eof() en xBrowse

Postby carlos vargas » Wed Feb 12, 2014 6:43 pm

if you say
1. Your modification to xbrowse is correct.
2. If oBrw:GoDown() == 1 means that we did not reach end of file.
If oBrw:GoDown() == 0 it means we reached end of file


Code: Select all  Expand view

METHOD GoDown( nDown ) CLASS TXBrowse

   local nLines, n, oCol, nAt

   if ::nLen == 0 .or. ::Eof()
      if ::bPastEof != nil
         Eval( ::bPastEof )
      endif
      return nil                 // here  - return 0 ???  we reached end of file
   endif
 


and

Code: Select all  Expand view

         if ::bPastEof != nil .and. nDown == 1               //here - nDown should be 0?
            Eval( ::bPastEof )
         endif
         if ::oVScroll != nil
            ::VGoBottom()
         endif
 


is that I am trying to locate a bug as I have the following code with tdolphin

Code: Select all  Expand view

...
      oQryCaja := oServer:Query( "SELECT * FROM vCATCAJA WHERE FECHA=%1 AND NUM_CIUD=%2 ORDER BY FECHA", { dFecha, nNumCiud } )
...
  DEFINE DIALOG oDlg NAME "DLG_CAJAC" OF oMainWnd ICON GetIcon() FONT oFontD

   oDlg:cTitle := StrFormat( "Registro/Movimientos de caja: [%1]", DToC( dFecha ) )

   REDEFINE XBROWSE oBrw DATASOURCE oQryCaja ID 101 OF oDlg AUTOSORT ;
      ON DBLCLICK CajaOM_Editar( FALSE ) FONT oFontD FOOTERS

   ADD TO oBrw DATA bColMov1            TITLE "Tipo"         SIZE 030 CENTER
   ADD TO oBrw DATA oQryCaja:FECHA      TITLE "Fecha"        SIZE 080 CENTER
...
 

and occasionally, when I move to the last record with the mouse movement (pgdown), and I want to edit this code
clarify that if I use the keys end or down to goto to lastrec, the error does not occur, is only the pgdown key
Code: Select all  Expand view

PROCEDURE CajaOM_Editar( lNuevo )
...
   IF lNuevo
      nTipo         := 1
      cNumDocu      := Space( 15 )
      cBeneficiario := PadR( "CREDICOM", 50 )
      nMonto        := 0
      cConcepto     := aIngresos[ 1 ]
      nConcepto     := CajaOM_GetConceptoN( cConcepto )
      cDescripcion  := Space( 80 )
   ELSE
      IF oQryCaja:Eof()
         MsgAlert( "No hay movimientos en caja registrados, nada que editar." )
         oBrw:SetFocus()
         RETURN
      ELSE
...
 

to me indicates that reached the end of file.
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1688
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 5 guests