XBROWSE : Error in method Delrepos

XBROWSE : Error in method Delrepos

Postby demont frank » 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 :

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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Postby James Bott » Mon Oct 06, 2008 5:13 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Mon Oct 06, 2008 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Oct 06, 2008 7:06 pm

Wouldn't this be the right fix ?
Code: Select all  Expand view
elseif ! Empty( cFilter := ( ::cAlias )->( dbFilter() ) )
           bFilter  :=  ( ::cAlias )->( &( "{ || " + cFilter + " }" ) )
           ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Oct 06, 2008 7:11 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Mon Oct 06, 2008 7:13 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby James Bott » Mon Oct 06, 2008 7:15 pm

Antonio,

>Wouldn't this be the right fix ?

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

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Antonio Linares » Mon Oct 06, 2008 7:16 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: XBROWSE : Error in method Delrepos

Postby Otto » Tue Mar 10, 2009 7: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6074
Joined: Fri Oct 07, 2005 7:07 pm

Re: XBROWSE : Error in method Delrepos

Postby James Bott » Wed Mar 11, 2009 5: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBROWSE : Error in method Delrepos

Postby Otto » Wed Mar 11, 2009 8: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: 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
         
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6074
Joined: Fri Oct 07, 2005 7:07 pm

Re: XBROWSE : Error in method Delrepos

Postby Otto » Thu Mar 12, 2009 6:58 pm

Is it save to commend out this line?

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6074
Joined: Fri Oct 07, 2005 7:07 pm

Re: XBROWSE : Error in method Delrepos

Postby James Bott » Fri Mar 13, 2009 2:54 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: XBROWSE : Error in method Delrepos

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41414
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: XBROWSE : Error in method Delrepos

Postby demont frank » 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
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests