Friday, February 25, 2011

Sort the Array elements

Whith below code we can sort the Array values

Dim arrSortOut(8)
arrSortOut(0)=2
arrSortOut(1)=1
arrSortOut(2)=5
arrSortOut(3)=6
arrSortOut(4)=8
arrSortOut(5)=0
arrSortOut(6)=9
arrSortOut(7)=3
arrSortOut(8)=4


For i = UBound(arrSortOut) - 1 To 0 Step -1
For j= 0 to i
' you want in Ascending order
If arrSortOut(j)>arrSortOut(j+1) then
' You want in Decending order
' if arrSortOut(j) temp=arrSortOut(j+1)
arrSortOut(j+1)=arrSortOut(j)
arrSortOut(j)=temp
end if
Next
Next


For x=0 to 8
msgbox arrSortOut(x)
Next

Monday, January 3, 2011

How to create "RegisterUserFunc" and use same?

Customize the any object class operation with RegisterUserFunc with below steps.
1. Create one function with expected behavior code
2. Register same with below statement.
RegisterUserFunc TOClass, MethodName, FunctionName, SetAsDefault

Code Snippet:-

1. Define the Function
Function existEdit(Editbox, x)
If Editbox.exist(10) Then
Set objReference =Editbox
strClassName = objReference.GetTOProperty("attached text")
reporter.ReportEvent micDone, "Entered data in Edit box"," entered < " & x & "> value in " & strClassName
editbox.set x
End If
End Function

2. Register the function for Object class operation.
RegisterUserFunc "WinEdit", "set", "existEdit"

Use the Registered user function with below code :-
Dialog("Login").WinEdit("Agent Name:").Set "TestData "

For customize function unregister use below statement.

UnRegisterUserFunc "WinEdit", "Set"