Thursday, 18 July 2019

UFT:'ReadParameter_FN

'@Description This function reads the action parameter value and returns back.
'@Documentation This function reads the action parameter value and returns back.
Function ReadParameter_FN(str_Name)

Err.Clear
Dim tempValue
tempValue = str_Name
On Error Resume Next

dataSource = "Global"
ReadParameter_FN = Datatable.Value(str_Name,dataSource)

If Err.Number <> 0 Then
Err.Clear
dataSource = Environment.Value("ActionName")
If Environment.Value("localRowIndex") = 0 Then
Environment.Value("localRowIndex") = 1
End If
datatable.LocalSheet.SetCurrentRow Environment.Value("localRowIndex")
ReadParameter_FN = Datatable.Value(str_Name,dataSource)
End If


If Err.Number <> 0 Then
Call ReportEvent_FN("Fail", "Read Value from Datasheet", "Reading parameter : "&str_Name&" from Datasheet is failed. Description:"&Err.Description)
End If

Err.Clear

End Function

UFT: WriteParameter_FN

'@Description This function writes the action parameter value and returns back.
'@Documentation This function writes the action parameter value and returns back.
Function WriteParameter_FN(str_Name, str_Value)

Err.Clear
     On Error Resume Next
Datatable.Value(str_Name,dataSource) = str_Value

If Err.Number <> 0 Then
DataTable.getSheet(dataSource).AddParameter str_Name, str_Value
Err.Clear
End If

If dataSource <> "Global" Then
Datatable.Value(str_Name,"Global") = str_Value
If Err.Number <> 0 Then
DataTable.getSheet("Global").AddParameter str_Name, str_Value
Err.Clear
End If
End If
Err.Clear

End Function

UFT ValidateRegularPattern_FN function

Function ValidateRegularPattern_FN(str_Pattern, str_Value)
Err.Clear

Dim regEx, Match

Set regEx = New RegExp   ' Create a regular expression.
regEx.Pattern = str_Pattern   ' Set pattern.
regEx.IgnoreCase = True   ' Set case insensitivity.
regEx.Global = True   ' Set global applicability.
Match  = regEx.Test(str_Value)   ' Execute search.
 
ValidateRegularPattern_FN = Match

Err.Clear

End Function

Spring Boot : Exception Handler 14