# Variables • ### Question

• I'm trying to make the game of 15, I'm creating the squares but I don't know how to assign the name square1, square2 etc to the rectangle i created.
This is the code:

gw = 170
gh = 170
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
sqx=5
sqy=125
For i = 1 To 15
If sqx = 165 Then
sqx = 5
sqy = sqy - 40
EndIf

obj = Text.Append(square,i)
GraphicsWindow.MoveShape(obj,sqx,sqy)
sqx = sqx + 40
EndFor

thanks
Saturday, January 10, 2009 6:18 PM

• You can use Arrays to keep track of your squares.

name = "square" + i
Array.SetValue(name, obj)

Later, when you want to refer to your square, you can get them back like this:

obj = Array.GetValue("square12")
GraphicsWindow.MoveShape(obj, 200, 200)

Hope that helps.
• Marked as answer by Sunday, January 11, 2009 11:44 AM
Saturday, January 10, 2009 7:37 PM

### All replies

• gw = 170 gh = 170 GraphicsWindow.Width = gw GraphicsWindow.Height = gh sqx=5 sqy=5 For i = 1 To 15 If sqx = 165 Then sqx = 5 sqysqy = sqy + 40 EndIf GraphicsWindow.BrushColor = "Black" GraphicsWindow.DrawRectangle(sqx,sqy,40,40) GraphicsWindow.BrushColor = "Cyan" GraphicsWindow.FillRectangle(sqx+1,sqy+1,38,38) GraphicsWindow.BrushColor = "Red" name = Text.Append(square,i) GraphicsWindow.DrawText(sqx+10,sqy+12,name) sqxsqx = sqx + 40 EndFor
Saturday, January 10, 2009 7:25 PM
• You can use Arrays to keep track of your squares.

name = "square" + i
• 