NELyon Posted December 25, 2006 Share Posted December 25, 2006 Ok, so i am trying to read the data within the <description> tag in the WikiHow's rss feed. I'm trying to take the description and set it into an Edit Box. It flashes for a minute and i can see that the data in entered, but then i get a Array variable has incorrect number of subscripts or subscript dimension range exceeded error. If i do it with a message box, it displays all of the message boxes, but gives the same error at the end. Heres the script. expandcollapse popup#include <array.au3> #Include <Inet.au3> $a = _StrBetween(_INetGetSource("http://www.wikihow.com/feed.rss"), "<description>", "</description>") $GUI = GUICreate("WikiHow's Latest HowTo's", 700, 700, 100, 50) $Edit = GUICtrlCreateEdit("", 50, 50, 600, 600) GUISetState() For $i = 0 to UBound($a) GUICtrlSetData($Edit, $a[$i] & @CRLF) Next While 1 Sleep(2000) WEnd ; By Smoke_N ; ; ; ; ; ; Smoke_N Rocks 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 Anyone know what's going on here? Link to comment Share on other sites More sharing options...
MHz Posted December 25, 2006 Share Posted December 25, 2006 Seems _StringBetween() returns a 0 based array with data starting from element 0. Add a -1 after the UBound For $i = 0 to UBound($a) -1 GUICtrlSetData($Edit, $a[$i] & @CRLF) Next Link to comment Share on other sites More sharing options...
NELyon Posted December 25, 2006 Author Share Posted December 25, 2006 (edited) I tried that, and it only returned the first description. EDIT: Nope, it only returns the LAST one lol Edited December 25, 2006 by D-Generation X Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted December 25, 2006 Share Posted December 25, 2006 guictrlsetdata sets the data, do a guictrlread & $a Link to comment Share on other sites More sharing options...
NELyon Posted December 25, 2006 Author Share Posted December 25, 2006 guictrlsetdata sets the data, do a guictrlread & $aUh, What?I'm trying to set the data. It will only set the last entry though. Link to comment Share on other sites More sharing options...
MHz Posted December 25, 2006 Share Posted December 25, 2006 Try this expandcollapse popup#include <array.au3> #Include <Inet.au3> $source = _INetGetSource("http://www.wikihow.com/feed.rss") ;~ MsgBox(0, '', $source) $a = _StrBetween($source, "<description>", "</description>") $GUI = GUICreate("WikiHow's Latest HowTo's", 700, 700, 100, 50) $Edit = GUICtrlCreateEdit("", 50, 50, 600, 600) GUISetState() Global $text For $i = 0 to UBound($a) -1 $text &= $a[$i] & @CRLF Next GUICtrlSetData($Edit, $text & @CRLF) While 1 Sleep(2000) WEnd ; By Smoke_N ; ; ; ; ; ; Smoke_N Rocks 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 Link to comment Share on other sites More sharing options...
NELyon Posted December 25, 2006 Author Share Posted December 25, 2006 Yes! Thanks MHz Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted December 25, 2006 Share Posted December 25, 2006 When u set the data itll erase all old data, thus i was suggesting reading all the data and then adding the string then setting it so it doesnt overwrite what u already had in it, and of course MHZ showed another way. Link to comment Share on other sites More sharing options...
NELyon Posted December 25, 2006 Author Share Posted December 25, 2006 Yeah, i modded MHz's code and got what i was looking for. THanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now