SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    KS
    KS is offline
    Senior Member
    Join Date
    May 2001
    Posts
    265
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Comparing two List of String

    I have two lists of string. Is there a simple way to print out the differences between two lists.
    Thanks in advance.

    ------------------

  2. #2
    Senior Member
    Join Date
    Nov 1999
    Location
    Eagle, ID,USA
    Posts
    1,035
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two List of String

    Here's a ListCompare function I wrote sometime back

    whoops! you'll have to comment out the DPrint call. This is one of our debug print statements. It wont compile with this in it.
    ------------------


    [This message has been edited by TonyM (edited 02-28-2002).]

    [This message has been edited by TonyM (edited 02-28-2002).]
    Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac.

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Location
    Chicago, IL USA
    Posts
    383
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two List of String

    Shows the differences in two Lists of strings ?

    This a a basic part of SilkTest, the Verify() function.
    Be sure to wrap it in a do ... except or your test will stop:

    ------------------
    Rob Kapteyn
    Rob Kapteyn, CSTE
    RobKapteyn@gmail.com

  4. #4
    Senior Member
    Join Date
    Nov 1999
    Location
    Eagle, ID,USA
    Posts
    1,035
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two List of String

    I believe the question was printing out the difference and not erroring out on a difference.

    ------------------
    Have you ever noticed? Anybody going slower than you is an idiot, and anyone going faster than you is a maniac.

  5. #5
    Senior Member
    Join Date
    Nov 2000
    Location
    Bloomington, IL
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two List of String

    First confirm that the two lists have the same number of entries using the ListCount function and comparing the returned integer.

    Then set up a for loop from 1 to the returned value from ListCount. Get the the same index from each list and use the Verify function within a do..except construct. If they match do nothing, if they do not print the first value, then the second value.

    The following function handles this:


    CheckLists(LIST OF STRING lsList1, LIST OF STRING lsList2)
    INTEGER iCnt1
    INTEGER iCnt2
    INTEGER i
    BOOLEAN bHeader = FALSE

    iCnt1 = ListCount (lsList1)
    iCnt2 = ListCount (lsList2)

    do
    Verify (iCnt1, iCnt2)

    except
    Print("The two lists do not match in the number of entries")
    Print("First list: {iCnt1} Second list {iCnt2}"
    Print("")
    return

    for i = 1 to iCnt1
    do
    Verify (lsList1[i], lsList2[i])
    except
    if bHeader == FALSE
    Print("The following list values did not match")
    bHeader = TRUE
    Print("In list value {i}. List 1: {lsList1[i]} List 2: {lsList2[i]}")



    ------------------

  6. #6
    KS
    KS is offline
    Senior Member
    Join Date
    May 2001
    Posts
    265
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two List of String

    Thanks everyone. This last one is really nice.
    Thanks again..

    ------------------

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:06 AM.

Copyright BetaSoft Inc.