Jump to content

Need Help with comparing a string char by char


Recommended Posts

Hey guys,

It's clay again begging for some assistance.

I am working on a script and where I am comparing license agreements. I have a local copy of Lic Agreement and I grab a copy from the installs that I run. For some reason i get an issue with some of the Lic agreements not matching even though they should.

I decided to investiage:

I stripped both of the Agreements (the local one and the one I grab from the install) of all white spaces (ws) and Carriage Returns (CR) and placed them in variables

I then compared the the length of both of the variables. The lengths appeared to be different by ONE character... which puzzeled me.

So up until this point I know that the strings that I am comparing do not have WS's or CR's, and appear to be different by one character or something else unknown to me. I tried StringinStr() and StringCompare to see if they would retrun successful, but none of that worked so I know something is wrong.

Now what I want to do is to compare both string character by character to see which thing is creatingthe difference. I was doing some rough testing using string split to split char by char, but that has not been going very well for me as the entire variable is being return rather than just each char. Could someone help me with this...

I have included some of my testing code

If you are not sure what is wrong with what I am going... any other suggests that might work would be fine, just point me in the right direction and I will take care of the rest.

#include <file.au3>
Dim $aRecords
Dim $InstallRecords
Dim $l_logfile
Dim $i_logfile 


    $l_logfile = fileopen(@ScriptDir & "\Functions\local.txt", 9); this will create the file and directory structure if needed
    If $l_logfile = -1 Then
        MsgBox(0, "", "It didn't create it")
        exit -1
    EndIf
    
    $i_logfile = fileopen(@ScriptDir & "\Functions\Install.txt", 9); this will create the file and directory structure if needed
    If $i_logfile = -1 Then
        MsgBox(0, "", "It didn't create it")
        exit -1
    EndIf
    MsgBox(0, "", "Going into the long loop")
    While 1
                $local = FileRead("local.txt", 1)
                If @error = -1 Then 
        MsgBox(0, "", "Reached the end of # 1")
    ExitLoop
    EndIf
    Wend
    
    While 1
                $install = FileRead("install.txt", 1)
                If @error = -1 Then 
    MsgBox(0, "", "Reached the end of # 2") 
    ExitLoop
    EndIf 
    Wend
    
    $aRecords = Stringsplit($local, "")
    $InstallRecords = Stringsplit($install, "")
    
    For $x = 1 to $aRecords[0]
                Msgbox(0,'Record:' & $x, $aRecords[$x])
    Msgbox(0,'InstallRecords:' & $x, $InstallRecords[$x])
Next
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...