Jump to content

Recommended Posts

Posted

I've been using a rss reader to collect some information about .torrent files (the titles) and

saved it into a .ini file. Now I would like to put the information in a listbox. The problem is that

I can't figure out how to but all the rows/lines into the listbox. Not only the first one (Swedvdr.org).

Any idea?

$READ = IniRead(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5", "RSS", "NotFound")
GUICtrlSetData($Listbox2,$READ)

Inifile

[Section5]
swedvdr.org
Autoit1XXX
Autoit2XXX
Autoit3XXX
Autoit4XXX
Autoit5XXX
Autoit6XXX
Autoit7XXX
Autoit8XXX
Posted

You need to use IniReadSection()

Example

$READ = IniReadSection(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5")
For $x = 1 To $READ[0][0]
   _GUICtrlListAddItem ($Listbox2, $READ[$x][0])
Next

Note:

Don't forget to be able to use __GUICtrlListAddItem() you need to include GuiList.au3

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Posted (edited)

You need to use IniReadSection()

Example

$READ = IniReadSection(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5")
For $x = 1 To $READ[0][0]
   _GUICtrlListAddItem ($Listbox2, $READ[$x][0])
Next

Note:

Don't forget to be able to use __GUICtrlListAddItem() you need to include GuiList.au3

Still it only reads the first/ adding the first line =/

Thanks for replay anyway.

INIFILE

RSS=swedvdr.org
Autoit1
Autoit2
Autoit3
Autoit4
Autoit5
Edited by walle
Posted (edited)

Still it only reads the first/ adding the first line =/

Thanks for replay anyway.

INIFILE

RSS=swedvdr.org
Autoit1
Autoit2
Autoit3
Autoit4
Autoit5
Try INIFILE
[Section5]
RSS=swedvdr.org
RSS=Autoit1
RSS=Autoit2
RSS=Autoit3
RSS=Autoit4
RSS=Autoit5
Edited by GMK
Posted

Here is the Rss reader, don't know if that helps

#include <array.au3>
#Include <Inet.au3>
$source = _INetGetSource("http://www.swedvdr.org/rss")
$a = _StrBetween($source, "<title>", "</title>")
GUISetState()
Global $text
For $i = 0 to UBound($a) -1
    $text &= $a[$i] & @CRLF
Next
;GUICtrlSetData($Edit, $text & @CRLF)
IniWrite(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5", "RSS", $text)

While 1
    Sleep(2000)
WEnd


Func _StrBetween($sString, $sStart, $sEnd, $vCase = -1, $iSRE = -1)
    If $iSRE = -1 Or $iSRE = Default Then
        If $vCase = -1 Or $vCase = Default Then $vCase = 0
        If $vCase <> -1 And $vCase <> Default Then $vCase = 1
        Local $sHold = '', $sSnSStart = '', $sSnSEnd = ''
        While StringLen($sString) > 0
            $sSnSStart = StringInStr($sString, $sStart, $vCase)
            If Not $sSnSStart Then ExitLoop
            $sString = StringTrimLeft($sString, ($sSnSStart + StringLen($sStart)) - 1)
            $sSnSEnd = StringInStr($sString, $sEnd, $vCase)
            If Not $sSnSEnd Then ExitLoop
            $sHold &= StringLeft($sString, $sSnSEnd - 1) & Chr(1)
            $sString = StringTrimLeft($sString, $sSnSEnd)
        WEnd
        If Not $sHold Then Return SetError(1, 0, 0)
        $sHold = StringSplit(StringTrimRight($sHold, 1), Chr(1))
        Local $aArray[UBound($sHold) - 1]
        For $iCC = 1 To UBound($sHold) - 1
            $aArray[$iCC - 1] = $sHold[$iCC]
        Next
        Return $aArray
    Else
        If $vCase = Default Or $vCase = -1 Then $vCase = '(?i)'
        If $vCase <> Default And $vCase <> -1 Then $vCase = ''
        Local $aArray = StringRegExp($sString, '(?s)' & $vCase & $sStart & '(.*?)' & $sEnd, 3)
        If IsArray($aArray) Then Return $aArray
        Return SetError(1, 0, 0)
    EndIf
EndFunc
Posted (edited)

Would it work better to separate your RSS entries with commas, instead of @CRLF? Then you could do a StringSplit and insert that array into the ListBox.

Edit: Does InetGetSource work for this? When I try it, it doesn't bring up the same thing and seems as if a login is necessary. There might be a cookie stored in your session that logs you in automatically, but I was just curious.

Edited by GMK
Posted

Would it work better to separate your RSS entries with commas, instead of @CRLF? Then you could do a StringSplit and insert that array into the ListBox.

Edit: Does InetGetSource work for this? When I try it, it doesn't bring up the same thing and seems as if a login is necessary. There might be a cookie stored in your session that logs you in automatically, but I was just curious.

A login is indeed necessary...

You are probably right, damn I hate does listboxes >_>

Posted

Like GMK mention in post #4 try creating the ini file like this one:

[section5]

RSS=swedvdr.org

RSS=Autoit1

RSS=Autoit2

RSS=Autoit3

RSS=Autoit4

RSS=Autoit5

I tried the code below and work for me as long the ini file is created as the one above:

#include <GUIConstants.au3>
#include <GUIList.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Listbox", 250, 270, 193, 115)
$Listbox2 = GUICtrlCreateList("", 8, 16, 225, 201)
$Button1 = GUICtrlCreateButton("Close", 80, 232, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$READ = IniReadSection(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5")
For $x = 1 To $READ[0][0]
   _GUICtrlListAddItem ($Listbox2, $READ[$x][1])
Next

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button1
            Exit

    EndSwitch
WEnd
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Posted

Like GMK mention in post #4 try creating the ini file like this one:

I tried the code below and work for me as long the ini file is created as the one above:

#include <GUIConstants.au3>
#include <GUIList.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Listbox", 250, 270, 193, 115)
$Listbox2 = GUICtrlCreateList("", 8, 16, 225, 201)
$Button1 = GUICtrlCreateButton("Close", 80, 232, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$READ = IniReadSection(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5")
For $x = 1 To $READ[0][0]
   _GUICtrlListAddItem ($Listbox2, $READ[$x][1])
Next

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Button1
            Exit

    EndSwitch
WEnd

Worked like a charm, but, still need some changes in the rss reader.

Tried this, IniWrite(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5", "RSS", "RSS=" & $text)

Need "RSS=" before Autoit2,autoit3,autoit4,autoit5.

Any idea?

//Walle

Posted

Going by your code in post #5:

change

For $i = 0 to UBound($a) -1
    $text &= $a[$i] & @CRLF
Next
;GUICtrlSetData($Edit, $text & @CRLF)
IniWrite(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5", "RSS", $text)

For

For $i = 0 to UBound($a) -1
    IniWrite(@HomeDrive & "\Temp\Burnbuddy.ini", "Section5", $i, $a[$i])
Next

This will create a ini file like the one below which also work with the code in post #9

[Section5]
0=swedvdr.org
1=Autoit1
2=Autoit2
3=Autoit3
4=Autoit4
5=Autoit5
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Posted

It sounds like you're getting closer to your goal, but instead of writing to an INI file to be read into a listbox, wouldn't it be more efficient to just write into the listbox--skipping the "middle man?"

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
  • Recently Browsing   0 members

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