Filter: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Filter (''stringarray'', ''value''[, ''include''[, ''compare'']])
Filter (''stringarray'', ''value''[, ''include''[, ''compare'']])


'''Description'''
== Description ==


Filter returns an array of strings that is a subset of inputs that have met the specified filter criteria. The required parameter, ''stringarray'', is a one-dimensional array of strings to be filtered. The required parameter, ''value'', is a string expression to be searched for. The optional parameter, ''include'', is a boolean value, when TRUE, the returned values are the strings that contain value, when FALSE, the returned values do not contain value. The default value of ''include'' is TRUE. The optional parameter, ''compare'', is a numeric expression or constant that specifies the type of comparisons to perform, see below. The default value of ''compare'' is vbBinaryCompare.
Filter returns an array of strings that is a subset of inputs that have met the specified filter criteria. The required parameter, ''stringarray'', is a one-dimensional array of strings to be filtered. The required parameter, ''value'', is a string expression to be searched for. The optional parameter, ''include'', is a boolean value, when TRUE, the returned values are the strings that contain value, when FALSE, the returned values do not contain value. The default value of ''include'' is TRUE. The optional parameter, ''compare'', is a numeric expression or constant that specifies the type of comparisons to perform, see below. The default value of ''compare'' is vbBinaryCompare.
Line 16: Line 16:
|}
|}


'''Example'''
== Example ==


<pre>
<pre>
Line 38: Line 38:
</pre>
</pre>


'''Output'''
== Output ==


<pre>
<pre>
Line 55: Line 55:
</pre>
</pre>


'''Related items'''
== Related items ==


[[replace|REPLACE]]
[[replace|REPLACE]]


[[Category:Language Reference]]
[[Category:Language Reference]]

Revision as of 04:52, 16 August 2012

Filter (stringarray, value[, include[, compare]])

Description

Filter returns an array of strings that is a subset of inputs that have met the specified filter criteria. The required parameter, stringarray, is a one-dimensional array of strings to be filtered. The required parameter, value, is a string expression to be searched for. The optional parameter, include, is a boolean value, when TRUE, the returned values are the strings that contain value, when FALSE, the returned values do not contain value. The default value of include is TRUE. The optional parameter, compare, is a numeric expression or constant that specifies the type of comparisons to perform, see below. The default value of compare is vbBinaryCompare.

Table 10: Comparison constants

Constant Value Description
vbBinaryCompare 0 Binary comparison case sensitive (default)
vbTextCompare 1 Textual comparison, case insensitive

Example

REM Filter Example
'FILTER finds matches in an array of strings
Dim Who, TheKs, NotEric
Who = Array("Eric", "Kenny", "Kyle", "Stan")
TheKs = Filter(Who, "k", TRUE,vbTextCompare)
NotEric = Filter(Who, "Eric", FALSE, _
  vbBinaryCompare)
PrintArray "Who", Who
PrintArray "The K's", TheKs
PrintArray "Everyone but Eric", NotEric
Sub PrintArray(ArrName, Arr)
  Dim i
  Print ArrName
  For i = 0 TO UBOUND(Arr)
    Print "  " & Arr(i)
  Next
End Sub

Output

Who
  Eric
  Kenny
  Kyle
  Stan
The K's
  Kenny
  Kyle
Everyone but Eric
  Kenny
  Kyle
  Stan

Related items

REPLACE