Micro Focus QTP (UFT) Forums
Comapring two List & Print the missed values - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Comapring two List & Print the missed values (/Thread-Comapring-two-List-Print-the-missed-values)



Comapring two List & Print the missed values - kalaivanan123 - 08-07-2012

Hi All,

Code:
Call compare_values()

Function compare_values()

   Exp_Values="India,Spain,Japan,Singapore,Russia,China,Mexico,England,Germany"
    Spl_Exp_Values=split(Exp_values,",")

    Act_values="India;Japan;Singapore;China;England"
    Spl_Act_values=split(Act_values,";")

        For i=0 to Ubound(Spl_Exp_values)
        flg=0

            For j=0 to Ubound(Spl_Act_values)
                comp=Strcomp(Spl_Exp_Values(i),Spl_Act_values(j))
                If comp= 0 Then
                    flg=flg+1
                    Exit For
                End If
            Next

        If flg=0 Then
                Print (Spl_Exp_Values(i) & " not found in Actual Values list")
        End If

    Next

End Function

In above function I am comparing two List (i.e :-Exp_vaues,Act_values). Then I would like to print the missed values in second list which is present in first. Now I'm getiing Output like below,

Output:-
Spain not found in Actual Values list
Russia not found in Actual Values list
Mexico not found in Actual Values list
Germany not found in Actual Values list

But I would like to print all the missed values in one statement(E.g:-Spain,Russia,Mexico,Germany not found in Actual values list)

Pls help me to get solution for this.


RE: Comapring two List & Print the missed values - sree.85 - 08-08-2012

Modify this code as

Code:
If flg=0 Then
                Print (Spl_Exp_Values(i) & " not found in Actual Values list")
        End If
dim str1
str1=str1&Spl_Exp_Values(i)
come out of loop and print the str1 value