Link:http://output.to/sideway/default.asp?qno=180300021 Script, Scripting Language, VBScript elements, Server-Side VBScript Function Filter Function
VBScript Array FunctionsFunctions for manipulating array expression. Filter Functionlast updated 9/18/2017Create a zero-based array by filtering a given InputStrings according to the specified search Value, and the specified Include and Compare settings. SyntaxFilter(InputStrings, Value[, Include[, Compare]]) ArgumentInputStringsRequired. Any valid one-dimensional array which is used for searching and copying elements from.ValueRequired. Any Valid string speified to search for.IncludeOptional setting. A Boolean value that is used to indicate whether the return subset of the array should contain Value as a substring. If Include argument is omitted, True is used and Filter returns the subset of the array that contains Value as a substring. If Include is False, Filter returns the subset of the array that does not contain Value as a substring.CompareOptional setting. A constant that is used to indicate the kind of comparison used when evaluating substrings. If compare argument is omitted, 0 is used and a binary comparison is performed.SettingsInclude argument ValueConstant1Returns the subset of the array that contains Value as a substring.0Returns the subset of the array that does not contain Value as a substring. Compare argument vbConstantValueConstantvbBinaryCompare0Perform a binary comparison.vbTextCompare1Perform a textual comparison. ReturnsReturns a Variant() containing a zero-based array with elements obtained by filtering a given InputStrings according to the specified search Value, and the specified Include and Compare settings.Returns of Filter function: Resultreturn valueValues are foundVariant of an zero-based one-dimensional array contains all valuesNo value is foundVariant of a zero length array Special returns of Filter function: InputStringsValuereturn valueNullAnyRun-time ErrorEmptyAnyRun-time Error""AnyRun-time ErrorNot a one-dimensional arrayAnyRun-time ErrorAnyNullRun-time ErrorArray(Null), Array()Empty,""Variant of a zero length arrayArray(Empty), Array("")Empty,""Variant of an array with a "" elementValid arrayEmpty,""InputStrings Remarks
Requirement2ExamplesExamples of Filter function ASP VbScript Command:
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /internet/users/sideblog/default.asp varsstr, TypeNameEval("cmda1"), TypeNameEval(cmda1), TypeNamestr=Array(Null):fnd=Empty[""], Variant()[Filter(str,fnd)], String[], Variant()str=Array(Null):fnd=Empty[""], Variant()[Filter(str,fnd)], String[], Variant()str=Array():fnd=Empty[], Variant()[Filter(str,fnd)], String[], Variant()str=Array(Empty):fnd=Empty[""], Variant()[Filter(str,fnd)], String[""], Variant()str=Array(""):fnd=Empty[""], Variant()[Filter(str,fnd)], String[""], Variant()str=Array(12,21,13):fnd=Empty['12' '21' '13'], Variant()[Filter(str,fnd)], String['12' '21' '13'], Variant()str=Array(Null):fnd=""[""], Variant()[Filter(str,fnd)], String[], Variant()str=Array():fnd=""[], Variant()[Filter(str,fnd)], String[], Variant()str=Array(Empty):fnd=""[""], Variant()[Filter(str,fnd)], String[""], Variant()str=Array(""):fnd=""[""], Variant()[Filter(str,fnd)], String[""], Variant()str=Array(12,21,13):fnd=""['12' '21' '13'], Variant()[Filter(str,fnd)], String['12' '21' '13'], Variant()str=Array(12,21,13):fnd=1['12' '21' '13'], Variant()[Filter(str,fnd)], String['12' '21' '13'], Variant()str=Array(12,21,13):fnd=2['12' '21' '13'], Variant()[Filter(str,fnd)], String['12' '21'], Variant()str=Array(12,21,13):fnd=3['12' '21' '13'], Variant()[Filter(str,fnd)], String['13'], Variant()str=Split("12 21 13"):fnd=1["12" "21" "13"], Variant()[Filter(str,fnd)], String["12" "21" "13"], Variant()str=Split("12 21 13"):fnd=2["12" "21" "13"], Variant()[Filter(str,fnd)], String["12" "21"], Variant()str=Split("12 21 13"):fnd=3["12" "21" "13"], Variant()[Filter(str,fnd)], String["13"], Variant()str=Array("12","21","13"):fnd=1["12" "21" "13"], Variant()[Filter(str,fnd)], String["12" "21" "13"], Variant()str=Array("12","21","13"):fnd=2["12" "21" "13"], Variant()[Filter(str,fnd)], String["12" "21"], Variant()str=Array("12","21","13"):fnd=3["12" "21" "13"], Variant()[Filter(str,fnd)], String["13"], Variant()str=Array(""," "," "):fnd=" "["" " " " "], Variant()[Filter(str,fnd)], String[" " " "], Variant()str=Array(""," "," "):fnd=" "["" " " " "], Variant()[Filter(str,fnd)], String[" "], Variant()str=Array(""," "," "):fnd=" "["" " " " "], Variant()[Filter(str,fnd)], String[], Variant()str=Array(12,21,13):fnd=1:flg=1['12' '21' '13'], Variant()[Filter(str,fnd,flg)], String['12' '21' '13'], Variant()str=Array(12,21,13):fnd=1:flg=0['12' '21' '13'], Variant()[Filter(str,fnd,flg)], String[], Variant()str=Array(12,21,13):fnd=2:flg=1['12' '21' '13'], Variant()[Filter(str,fnd,flg)], String['12' '21'], Variant()str=Array(12,21,13):fnd=2:flg=0['12' '21' '13'], Variant()[Filter(str,fnd,flg)], String['13'], Variant()str=Array(12,21,13):fnd=3:flg=1['12' '21' '13'], Variant()[Filter(str,fnd,flg)], String['13'], Variant()str=Array(12,21,13):fnd=3:flg=0['12' '21' '13'], Variant()[Filter(str,fnd,flg)], String['12' '21'], Variant()str=Array("ab","aB","Ab","AB"):fnd="a":flg=1:cmp=0["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg)], String["ab" "aB"], Variant()str=Array("ab","aB","Ab","AB"):fnd="B":flg=1:cmp=0["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg)], String["aB" "AB"], Variant()str=Array("ab","aB","Ab","AB"):fnd="a":flg=0:cmp=0["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg)], String["Ab" "AB"], Variant()str=Array("ab","aB","Ab","AB"):fnd="B":flg=0:cmp=0["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg)], String["ab" "Ab"], Variant()str=Array("ab","aB","Ab","AB"):fnd="a":flg=1:cmp=1["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg,cmp)], String["ab" "aB" "Ab" "AB"], Variant()str=Array("ab","aB","Ab","AB"):fnd="B":flg=1:cmp=1["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg,cmp)], String["ab" "aB" "Ab" "AB"], Variant()str=Array("ab","aB","Ab","AB"):fnd="a":flg=0:cmp=1["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg,cmp)], String[], Variant()str=Array("ab","aB","Ab","AB"):fnd="B":flg=0:cmp=1["ab" "aB" "Ab" "AB"], Variant()[Filter(str,fnd,flg,cmp)], String[], Variant() Sources |
Sideway BICK Blog 21/03 |