Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Monday, 13 May 2019

The array functions allow for the manipulation of arrays.

Array() : The Array() functions returns a variant containing an array. 

Note: The first element in the array is zero.

This function has the form: 

Array(arglist): 

arglist: A list (separated by commas) of values that is the elements in the array.

Examples: Uses of the array function

a=Array(5,10,15,20)
Msgbox (a(3))

Output: 20


a=Array(5,10,15,20)
For Each x in a
    Msgbox (x)
Next

Output: 
5
10
15
20

Filer():  The Filter() function returns  a zero-based array that contains a subset of a string array based on a filter criteria.

Note: If no matches of the value parameter  are found, the Filter function will return an empty array.

Note: If the parameter inputstrings is Null or is NOT a one-dimensional array, an error will occur.

This function has the form:

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

inputstrings: (required) A one-dimensional array of strings to be searched.
value: (rquired) The string to search for 
include: (Optional) A Boolean value that indicates whether to return the substrings that inlcude or exclude value. True returns the subset of the array that contains value as a substring. False returns the subset of the array that does not contain value as substring (default=True)
compare: (optional) Specifies the string comparision to use. This parameter can have one of the following values: 
0=vbBinarCompare- Perform a binary comparison 
1=vbTextCompare-Perform a textual comparison.

Example: 

Filter items that contains "S" 

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S")
For each x In b
    Msgbox(x)
Next

Output: Sunday
Saturday


Items that does NOT contain "S" (include=False)

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",False)
For each x In b
    Msgbox(x)
Next

Output: 

Monday
Tuesday
Wednesday
Thursday
Friday


Items that  contain "S" with a textual comparison (compare=1)

a=Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
b=Filter(a,"S",True,1)
For each x In b
    Msgbox(x)
Next

Output: Sunday
Tuesday
Wednesday
Thursday
Saturday








No comments:

Post a Comment

Note: only a member of this blog may post a comment.