Monday 28 March 2011

QTP @ VBScript > Array Sorting

Leave a Comment
'********************************************************
' @ Purpose of the script: To sort an array
'********************************************************
Dim arrSortOut(8)
arrSortOut(0)="X"
arrSortOut(1)="Z"
arrSortOut(2)="Y"
arrSortOut(3)="H"
arrSortOut(4)="I "
arrSortOut(5)="A"
arrSortOut(6)="L"
arrSortOut(7)="M"
arrSortOut(8)="R"

' Before Sorting an array
Print "@@@@@@@@@@@@@@@@@@@@@@@"
Print " Before Sorting : The Array elements are "
Print "@@@@@@@@@@@@@@@@@@@@@@@"
For x=0 to 8
Print arrSortOut(x)
Next

' Sorting an array now...
For i = UBound(arrSortOut) - 1 To 0 Step -1
    For j= 0 to i
        If arrSortOut(j)>arrSortOut(j+1) Then
            temp=arrSortOut(j+1)
            arrSortOut(j+1)=arrSortOut(j)
            arrSortOut(j)=temp
        End If
   Next
Next
' After Sorting an array
Print "@@@@@@@@@@@@@@@@@@@@@@@"
Print " After Sorting out  :The Array elements are "
Print "@@@@@@@@@@@@@@@@@@@@@@@"
For x=0 to 8
Print arrSortOut(x)
Next

0 comments:

Post a Comment

Monday 28 March 2011

QTP @ VBScript > Array Sorting

'********************************************************
' @ Purpose of the script: To sort an array
'********************************************************
Dim arrSortOut(8)
arrSortOut(0)="X"
arrSortOut(1)="Z"
arrSortOut(2)="Y"
arrSortOut(3)="H"
arrSortOut(4)="I "
arrSortOut(5)="A"
arrSortOut(6)="L"
arrSortOut(7)="M"
arrSortOut(8)="R"

' Before Sorting an array
Print "@@@@@@@@@@@@@@@@@@@@@@@"
Print " Before Sorting : The Array elements are "
Print "@@@@@@@@@@@@@@@@@@@@@@@"
For x=0 to 8
Print arrSortOut(x)
Next

' Sorting an array now...
For i = UBound(arrSortOut) - 1 To 0 Step -1
    For j= 0 to i
        If arrSortOut(j)>arrSortOut(j+1) Then
            temp=arrSortOut(j+1)
            arrSortOut(j+1)=arrSortOut(j)
            arrSortOut(j)=temp
        End If
   Next
Next
' After Sorting an array
Print "@@@@@@@@@@@@@@@@@@@@@@@"
Print " After Sorting out  :The Array elements are "
Print "@@@@@@@@@@@@@@@@@@@@@@@"
For x=0 to 8
Print arrSortOut(x)
Next

No comments:

Post a Comment