Microsoft Small Basic

Program Listing: CZH557
'################'
'Flickr in a Grid
'Basic Challenge 3
'Sep/2012
'by GoToLoop
'################'

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

'________________________________________________________________________________________'
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.Width = 1280
GraphicsWindow.Height = 800
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height

InitVars()
GraphicsWindow.KeyDown = KeyPressed
'________________________________________________________________________________________'
Loop:

GetPics()
DisplayImgGrid()

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=Chips;" ' <--- row #2

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

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
pos = tagsCols*(tRow-1) + tCol
GraphicsWindow.Title = msg + pos + "/" + elements + ") ..."

imgs[tRow][tCol] = ImageList.LoadImage(Flickr.GetRandomPicture(tags[tRow][tCol]))

Sound.PlayChime()
EndFor
EndFor

GraphicsWindow.Title = "Flickr in a Grid"

EndSub
'________________________________________________________________________________________'
Sub DisplayImgGrid

For tRow=1 To tagsRows
For tCol=1 To tagsCols
GraphicsWindow.DrawResizedImage(imgs[tRow][tCol] gwGrid*(tCol-1),ghGrid*(tRow-1) gwGrid,ghGrid)
EndFor
EndFor

EndSub
'________________________________________________________________________________________'
Sub KeyPressed

noKey = "False"
Sound.PlayClick()

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

EndSub
'________________________________________________________________________________________'