SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Senior Member
    Join Date
    Sep 2008
    Posts
    108
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Viewing differences

    Hi

    Sorry if this has been asked before (I did a search and couldnt see anything obvious), but I am getting to grips with the file comparison functionality and need to find a way to create two reports, get TC to compare them and tell me what the differences are.

    I started by creating two text files which differ slightly and using the 'Create File Checkpoint' function.
    This tells me that the files differ but doesnt show me the differences! Am I missing something here? [img]/images/graemlins/confused.gif[/img]

    Thanks

    Steve

  2. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Viewing differences

    Hi Steve,

    Files.Compare compares files by their hash values, so it is unable to report the actual difference. However, you can create a function that will compare files line by line and tell you which lines are different. For example:
    <font class="small">Code:</font><hr /><pre>//JScript
    function compareFiles(f1, f2)
    {
    var fso = Sys.OleObject("Scripting.FileSystemObject");
    var file = fso.OpenTextFile(f1);
    var fileStr1 = file.ReadAll().replace(/[\r\n]{2,}/g, "\r\n");
    file.Close();
    file = fso.OpenTextFile(f2);
    var fileStr2 = file.ReadAll().replace(/[\r\n]{2,}/g, "\r\n");
    file.Close();
    //NOTE: replace(/[\r\n]{2,}/g, "\r\n") removes empty lines

    var fileStrings1 = fileStr1.split("\r\n");
    var fileStrings2 = fileStr2.split("\r\n");

    f1 = Utilities.ExtractFileName(f1);
    f2 = Utilities.ExtractFileName(f2);
    var ret = true;
    var diffStr = "";
    var length = (fileStrings1.length &gt; fileStrings2.length)?fileStrings1.length:fileStrin gs2.length;
    for(var i = 0; i &lt; length; i++)
    {
    var str1 = "", str2 = "";
    if(i &lt; fileStrings1.length) str1 = fileStrings1[i];
    if(i &lt; fileStrings2.length) str2 = fileStrings2[i];

    if(str1 != str2)
    {
    diffStr += "Line " + (i + 1) + ":\r\n\t[" + f1 + "]:" + str1 + "\r\n\t[" + f2 + "]:" + str2 + "\r\n";
    ret = false;
    }
    }

    if(!ret) Log.Warning("Files are not identical", diffStr);
    return ret;
    }
    ...
    if(!compareFiles("c:\\myFile1.txt", "c:\\myFile2.txt")) // Do something
    ...</pre><hr />
    Jared - AQA Support

  3. #3
    Senior Member
    Join Date
    Sep 2008
    Posts
    108
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Viewing differences

    I will give that a try.

    Thank you.

  4. #4
    Senior Member
    Join Date
    Sep 2008
    Posts
    108
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Viewing differences

    I may have found a different way to do this but still cant quite get an end to end run.

    We have 'Beyond Compare' (BC) which I selected in Tools, Options, Stores, Engines.
    This is great as Test Complete checks that the files differ and opens Beyond Compase so I can now see the differences side by side.

    I then want to save the output and close BC, and stop the test. There is a setting in Tools, Options, Stores, Engines which is 'Wait until diff closes' which I have selected for this.

    What happens is that BC does nothing after opening as the script is waiting for control to pass back once BC is closed. As there is no actual VB script that deals with the wait state, I cant add my Beyond Compare code in at the right place.

    I hope this makes sense, and if so, can someone tell me how I would get round this?

    Thanks

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    1,920
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Viewing differences

    Hi Steve,

    If I get it right, you compare your files in BC and want your script to access its GUI, save the results, close BC and continue, but TC is waiting for it to close, so, the script is not running. Is that correct?
    If yes, you can execute the code that launches BC by using the CallObjectMethodAsync method (see the "Calling Methods Asynchronously" help topic for an example).
    Jared - AQA Support

  6. #6
    Senior Member
    Join Date
    Sep 2008
    Posts
    108
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Viewing differences

    Jared

    Yes you got that spot on.

    I'll try that CallObjectMethodAsync method now.

    Thanks

    Steve

  7. #7
    Member
    Join Date
    Jul 2008
    Posts
    146
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Viewing differences

    You should trey the command line bc options....
    Write a batch file to invoke BC from cmd line and do a file comaper.. BC filereport options

    BCCompare.exe @C:\Mainscript.txt

    Your mainscript.txt has the following commands

    criteria rulesbased
    #load folders
    Load c:\gold c:\current
    expand all
    select diff.files
    filereport : laypout:side-by-side options:displaymismatches output:C:\x.txt

    the results get appended

    Read the x.txt line by line from TC and log the messages

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin 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 11:52 AM.

Copyright BetaSoft Inc.