FILTER code block problem

This forum is for eXpress++ general support.
Post Reply
Message
Author
Janko
Posts: 111
Joined: Sat Mar 20, 2010 8:36 am
Location: Cerklje

FILTER code block problem

#1 Post by Janko »

Dear Roger,

I would like to filter array with content of variable cMAt which is a result of DCSLE. Bellow is the ilustration of my intentions, of course, it is not working in presented form.

Code: Select all

LOCAL bFlt:={|a| (alltrim(upper(cMat))) $ a[2]}

@0,0 DCSLE cMat SIZE 30,1  DATALINK {||oBrowse:refreshAll()}
 
@ 2,0 DCBROWSE oBrowse DATA arr SIZE 100,25 ;
      PRESENTATION dc_BrowPres()  FIT     FILTER bFlt 

…..
…..
Any hint appreciated.
BR Janko

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: FILTER code block problem

#2 Post by rdonnay »

Put some debugging in your code block to see the data as it is being evaluated :

The debug window will show the contents of a[2] and x for each row of the browse.

Code: Select all

LOCAL bFlt:={|a,x| x := (alltrim(upper(cMat))), (wtf x,a[2]), x $ a[2]}
The eXpress train is coming - and it has more cars.

Janko
Posts: 111
Joined: Sat Mar 20, 2010 8:36 am
Location: Cerklje

Re: FILTER code block problem

#3 Post by Janko »

Dear Roger,

I've prepared a small demo. Without FILTER it Works normal, after involving FILTER in DCBROWSE an error is generated
but I can not localize it.

I'd appreciate your suggestions.

BE Janko
Attachments
rogerFLT.zip
(30.34 KiB) Downloaded 630 times

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: FILTER code block problem

#4 Post by rdonnay »

I am still trying to figure out why it errors when cMat is initialized to an empty value.

I will work on this today.

A workaround for you is to initialize cMat := 'A'
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: FILTER code block problem

#5 Post by rdonnay »

Here is a fix that will work for you:

Code: Select all

LOCAL bFlt:={|a,x| x := (alltrim(upper(cMat))), Empty(x) .OR. x $ a[2]}
The eXpress train is coming - and it has more cars.

Janko
Posts: 111
Joined: Sat Mar 20, 2010 8:36 am
Location: Cerklje

Re: FILTER code block problem

#6 Post by Janko »

Dear Roger,

yes, the solution is logical and it works.

I would ask you also for an advice: how to refresh (repaint) oBrowse after each key stroke.
WHEN clause, DATALINK only do it after changin focus to oBrowse. I need refreshing after any change of cMat.

Thanks in advance
Janko

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: FILTER code block problem

#7 Post by rdonnay »

This code prevents an error if the data entered in the DCGET is not found in the array.

Code: Select all

cMat := Space(30)
 @0,0 DCGET cMat PICTURE '@!' ;
    KEYBLOCK {|n,x,o|o:GetData(),FilterBrowse(n,oBrowse,arr,cMat,o)}


STATIC FUNCTION FilterBrowse( nKey, oBrowse, arr, cMat, oGet )

LOCAL nFound := AScan(arr,{|a|Alltrim(cMat) $ a[2]}), lStatus := .t.

IF nKey < 97 .OR. nKey > 122  // A-Z
  RETURN .t.
ENDIF

IF nFound > 0 .AND. !Empty(cMat)
  oBrowse:goTop()
  oBrowse:forceStable()
  oBrowse:refreshAll()
ELSE
  lStatus := .f.
ENDIF

RETURN lStatus
The eXpress train is coming - and it has more cars.

Janko
Posts: 111
Joined: Sat Mar 20, 2010 8:36 am
Location: Cerklje

Re: FILTER code block problem

#8 Post by Janko »

Dear Roger,
yes, yes it works perfect. Thank you very much.

Kind regards
Janko

Post Reply