Page 1 of 2

XBROWSE : Error in method Delrepos

PostPosted: Mon Oct 06, 2008 10:13 am
by demont frank
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 :

Code: Select all  Expand view
         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 :

Code: Select all  Expand view
IF (IsBlock(bFilter) .AND. (::cAlias)->(Eval(bFilter)))  .OR. (IsLogical(bFilter) .AND. bFilter)


Frank

PostPosted: Mon Oct 06, 2008 5:13 pm
by James Bott
Frank,

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

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


Antonio, are you getting this?

Regards,
James

PostPosted: Mon Oct 06, 2008 7:00 pm
by Antonio Linares
James,

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

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

PostPosted: Mon Oct 06, 2008 7:06 pm
by Antonio Linares
Wouldn't this be the right fix ?
Code: Select all  Expand view
elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
           bFilter  :=  ( ::cAlias )->( &( "{ || " + cFilter + " }" ) )
           ...

PostPosted: Mon Oct 06, 2008 7:11 pm
by Antonio Linares
My code is wrong. This is a right example:
Code: Select all  Expand view
#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

PostPosted: Mon Oct 06, 2008 7:13 pm
by Antonio Linares
Cleaner code:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local bFilter

   USE Customer

   SET FILTER TO Customer->Married  // logical value

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

return nil

PostPosted: Mon Oct 06, 2008 7:15 pm
by James Bott
Antonio,

>Wouldn't this be the right fix ?

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

Regards,
James

PostPosted: Mon Oct 06, 2008 7:16 pm
by Antonio Linares
So this should be the right code for Method DelRepos():
Code: Select all  Expand view
         elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
            bFilter  := &( "{ || " + cFilter + " }" )
            if ! ( ::cAlias )->( Eval( bFilter ) )

unless I am missing something

Re: XBROWSE : Error in method Delrepos

PostPosted: Tue Mar 10, 2009 7:45 pm
by Otto
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

Re: XBROWSE : Error in method Delrepos

PostPosted: Wed Mar 11, 2009 5:36 am
by James Bott
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

Re: XBROWSE : Error in method Delrepos

PostPosted: Wed Mar 11, 2009 8:23 am
by Otto
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: Select all  Expand view
 elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
            bFilter  := &( "{ || " + cFilter + " }" )
 
       //  if ! ( ::cAlias )->( Eval( bFilter ) )
           ( ::cAlias )->( dbSkip( 1 ) )
               if ( ::cAlias )->( eof() )
                  ( ::cAlias )->( DbGoBottom() )
               endif
               
               lRepos := .t.
            endif
      //   endif
         

Re: XBROWSE : Error in method Delrepos

PostPosted: Thu Mar 12, 2009 6:58 pm
by Otto
Is it save to commend out this line?

Thanks in advance
Otto

Re: XBROWSE : Error in method Delrepos

PostPosted: Fri Mar 13, 2009 2:54 pm
by James Bott
Otto,

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

Code: Select all  Expand view

   ! 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

Re: XBROWSE : Error in method Delrepos

PostPosted: Sat Mar 14, 2009 10:01 am
by Antonio Linares
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.

Re: XBROWSE : Error in method Delrepos

PostPosted: Sat Mar 14, 2009 11:06 am
by demont frank
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