Attached to a field, this behavior retrieves data from Yahoo"s finacial site to show you the current quote.
--#####################################
--## Stock Quote behavior ##
--## Written by Aviyam Fischer ##
--## aviyam@bigfoot.com ##
--#####################################
--
-- Usage: Create a text field and attach
-- this behavior to it.
--
property spriteNum
property theNetID
property theStock
property refreshTime
on beginSprite me
theURL="http://finance.yahoo.com/d/quotes.csv?s="&theStock&"&f=sl1d1t1c1ohgv&e=.csv"
set theNetID = getNetText(theURL)
startTimer
end
on exitFrame me
if netDone(theNetID) then
theQuote = netTextResult(theNetID)
member(sprite(me.spriteNum).member).text = theQuote.item[2]
else
doConnectionAnimation(me)
end if
if the timer>= refreshTime *60 then beginSprite(me)
end
on doConnectionAnimation me
if member(sprite(me.spriteNum).member).text = " * * " then
member(sprite(me.spriteNum).member).text = "* * *"
else
member(sprite(me.spriteNum).member).text = " * * "
end if
end
on getPropertyDescriptionList
vPDlist = [:]
setaProp vPDList, #theStock, [#comment: "The stock to quote:", #format: #string, ¬
#default: "AAPL"]
setaProp vPDList, #refreshTime, [#comment: "refresh time (ticks)", #format: #integer,¬
#range: [#min: 100, #max: 1000],#default: 600]
return vPDList
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA