Microsoft Small Basic

Program Listing: CZH557-1
'################'
'Flickr in a Grid (v1.1)
'Basic Challenge 3
'Sep/2012
'by GoToLoop
'################'

'CZH557-0

'http://social.msdn.microsoft.com/Forums/en-US/smallbasic
'/thread/88d814da-7691-4103-9785-6886f5cb9105

'________________________________________________________________________________________'
GraphicsWindow.Left = 0
GraphicsWindow.Height = 0
GraphicsWindow.Width = 1400
GraphicsWindow.Height = 900

InitVars()

GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.KeyDown = KeyPressed
'________________________________________________________________________________________'
Loop:

GetPics()

noKey = "True"

While noKey
Program.Delay(200)
EndWhile

Goto Loop
'________________________________________________________________________________________'
Sub InitVars

tags[1] = "1=VideoGames;2=Programming;" ' <--- row #1
tags[2] = "1=Computers;2=MMORPG;" ' <--- row #2

tagsCols = Array.GetItemCount(tags[1])
tagsRows = Array.GetItemCount(tags)

gw = GraphicsWindow.Width
gh = GraphicsWindow.Height

gwGrid = gw / tagsCols
ghGrid = gh / tagsRows

elements = tagsCols * tagsRows

msg = "Loading Flickr Image: ("

EndSub
'________________________________________________________________________________________'
Sub GetPics

For tRow=1 To tagsRows
For tCol=1 To tagsCols

tag = tags[tRow][tCol]
pos = tagsCols*(tRow-1) + tCol

GraphicsWindow.Title = msg + pos + "/" + elements + ") [" + tag + "] ..."

img = Flickr.GetRandomPicture(tag)

GraphicsWindow.DrawResizedImage(img gwGrid*(tCol-1),ghGrid*(tRow-1) gwGrid,ghGrid)

Sound.PlayChime()

EndFor
EndFor

GraphicsWindow.Title = "Flickr in a Grid"

EndSub
'________________________________________________________________________________________'
Sub KeyPressed

noKey = "False"
Sound.PlayClick()

If GraphicsWindow.LastKey = "Escape" Then
Program.End()
EndIf

EndSub
'________________________________________________________________________________________'