Skip to main content

Filter-Array-Data

Command Description

Filter the specified data in an array or a dictionary

Command Prototype

arrRet = Filter(arrParam,sFilter,bInclude)

Parameter Description

ParameterRequiredTypeDefaultDescription
arrParamTrueexpression[]The array to be filtered
sFilterTruestring""The string used for filtering; the data can be kept or not, depending on whether the string is matched in the array entry. When null is entered, all non-strings and empty strings in the array are filtered
bIncludeTruebooleanTrueThe filter content is used to match in the target array. When the array elements cannot be matched, an empty array is returned if the filter text is retained, and the original target array is returned if the filter text is not retained. Otherwise, the array composed of all matched elements is returned if the filter text is retained, and the array removing all matched elements is returned if the filter text is not retained

return

arrRet,The variable used to save the output of the command.

Demo

TracePrint("----------------------Filter array data---------------------- --") 
//-------------------------------------------------------------------------------
//[Remarks] To filter the strings in the array, you can choose whether to keep the filter text.
//Input parameter 1:
// arrParam--Array to be filtered.
//Input parameter 2:
// sFilter--Filter the strings used, and match the array elements one by one. When null is input, will filter all non-strings and empty strings in the array.
//Input parameter 3:
// bInclude--Use the filter content to match in the target array. When no array elements are matched, if the filter text is retained, it will return an empty array, and if the filter text is not retained, the original target array will be returned; when When the elements of the array can be matched, if the filter text is retained, the array of all matched elements will be returned. If the filter text is not retained, the array of all elements after the matched elements will be removed will be returned.
//out parameters:
// arrRet--The variable to which the output of the function call is saved.
//
//Command prototype: arrRet=Filter(arrParam,sFilter,bInclude)
//-------------------------------------------------------------------------------
arrRet=Filter(["UiBot","RPA","UiBot123"],"Bot",True)
TracePrint(arrRet)