SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Jul 2008
    Location
    Australia
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Use beyond compare to compare text files

    Hi All

    For the work i am doing we need to regularly compare log files (.txt). The task is to generate log files before a release and after deployment generate the log files and compare these logfiles to ensure that nothing is broken.

    I am using the code below to compare the text files but unable to parameterise this script so that i can get input from datatable for the logfile name and location. There are roughly 1800 logfiles pre and post release so getting input from datatable would be best option in my opinion and all I need for output is to check if the logfiles match or not.

    Below code works as log as i input the file location manually into the script but not from datatable.

    Option Explicit

    Dim WSHShell, BC3, LeftSide, RightSide, Result
    Set WSHShell = CreateObject("WScript.Shell")

    Set Result = nothing

    BC3 = """C:\New folder\Beyond Compare 4\Beyond Compare 4\BComp.exe"""
    LeftSide = " ""C:\New folder\Beyond Compare 4\Pre_Logfile1.txt"""
    RightSide = " ""C:\New folder\Beyond Compare 4\Pre_Logfile2.txt"""

    Result = WSHShell.Run(BC3 + "/quickcompare" + LeftSide + RightSide, 0, True)

    msgbox Result

    Did anyone work on a similar task?

    Thanks in advance

  2. #2
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,636
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0
    So you're just retrieving file location strings from the datatable and that's not working? Why not? What error are you getting? What code were you using?
    Last edited by NoUse4aName; 04-09-2018 at 09:31 AM.

  3. #3
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,847
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Why not use FSO and bind to the parent folder retrieving all the logfiles in a loop passing the fileObj.Name to the call?

    That way you don't need to know how many log files there are.

    Mark Smith.

  4. #4
    Member
    Join Date
    Jul 2008
    Location
    Australia
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Finally i managed get this work

    Option Explicit

    Dim WSHShell, BC4, LeftSide, RightSide, Result, intRowCount, Path, Pre, Post, Prefile, PostFile, PreSide, PostSide, intRunLoop
    Set WSHShell = CreateObject("WScript.Shell")

    Set Result = nothing


    'Get Row count from the Data Table
    intRowCount = DataTable.GetSheet(dtGlobalSheet).GetRowCount


    For intRunLoop = 1 to intRowCount

    'Set Current Row
    DataTable.GetSheet(dtGlobalSheet).SetCurrentRow intRunLoop

    'Get Data from Current row
    'Path column in datatable will have the location of the file
    'Pre and Post columns in datatable will have just the file names to compare
    Path = DataTable("Path", dtGlobalSheet)
    Pre = DataTable("Pre", dtGlobalSheet)
    Post = DataTable("Post", dtGlobalSheet)

    'Build the location of the file
    Prefile = Path&Pre
    PostFile = Path&Post

    'assign values for Beyond compare command
    BC4 = """C:\New folder\Beyond Compare 4\Beyond Compare 4\BComp.exe"""
    PreSide = " ""&Prefile&"""
    PostSide = " ""&PostFile&"""

    LeftSide = Replace(PreSide, "&Prefile&", Prefile)
    RightSide = Replace(PostSide, "&PostFile&", PostFile)

    'Compare the files and assign the result value to a variable
    Result = WSHShell.Run(BC4 + "/quickcompare" + LeftSide + RightSide, 0, True)

    'Write result value to datatable
    DataTable("Result", dtGlobalSheet) = Result

    Next


    'Clear variables
    Set WSHShell = nothing
    Set BC4 = nothing
    Set LeftSide = nothing
    Set RightSide = nothing
    Set Result = nothing
    Set intRowCount = nothing
    Set Path = nothing
    Set Pre = nothing
    Set Post = nothing
    Set Prefile = nothing
    Set PostFile = nothing
    Set PreSide = nothing
    Set PostSide = nothing
    Set intRunLoop = nothing

  5. #5
    Member
    Join Date
    Jul 2008
    Location
    Australia
    Posts
    79
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0
    Below are the details of output codes

    'Return codes
    'Code Meaning
    '0 Success
    '1 Binary same
    '2 Rules-based same
    '11 Binary differences
    '12 Similar
    '13 Rules-based differences
    '14 Conflicts detected
    '100 Unknown error
    '101 Conflicts detected, merge output not written
    '102 BComp.exe unable to wait until BCompare.exe finishes
    '103 BComp.exe cannot find BCompare.exe
    '104 Trial period expired
    '105 Error loading script file
    '106 Script syntax error
    '107 Script failed to load folders or files

 

 

Tags for this Thread

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.40 (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.00%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:02 PM.

Copyright BetaSoft Inc.