Jump to content

Ubound returning wrong number?


NELyon
 Share

Recommended Posts

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.

#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

Try this

#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

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...