Filter: Difference between revisions
No edit summary |
|||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.'' | |||
Filter (''stringarray'', ''value''[, ''include''[, ''compare'']]) | Filter (''stringarray'', ''value''[, ''include''[, ''compare'']]) | ||
Line 16: | Line 18: | ||
|} | |} | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Rem Filter Example | |||
' | 'Filter finds matches in an array of strings | ||
Dim Who, TheKs, NotEric | Dim Who, TheKs, NotEric | ||
Who = Array("Eric", "Kenny", "Kyle", "Stan") | Who = Array("Eric", "Kenny", "Kyle", "Stan") | ||
Line 32: | Line 34: | ||
Dim i | Dim i | ||
Print ArrName | Print ArrName | ||
For i = 0 TO | For i = 0 TO UBound(Arr) | ||
Print " " & Arr(i) | Print " " & Arr(i) | ||
Next | Next | ||
Line 57: | Line 59: | ||
== Related items == | == Related items == | ||
[[replace| | [[replace|Replace]] | ||
[[Category:Language Reference]] | [[Category:Language Reference]] | ||
[[Category:Strings]] | |||
[[Category:BASIC Functions]] |
Latest revision as of 15:24, 25 March 2019
This function is for BASIC compatibility. It is not available in pure JavaScript projects.
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 (Basic)
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