Thursday, December 2, 2010

Iterations on Columns

Hi, This is code to run scripts based on columns iterations. This is just to show that even we can iterate based on columns too.

' Iterations based on Columns in Datatable
' First column will run once and second column runs thrice calling the Actions/Functions in it for every iteration.

Dim RC, CC, i, j, var

RC = Datatable.GetRowCount
CC = Datatable.GetSheet(dtGlobalSheet).getparametercount

print "Row count of the Datatable is :"&RC
print "Column Count of the Datatable is :"&CC

Function One()
   print "First Function is executed"
End Function

Function Two()
   print "Second Function is Executed"
End Function

Function Three()
   print "Third Function is Executed"
End Function

For i=1 to CC

    For j=1 to RC

        If (i=1) Then

            print i&"st Column iteration"
            print j&" Row cell value of "&i&" Column is :"&                       Datatable.Value(i,dtGlobalSheet)
            Datatable.SetNextRow
           
        End If

        If (i=2) Then
            For des = 1 to 3
                For k=1 to RC
                    var=datatable.Value(i,dtGlobalSheet)
                    'print "The Function Name is :"&var
                    Execute Cstr(var)  'or 'Call Cstr(var)
                    Datatable.SetNextRow
                Next
            Next
        Exit For
        End If

    Next
    if(i=2) Then
        Exit For
    End If
Next
' Iterations based on Columns in Datatable
' First column will run once and second column runs thrice calling the Actions/Functions in it for every iteration.

Dim RC, CC, i, j, var

RC = Datatable.GetRowCount
CC = Datatable.GetSheet(dtGlobalSheet).getparametercount

print "Row count of the Datatable is :"&RC
print "Column Count of the Datatable is :"&CC

Function One()
   print "First Function is executed"
End Function

Function Two()
   print "Second Function is Executed"
End Function

Function Three()
   print "Third Function is Executed"
End Function

For i=1 to CC

    For j=1 to RC

        If (i=1) Then

            print i&"st Column iteration"
            print j&" Row cell value of "&i&" Column is :"& Datatable.Value(i,dtGlobalSheet)
            Datatable.SetNextRow
           
        End If

        If (i=2) Then
            For des = 1 to 3
                For k=1 to RC
                    var=datatable.Value(i,dtGlobalSheet)
                    'print "The Function Name is :"&var
                    Execute Cstr(var)  'or 'Call Cstr(var)
                    Datatable.SetNextRow
                Next
            Next
        Exit For
        End If

    Next
    if(i=2) Then
        Exit For
    End If
Next


"A good threat is worth a thousand tests" - Boris Beizer

No comments:

There was an error in this gadget