This forum is for eXpress++ general support.
Janko
Posts: 111 Joined: Sat Mar 20, 2010 8:36 am
Location: Cerklje
#1
Post
by Janko » Mon Mar 04, 2019 3:02 pm
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
rdonnay
Site Admin
Posts: 4813 Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:
#2
Post
by rdonnay » Mon Mar 04, 2019 4:34 pm
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
#3
Post
by Janko » Tue Mar 05, 2019 3:07 am
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 829 times
rdonnay
Site Admin
Posts: 4813 Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:
#4
Post
by rdonnay » Tue Mar 05, 2019 7:41 am
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.
rdonnay
Site Admin
Posts: 4813 Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:
#5
Post
by rdonnay » Tue Mar 05, 2019 7:50 am
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
#6
Post
by Janko » Tue Mar 05, 2019 9:59 pm
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
rdonnay
Site Admin
Posts: 4813 Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:
#7
Post
by rdonnay » Wed Mar 06, 2019 5:53 am
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
#8
Post
by Janko » Wed Mar 06, 2019 10:42 am
Dear Roger,
yes, yes it works perfect. Thank you very much.
Kind regards
Janko