FlickrFeed

A simple Run BASIC widget for viewing images in a Flickr RSS 2.0 feed.

code ' Fetch Flickr feed ' --- ' Global type variables defaultfeed$ = "http://flickr.com/rss/feed" current = 1 rsslen = 0 rsscnt = 1

' Initial start screen [start] cls html " " input "Enter your Flickr RSS 2.0 feed: "; url$ html " "

' Fetches the provided RSS stream [fetch] if len(url$) = 0 then url$ = defaultfeed$ else url$ = url$

result$ = httpget$(url$)

if len(result$) > 0 then goto [parse] else goto [fail]

[parse] xmlparser #rss, result$

rsslen = #channel elementCount
 * 1) channel = #rss #element(1)

dim pics$(rsslen) dim urls$(rsslen)

' Loads everything into the two arrays for x = 1 to rsslen

#item = #channel #element(x)

if (#item key$ = "item") then

#link = #item #element(2) urls$(rsscnt) = #link value$

#mc = #item #element(8) pics$(rsscnt) = #mc attribValue$("url")

rsscnt = rsscnt + 1

end if next x

' Displays one picture at a time [display] cls html " " print current Call ShowPic urls$(current) pics$(current) link #b, "Previous", [back] print " "; link #f, "Forward", [forward] print "" html " " link #a, "Show All", [show all] html " " html " " wait

' Shows all the pictures in the feed [show all] cls html " " for piccy = 1 to rsscnt - 1 Call ShowPic urls$(piccy) pics$(piccy) next piccy html " " link #d, "Just Show One", [display] html " " html " " wait

' Forward by one picture [forward] if current = rsscnt then current = 1 else current = current + 1 goto [display]

' Back by one picture [back] if current = 1 then current = rsscnt -1 else current = current - 1 goto [display]

' In the event the URL call fails [fail] cls html " " link #fail, "Try again", [fetch] html " " wait

' Generates the HTML for each picture Sub ShowPic Furl$ Fpic$ html " " html "" html "" html " " End Sub code