[Solved]How to get rid of empty lines in array

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
IRBaboon
Posts: 27
Joined: 11 Aug 2014, 07:48

[Solved]How to get rid of empty lines in array

27 Jan 2016, 07:12

Hey there,

I wrote a script to filter out crawler-bot IPs from a list of referrer URLs in a text file. After that a listview is filled with this array. I thougt deleting a line in an array deletes the key/value pair but only the value is deleted. So the listview is filled with empty lines between. How could I get rid of this? And, I bet there are much better aproaches of filtering then I did, maybe someone could point me the way to another method.

Refers is a .txt with a referrer url in each line
IpList is a .txt with a bot IP in each line

Code: Select all

RefArray := Object()
Loop, Read, %Refers%
{
    RefArray.Insert(A_LoopReadLine)
}
Loop, % RefArray.Length()
{
    element :=  RefArray[A_Index]
    MyIndex := A_Index
    Loop, Read, %IpList%
    {
        IfInString, element, %A_LoopReadLine%
                RefArray.Delete(MyIndex)
    }
}

Loop % RefArray.Length()
{
    line := RefArray[A_Index]
    LV_Add(, line)
}
LV_ModifyCol()
thank you
IRBaboon
Last edited by IRBaboon on 27 Jan 2016, 08:14, edited 1 time in total.
SifJar
Posts: 398
Joined: 11 Jan 2016, 17:52

Re: How to get rid of empty lines in array

27 Jan 2016, 07:28

Code: Select all

if line
   LV_Add(, line)
?

(should only add it to the list view if the variable contains a value)
User avatar
IRBaboon
Posts: 27
Joined: 11 Aug 2014, 07:48

Re: How to get rid of empty lines in array

27 Jan 2016, 08:14

damn, so easy and works like a charm

Thank you very much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5, mikeyww, Proxima and 295 guests