Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
array is not created
#1
Occasionally I get this error in a macro and can't understand why.
It runs 2-3 times an hour 5 days a week and has no problems but on a couple of occasions I get this. Why would it work 99.9% of the time rather than always failing?
An old blog on QM coding and automation.

The Macro Hook
#2
code please
#3
Function Get_Temp
Trigger !ca"MessageBoard" "#32770"     Help - how to add the trigger to the macro
Code:
Copy      Help
str Src Message zipcode url negtemp
zipcode="65101" ;;enter your zipcode here
ARRAY(str) Temp FeelsLike
url.from("http://www.weather.com/weather/local/" zipcode "?lswe=" zipcode "&lwsa=WeatherLocalUndeclared&from=whatwhere")
int MatchSucess
IntGetFile url Src
;Src.getfile("C:\qm\Desktop\new 2.txt")
err
,Speak "Error getting Temprature" 2 "" -3 55
,end
_s.time("%I:%M")
findrx(Src "<B CLASS=obsTempTextA(>|-)([\d]{1,3})" 0 0 Temp) ;;([\d]{1,3}+)
if Temp[1]="-"
,Message.from("The current Temperature is " Temp[1] Temp[2])
,_s.from("Temp: " Temp[1] Temp[2] "  " _s)
else
,Message.from("The current Temperature is " Temp[2])
,_s.from("Temp: " Temp[2] "  " _s)
err
,_s.from("Error retreiving temp")
Speak Message 2 "" 0 65
_s.setwintext(id(5 win("MessageBoard" "#32770")))
err
An old blog on QM coding and automation.

The Macro Hook
#4
findrx(Src "<B CLASS=obsTempTextA(>|-)([\d]{1,3})" 0 0 Temp) ;;([\d]{1,3}+)
if Temp[1]="-"

Return if findrx fails (returns -1). Then it does not create the array. For example, sometimes the page may be unavailable, but IntGetFile does not fail because the website provides an error page.


Forum Jump:


Users browsing this thread: 1 Guest(s)