Jump to content

Stilling stuck with comparing arrays


Recommended Posts

Question.

I am using _FileReadToArray to ofcourse "read a file to an array", however I noticed that every other slot on the array is empty. I am assuming that those slots appear empty becasue it hold a New Line or Line Break or something other information such as that. This causes problems for me when I try to compare the contents of that array with another.

So I try reading what I get from _FileReadToArray to another array, and in the process I am trying to discarding anything that is not a string .. including all line breaks, new lines etc.

However when I print this array using a loop or using the _ArrayDisplay function I still have those DAMN empty slots in my array. Any thoughts on how I can avoid this?

some of my sample code is below

For $x = 1 to $aRecords[0]
    $aRecords[$x] = StringStripws(StringStripCR($aRecords[$x]), 8)
    If $aRecords[$x] <> "" or $aRecords[$x] <> CHR(10) or $aRecords[$x] <> @LF  Then $Array1[$x-1] = $aRecords[$x]
    $count1 += 1
Next
Redim $Array1[$count1]
    
For $x = 1 to $da_instRecords[0]
    $da_instRecords[$x] = StringStripws(StringStripCR($da_instRecords[$x]), 8)
    If $da_instRecords[$x] <> "" or $da_instRecords[$x] <> CHR(10) or $da_instRecords[$x] <> @LF Then $Array2[$x-1] =  
                $da_instRecords[$x]
    $count2 += 1
Next
Redim $Array2[$count2]

I have also tried

For $x = 1 to $aRecords[0]
    $aRecords[$x] = StringStripws(StringStripCR($aRecords[$x]), 8)
    $test = IsString($aRecords[$x])
    If $test = 1 Then $Array1[$x-1] = $aRecords[$x]
    $count1 += 1
Next
Redim $Array1[$count1]

Any ideas

Link to comment
Share on other sites

Question.

I am using _FileReadToArray to ofcourse "read a file to an array", however I noticed that every other slot on the array is empty. I am assuming that those slots appear empty becasue it hold a New Line or Line Break or something other information such as that. This causes problems for me when I try to compare the contents of that array with another.

So I try reading what I get from _FileReadToArray to another array, and in the process I am trying to discarding anything that is not a string .. including all line breaks, new lines etc.

However when I print this array using a loop or using the _ArrayDisplay function I still have those DAMN empty slots in my array. Any thoughts on how I can avoid this?

some of my sample code is below

For $x = 1 to $aRecords[0]
    $aRecords[$x] = StringStripws(StringStripCR($aRecords[$x]), 8)
    If $aRecords[$x] <> "" or $aRecords[$x] <> CHR(10) or $aRecords[$x] <> @LF  Then $Array1[$x-1] = $aRecords[$x]
    $count1 += 1
Next
Redim $Array1[$count1]
    
For $x = 1 to $da_instRecords[0]
    $da_instRecords[$x] = StringStripws(StringStripCR($da_instRecords[$x]), 8)
    If $da_instRecords[$x] <> "" or $da_instRecords[$x] <> CHR(10) or $da_instRecords[$x] <> @LF Then $Array2[$x-1] =  
                $da_instRecords[$x]
    $count2 += 1
Next
Redim $Array2[$count2]
That doesn't look like it gets rid of 'empty lines'. Maybe it should be more like this

$count1 = 1
For $x = 1 to $aRecords[0]
    $aRecords[$x] = StringStripws(StringStripCR($aRecords[$x]), 8)
    If $aRecords[$x] <> "" and $aRecords[$x] <> @LF  Then 
           $Array1[$count1] = $aRecords[$x]
       $count1 += 1
        endif

Next
Redim $Array1[$count1]
$Array1[0] = $coiunt1 - 1
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...