FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE : Error in method Delrepos
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 10:13 AM
Hello,

Next code generates a error in method Delrepos :

First a filter is set :

SET FILTER TO BEDIENDE->lActief // Logical field

This is preprocessed in :

dbSetFilter( {|| BEDIENDE->lActief}, "BEDIENDE->lActief" )

In Method Delrepos we have :

         elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
            // cFilter is "BEDIENDE->lActief"
            bFilter  := ( ::cAlias )->( &cFilter )
            if ! ( ::cAlias )->( Eval( bFilter ) )

( ::cAlias )->( &cFilter ) gives not a codeblock , only the value from the logical field , so EVAL(bFilter) generates a error

Maybe (::cAlias)->(Eval(bFilter)) can be changed in :

IF (IsBlock(bFilter) .AND. (::cAlias)->(Eval(bFilter)))  .OR. (IsLogical(bFilter) .AND. bFilter)


Frank
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 05:13 PM
Frank,

Here is the fix I posted awhile back. This is in the method delRepos().

elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) ) 
            //bFilter  :=  ( ::cAlias )->( &cFilter ) 
            cFilter  :=  ( ::cAlias )->( &cFilter ) 
            if ! eval( {|| cFilter } ) //( ::cAlias )->( Eval( bFilter ) )


Antonio, are you getting this?

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 07:00 PM

James,

Yes, we have been recently reviewing that issue in the spanish forums.

I wonder if we could avoid there the use of "&".

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 07:06 PM
Wouldn't this be the right fix ?
elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) ) 
           bFilter  :=  ( ::cAlias )->( &( "{ || " + cFilter + " }" ) )
           ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 07:11 PM
My code is wrong. This is a right example:
#include "FiveWin.ch"

function Main()

   local cFilter, bFilter

   USE Customer

   SET FILTER TO Customer->Married  // logical value

   cFilter = "{ || " + DbFilter() + " }"
   
   MsgInfo( ( Alias() )->( Eval( &cFilter ) ) )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 07:13 PM
Cleaner code:
#include "FiveWin.ch"

function Main()

   local bFilter

   USE Customer

   SET FILTER TO Customer->Married  // logical value

   bFilter = &( "{ || " + DbFilter() + " }" )
   
   MsgInfo( ( Alias() )->( Eval( bFilter ) ) )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 07:15 PM

Antonio,

>Wouldn't this be the right fix ?

Yes, I didn't remember to use the alias in mine.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
XBROWSE : Error in method Delrepos
Posted: Mon Oct 06, 2008 07:16 PM
So this should be the right code for Method DelRepos():
         elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
            bFilter  := &( "{ || " + cFilter + " }" )
            if ! ( ::cAlias )->( Eval( bFilter ) )

unless I am missing something
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: XBROWSE : Error in method Delrepos
Posted: Tue Mar 10, 2009 07:45 PM
Could someone please help me:

This is my filter:
Set filter to reschein->ZiNr = left(cRgZimmerNr + space(10),10)

With the new code I get following error:
Error BASE/1003 Variable does not exist: CRGZIMMERNR

I found this in the clipper docs:
Notes
. Declared variables: A character string returned by DBFILTER()
may not operate correctly when recompiled and executed using the
macro operator (&) if the original filter expression contained
references to local or static variables, or otherwise depended on
compile-time declarations.


Thanks in advance
Otto
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBROWSE : Error in method Delrepos
Posted: Wed Mar 11, 2009 05:36 AM

Otto,

It sounds like cRgZimmerNr is either a local or a static. You may either need to make it a private or make a copy of it assigned to a private. Better still would be to make a set/get function that returns the variable. The function holds the value as a static. If you need help doing this, let me know.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: XBROWSE : Error in method Delrepos
Posted: Wed Mar 11, 2009 08:23 AM
Hello James,

I am not clear about the line

if ! ( ::cAlias )->( Eval( bFilter ) ).

If I am right this sets the filter which dbFilter() reads before.
Couldn’t I commend out this line?

Thanks in advance and best regards,
Otto

METHOD DelRepos() CLASS TXBrowse

DBFILTER() returns the filter condition defined in the current work area
as a character string. If no FILTER has been SET, DBFILTER() returns a
null string ("").


Code (fw): Select all Collapse
  elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
            bFilter  := &( "{ || " + cFilter + " }" )
  
       //  if ! ( ::cAlias )->( Eval( bFilter ) )
           ( ::cAlias )->( dbSkip( 1 ) )
               if ( ::cAlias )->( eof() )
                  ( ::cAlias )->( DbGoBottom() )
               endif
               
               lRepos := .t.
            endif
      //   endif
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: XBROWSE : Error in method Delrepos
Posted: Thu Mar 12, 2009 06:58 PM

Is it save to commend out this line?

Thanks in advance
Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: XBROWSE : Error in method Delrepos
Posted: Fri Mar 13, 2009 02:54 PM
Otto,

The first test is to see if there is a filter.

Code (fw): Select all Collapse
   ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )

Then the test of eval( bFilter ) tests if the deleted record is NOT in the filter. I am not clear why this is needed. If there is a filter, then any record not in the filter will not be visible in the browse. So, I am not sure under what circumstances this code is needed.

Perhaps Antonio can answer this?

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: XBROWSE : Error in method Delrepos
Posted: Sat Mar 14, 2009 10:01 AM

Otto, James,

Method DelRePos() is called from Method Refresh():

Basically the idea is that we are going to repaint the browse, and if the current record does not match the filter expression, then we skip it, so it is not displayed.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
Re: XBROWSE : Error in method Delrepos
Posted: Sat Mar 14, 2009 11:06 AM
Antonio Linares wrote:Otto, James,

Method DelRePos() is called from Method Refresh():

Basically the idea is that we are going to repaint the browse, and if the current record does not match the filter expression, then we skip it, so it is not displayed.


Yes , but when a filter is active , (X)harbour will skip the record !

When the programmer starts from a record that doesn't match the filter expression , it can maybe avoided with

SKIP


Frank