1. Rick Domogalik
  2. PowerBuilder
  3. Friday, 20 May 2022 14:47 PM UTC

Is it possible to set your filter string to be an array?  I want users to be able to select multiple "keywords" from a list.  Then filter a master list based on whether or not the "keyword" column in the datawindow contains one of the selected keywords.  I have created a routine that puts all the selected keywords into an array "is_keyword_filter[]".

ls_filter = "keywords in '" + is_keyword_filter + "'"

dw_list.setfilter(ls_filter)

This code won't compile as I get an "Illegal use of array in expression from the ls_filter line of code.

 

Thanks!

Rick

 

 

Accepted Answer
Brad Mettee Accepted Answer Pending Moderation
  1. Friday, 20 May 2022 15:07 PM UTC
  2. PowerBuilder
  3. # Permalink

You'll need to create the filter one item at a time.

string ls_filter = ""
long ll_counter
long ll_itemcount
string is_keyword_filter[]

// populate ls_itemlist with selected items here, or add code within loop to iterate the list

for ll_counter = 1 to upperbound(is_keyword_filter)
  if ll_counter > 1 then
    ls_filter = " or "
  end if
  ls_filter = "colname='" + is_keyword_filter[ll_counter] + "'"
next

dw_list.setfilter(ls_filter)
dw_list.filter()
dw_list.groupcalc()

 

Comment
  1. Brad Mettee
  2. Friday, 20 May 2022 20:04 PM UTC
Roland,

That breaks down if the data entered matches any portion of the string, not just an exact match of one of the items.

  1. Helpful
  1. Mark Goldsmith
  2. Friday, 20 May 2022 20:05 PM UTC
You could also use...column_name In ('comma separated list').



@Miguel...yes, you can use a global function inside the quotes for the filter string. The only thing to remember is that if you are not using that global function anywhere else in script (outside of quotes) you'll have to call that function inside an If statement that never executes to ensure that it gets included in the executable. Would be nice if you could include it in a resource file like you can with datawindows and images.
  1. Helpful 1
  1. Miguel Leeuwe
  2. Saturday, 21 May 2022 03:41 AM UTC
Thanks Mark!
  1. Helpful
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.