sytaxing
30th November 2008, 10:49 PM
I've been searching throughout the forum and haven't found any post teaching me how to use the t-zone hack with mortscript. After using trial and error I believe i have figured out a way to use the Tzone hack with most of the Mortscripts.
Within the script itself, if you paste Connect("The Internet") then
Connect("T-mobile US") in the section before the script starts grabbing data it should now work with the tzone hack. Certain script already uses the Connect("The Internet"), therefore all you have to do is paste Connect("T-mobile US) under it
Since I use joemanb tzone 5.99 cab within his post here http://forum.xda-developers.com/showthread.php?t=395203, he names the proxy setting "T-mobile US" therefore it is what i put in the connection command. If you did the hack manually replace "T-mobile US" with the name you provided when you first set up the hack. This name can be found through Setting->Connections-->Connections-->General(Tab).
Here is a sample in which i successfully changed chriscsh minicolour theme weather script to work with T-zone Hack. I've only started to learn Mortscript for about 2 days, and I've been aiming to make the weather script below to end its connection after grabbing the weather data but EndConnection or Disconnection isnt working, I hope someone can help me with this! I hope someone finds this useful!
local=RegRead("HKCU", "\Software\Manila\Weather\", "Locationcode")
If(local eq "")
CallScript("locationinput.mscr")
EndIf
# your location (see http://developer.yahoo.com/weather/ on finding your location)
location= RegRead("HKCU", "\Software\Manila\Weather\", "Locationcode")
# desired units for temp, f or c
units=RegRead("HKCU", "\Software\Manila\Weather\", "Units")
weather = ""
Connect("The Internet")
Connect("T-mobile US")
Connect=InternetConnected("http://www.goolge.com")
If (Connect=TRUE)
raw = ReadFile("http://weather.yahooapis.com/forecastrss?p="&location&"&u="&units)
Sleep(1000)
SleepMessage (2, "DATA READING....", "WEATHER UPDATE", 0)
cond = ""
code = ""
ccond = ""
ccode = ""
temp = ""
lotemp = ""
hitemp = ""
day = ""
location=""
ForEach line in split(raw,"^LF^",1)
If(Find(line,"<yweather:location"))
CallFunction("getValue", location, line,"location city")
EndIf
#<yweather:condition text="Mostly Cloudy" code="28" temp="39" date="Fri, 21 Dec 2007 7:53 am PST" />
if (Find(line,"<yweather:condition"))
CallFunction("getValue", ccond, line, "text")
CallFunction("getValue", ccode, line, "code")
CallFunction("getValue", temp, line, "temp")
EndIf
#<yweather:forecast day="Fri" date="21 Dec 2007"low="34" high="55" text="Mostly Sunny" code="34" />
if (Find(line,"<yweather:forecast"))
CallFunction("getValue", cond, line, "text")
CallFunction("getValue", hitemp, line, "high")
CallFunction("getValue", lotemp, line, "low")
CallFunction("getValue", day, line, "day")
EndIf
EndForEach
weather="W|"&ccode&"|"&hitemp&"|"&lotemp&""
Tweather= day&" H: "&hitemp&" L: "&lotemp&" "&cond
RegWriteString("HKCU", "\Software\A_C\S2U2\", "UserWeather", weather)
RegWriteString("HKCU", "\Software\Manila\Weather\", "CurrentCond", ccond)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Temp", temp)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Status", ccode)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Location", location)
RegWriteString("HKCU", "\Software\Manila\Weather\", "TCond", Tweather)
SleepMessage (2, "DONE", "WEATHER UPDATE", 0)
Else
Message ("NO CONNECTION", "WEATHER UPDATE")
EndIf
# subroutine to pull value out of XML
Sub getValue
offset = Find(argv[1],argv[2]) + Length(argv[2])+2
endoff = find(argv[1], """", offset)
return(SubStr(argv[1], offset, endoff-offset))
EndSub
Within the script itself, if you paste Connect("The Internet") then
Connect("T-mobile US") in the section before the script starts grabbing data it should now work with the tzone hack. Certain script already uses the Connect("The Internet"), therefore all you have to do is paste Connect("T-mobile US) under it
Since I use joemanb tzone 5.99 cab within his post here http://forum.xda-developers.com/showthread.php?t=395203, he names the proxy setting "T-mobile US" therefore it is what i put in the connection command. If you did the hack manually replace "T-mobile US" with the name you provided when you first set up the hack. This name can be found through Setting->Connections-->Connections-->General(Tab).
Here is a sample in which i successfully changed chriscsh minicolour theme weather script to work with T-zone Hack. I've only started to learn Mortscript for about 2 days, and I've been aiming to make the weather script below to end its connection after grabbing the weather data but EndConnection or Disconnection isnt working, I hope someone can help me with this! I hope someone finds this useful!
local=RegRead("HKCU", "\Software\Manila\Weather\", "Locationcode")
If(local eq "")
CallScript("locationinput.mscr")
EndIf
# your location (see http://developer.yahoo.com/weather/ on finding your location)
location= RegRead("HKCU", "\Software\Manila\Weather\", "Locationcode")
# desired units for temp, f or c
units=RegRead("HKCU", "\Software\Manila\Weather\", "Units")
weather = ""
Connect("The Internet")
Connect("T-mobile US")
Connect=InternetConnected("http://www.goolge.com")
If (Connect=TRUE)
raw = ReadFile("http://weather.yahooapis.com/forecastrss?p="&location&"&u="&units)
Sleep(1000)
SleepMessage (2, "DATA READING....", "WEATHER UPDATE", 0)
cond = ""
code = ""
ccond = ""
ccode = ""
temp = ""
lotemp = ""
hitemp = ""
day = ""
location=""
ForEach line in split(raw,"^LF^",1)
If(Find(line,"<yweather:location"))
CallFunction("getValue", location, line,"location city")
EndIf
#<yweather:condition text="Mostly Cloudy" code="28" temp="39" date="Fri, 21 Dec 2007 7:53 am PST" />
if (Find(line,"<yweather:condition"))
CallFunction("getValue", ccond, line, "text")
CallFunction("getValue", ccode, line, "code")
CallFunction("getValue", temp, line, "temp")
EndIf
#<yweather:forecast day="Fri" date="21 Dec 2007"low="34" high="55" text="Mostly Sunny" code="34" />
if (Find(line,"<yweather:forecast"))
CallFunction("getValue", cond, line, "text")
CallFunction("getValue", hitemp, line, "high")
CallFunction("getValue", lotemp, line, "low")
CallFunction("getValue", day, line, "day")
EndIf
EndForEach
weather="W|"&ccode&"|"&hitemp&"|"&lotemp&""
Tweather= day&" H: "&hitemp&" L: "&lotemp&" "&cond
RegWriteString("HKCU", "\Software\A_C\S2U2\", "UserWeather", weather)
RegWriteString("HKCU", "\Software\Manila\Weather\", "CurrentCond", ccond)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Temp", temp)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Status", ccode)
RegWriteString("HKCU", "\Software\Manila\Weather\", "Location", location)
RegWriteString("HKCU", "\Software\Manila\Weather\", "TCond", Tweather)
SleepMessage (2, "DONE", "WEATHER UPDATE", 0)
Else
Message ("NO CONNECTION", "WEATHER UPDATE")
EndIf
# subroutine to pull value out of XML
Sub getValue
offset = Find(argv[1],argv[2]) + Length(argv[2])+2
endoff = find(argv[1], """", offset)
return(SubStr(argv[1], offset, endoff-offset))
EndSub