Jump to content

Array not working correctly


Recommended Posts

I'm sure this is one of my stupid mistakes, but...

#include "XML.au3"
#include <Inet.au3>

Func forecast()
    Local $feed = StringReplace(StringReplace(StringReplace(StringReplace(_INetGetSource ("http://rss.weather.com/weather/rss/local/USCO0128?cm_ven=LWO&cm_cat=rss&par=LWO_rss"), "]]>", ""), "<![CDATA[", ""), "&deg;", "°"), "For more details?", "Click Yes for further forecast")
    Local $array
    If @error Then
        SetError(@error)
        Return "Unable to read RSS feed"
    EndIf
    For $i=1 To __StringFindOccurances($feed, "<item>")
        If _XMLGet(_XMLGet($feed, "item", $i), "title") = "Your 10-Day Forecast forEnglewood, CO (80155)" Then
            $num = $i
            ExitLoop
        EndIf
    Next
    If $num = 0 Then Return "Could not find forecast in XML file"
    $forecast = StringReplace(_XMLGet(_XMLGet($feed,"item", $num), "description"), "----", @CRLF)
    $array[0] = $forecast
    $array[1] = $feed
    $array[2] = $num
    Return $forecast
EndFunc

$return = forecast()
MsgBox (0, "bleep", _XMLGet(_XMLGet($return[1],"item", $return[2]), "link"))
If MsgBox (4, "forecast", $return[0]) = 6 Then Run (_XMLGet(_XMLGet($return[1],"item", $return[2]), "link"))

When I run this, I get...

C:\Documents and Settings\Matt Roth\My Documents\AutoIt\forecast.au3 (19) : ==> Badly formated variable or macro.: 
$array[0] = $forecast 
$array^ ERROR

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

I'm sure this is one of my stupid mistakes, but...

#include "XML.au3"
#include <Inet.au3>

Func forecast()
    Local $feed = StringReplace(StringReplace(StringReplace(StringReplace(_INetGetSource ("http://rss.weather.com/weather/rss/local/USCO0128?cm_ven=LWO&cm_cat=rss&par=LWO_rss"), "]]>", ""), "<![CDATA[", ""), "&deg;", "°"), "For more details?", "Click Yes for further forecast")
    Local $array
    If @error Then
        SetError(@error)
        Return "Unable to read RSS feed"
    EndIf
    For $i=1 To __StringFindOccurances($feed, "<item>")
        If _XMLGet(_XMLGet($feed, "item", $i), "title") = "Your 10-Day Forecast forEnglewood, CO (80155)" Then
            $num = $i
            ExitLoop
        EndIf
    Next
    If $num = 0 Then Return "Could not find forecast in XML file"
    $forecast = StringReplace(_XMLGet(_XMLGet($feed,"item", $num), "description"), "----", @CRLF)
    $array[0] = $forecast
    $array[1] = $feed
    $array[2] = $num
    Return $forecast
EndFunc

$return = forecast()
MsgBox (0, "bleep", _XMLGet(_XMLGet($return[1],"item", $return[2]), "link"))
If MsgBox (4, "forecast", $return[0]) = 6 Then Run (_XMLGet(_XMLGet($return[1],"item", $return[2]), "link"))

When I run this, I get...

C:\Documents and Settings\Matt Roth\My Documents\AutoIt\forecast.au3 (19) : ==> Badly formated variable or macro.: 
$array[0] = $forecast 
$array^ ERROR
When you declared your array variable, you didn't give it enough (or any) subscripts:

Local $array[3]

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...