Jump to content
Sign in to follow this  
sonicxtacy02

needa little help preventing duplicate strings

Recommended Posts

I have a working script of an rss feed reader i've been working on for some time. The problem is the way the script is setup sometimes i get duplicate strings of data(if the feed is shorter than "normal" the script starts reading from the beginning). What i need is a function that saves the data in the $info variable then checks it each time the loop is run. If the string is a duplicate then the loop is exited. How do i go about doing this? Here is my script

Global $string, $stringtrim, $rrpath, $rsslink, $x, $info,$jamnum, $jamind, $skin
$rrpath=iniread("trafficdetails.ini","trafficdetails","rrpath","C:\Program files\road runner")
if $cmdlineraw="" then $cmdlineraw=1


$rsslink=iniread("trafficdetails.ini","TrafficDetails","RssLink","Default")
InetGet($rsslink, "trdetails.txt", 1)

Dim $arr[1]
        $a=0
        $f = FileOpen("trdetails.txt",0)
        stringstripcr($f)
        $query="Jam"
        while 1
            $l = FileReadLine($f)
            If @error = -1 Then ExitLoop
            If StringInStr($l,$query) Then _ArrayAdd($arr, $l)
        WEnd
         For $i = 1 to UBound($arr) - 1
            for $x = 1 to 30
            $string = _SRE_Between($arr[$i], "<title>", "</title>")
            if not $string="" then
                $stringtrim= StringTrimRight($string, 32)
                $info = $stringtrim
                $a=$a+1
                if $a=41 OR $a=82 OR $a=123 OR $a=164 OR $a=205 OR $a=246 OR $a=287 OR $a=328 OR $a=369 OR $a=410 OR $a=451 OR $a=492 OR $a=533 OR $a=574 OR $a=615 OR $a=656 OR $a=697 OR $a=738 OR $a=779 OR $a=820 OR $a=861 OR $a=902 OR $a=943 OR $a=984 OR $a=1025 OR $a=1066 OR $a=1107 OR $a=1148 OR $a=1189 OR $a=1230 then
                    get_ind()
                    Run($rrpath&"\exec.exe SETLABEL;!feed"&$X&";" & $info)
                Else
                endif

            EndIf
            Next
        Next

sleep(5000)
Dim $time= filegettime("trdetails.txt")
sleep(4000)

If Not @error Then
    $yyyymd = $time[1] & "/" & $time[2] & "/" & $time[0] & " @ " & $time[3] & ":" & $time[4]
Else
    $yyyymd="Unavailable"
EndIf

run($rrpath&"\exec.exe SETLABEL;CUSTOMTRAFFICDETAILS;" & $yyyymd)


Func _SRE_Between($s_String, $s_Start, $s_End, $i_ReturnArray = 0); $i_ReturnArray returns an array of all found if it = 1, otherwise default returns first found
    $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
    If Not @error And Not $i_ReturnArray And IsArray($a_Array) Then Return $a_Array[0]
    If IsArray($a_Array) Then Return $a_Array
    return $string
EndFunc

Func get_ind()
    $indopt=iniread("trafficdetails.ini","TrafficDetails","IndicatorSupport","Default")
    $feed1=IniRead("trafficdetails.ini","IndicatorLocation","feed1","Default")
    $feed2=IniRead("trafficdetails.ini","IndicatorLocation","feed2","Default")
    $feed3=IniRead("trafficdetails.ini","IndicatorLocation","feed3","Default")
    $feed4=IniRead("trafficdetails.ini","IndicatorLocation","feed4","Default")
    $feed5=IniRead("trafficdetails.ini","IndicatorLocation","feed5","Default")
    $feed6=IniRead("trafficdetails.ini","IndicatorLocation","feed6","Default")
    $feed7=IniRead("trafficdetails.ini","IndicatorLocation","feed7","Default")
    $feed8=IniRead("trafficdetails.ini","IndicatorLocation","feed8","Default")
    $feed9=IniRead("trafficdetails.ini","IndicatorLocation","feed9","Default")
    $feed10=IniRead("trafficdetails.ini","IndicatorLocation","feed10","Default")
    $feed11=IniRead("trafficdetails.ini","IndicatorLocation","feed11","Default")
    $feed12=IniRead("trafficdetails.ini","IndicatorLocation","feed12","Default")
    $feed13=IniRead("trafficdetails.ini","IndicatorLocation","feed13","Default")
    $feed14=IniRead("trafficdetails.ini","IndicatorLocation","feed14","Default")
    $feed15=IniRead("trafficdetails.ini","IndicatorLocation","feed15","Default")
    $feed16=IniRead("trafficdetails.ini","IndicatorLocation","feed16","Default")
    $feed17=IniRead("trafficdetails.ini","IndicatorLocation","feed17","Default")
    $feed18=IniRead("trafficdetails.ini","IndicatorLocation","feed18","Default")
    $feed19=IniRead("trafficdetails.ini","IndicatorLocation","feed19","Default")
    $feed20=IniRead("trafficdetails.ini","IndicatorLocation","feed20","Default")
    $feed21=IniRead("trafficdetails.ini","IndicatorLocation","feed21","Default")
    $feed22=IniRead("trafficdetails.ini","IndicatorLocation","feed22","Default")
    $feed23=IniRead("trafficdetails.ini","IndicatorLocation","feed23","Default")
    $feed24=IniRead("trafficdetails.ini","IndicatorLocation","feed24","Default")
    $feed25=IniRead("trafficdetails.ini","IndicatorLocation","feed25","Default")
    $feed26=IniRead("trafficdetails.ini","IndicatorLocation","feed26","Default")
    $feed27=IniRead("trafficdetails.ini","IndicatorLocation","feed27","Default")
    $feed28=IniRead("trafficdetails.ini","IndicatorLocation","feed28","Default")
    $feed29=IniRead("trafficdetails.ini","IndicatorLocation","feed29","Default")
    $feed30=IniRead("trafficdetails.ini","IndicatorLocation","feed30","Default")
    if $indopt="true" Then
        select
        case $cmdlineraw=1 
            If $x=1 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed1&$jamind&";out")
            ElseIf $x=2 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed2&$jamind&";out")
            Elseif $x=3 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed3&$jamind&";out")
            Elseif $x=4 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed4&$jamind&";out")
            Elseif $x=5 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed5&$jamind&";out")
            Elseif $x=6 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed6&$jamind&";out")
            Elseif $x=7 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed7&$jamind&";out")
            Elseif $x=8 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed8&$jamind&";out")
            Elseif $x=9 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed9&$jamind&";out")
            Elseif $x=10 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed10&$jamind&";out")
            Endif
        case $cmdlineraw=2
            if $x=11 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed11&$jamind&";out")
            Elseif $x=12 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed12&$jamind&";out")
            Elseif $x=13 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed13&$jamind&";out")
            Elseif $x=14 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed14&$jamind&";out")
            Elseif $x=15 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed15&$jamind&";out")
            Elseif $x=16 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed16&$jamind&";out")
            Elseif $x=17 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed17&$jamind&";out")
            Elseif $x=18 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed18&$jamind&";out")
            Elseif $x=19 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed19&$jamind&";out")
            Elseif $x=20 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed20&$jamind&";out")
            ENDIf
        case $cmdlineraw=3
            if $x=21 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed21&$jamind&";out")
            Elseif $x=22 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed22&$jamind&";out")
            Elseif $x=23 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed23&$jamind&";out")
            Elseif $x=24 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed24&$jamind&";out")
            Elseif $x=25 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed25&$jamind&";out")
            Elseif $x=26 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed26&$jamind&";out")
            Elseif $x=27 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed27&$jamind&";out")
            Elseif $x=28 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed28&$jamind&";out")
            Elseif $x=29 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed29&$jamind&";out")
            Elseif $x=30 Then
                get_num()
                Run($rrpath&"\exec.exe LOADIMG;"&$feed30&$jamind&";out")
            EndIf
    EndSelect
    ELSE
    ENDif
EndFunc

Func get_num()
    $jamnumpre=stringright($info,4)
    $jamnum=stringtrimright($jamnumpre,2)
    if $jamnum=0 Then
        $jamind="trafficyellow.gif"
    Elseif $jamnum=1 Then
        $jamind="trafficyellow.gif"
    elseif $jamnum=2 Then
        $jamind="trafficyellow.gif"
    elseif $jamnum=3 Then
        $jamind="trafficorange.gif"
    elseif $jamnum=4 Then
        $jamind="trafficorange.gif"
    elseif $jamnum=5 Then
        $jamind="trafficorange.gif"
    elseif $jamnum=6 Then
        $jamind="trafficred.gif"
    elseif $jamnum=7 Then
        $jamind="trafficred.gif"
    elseif $jamnum=8 Then
        $jamind="trafficred.gif"
    elseif $jamnum=9 Then
        $jamind="trafficred.gif"
    EndIf
ENDFUNC
Edited by sonicxtacy02

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...