Microsoft Small Basic
RSS

Navigation





Quick Search
»
Advanced Search »

PoweredBy

Variables

RSS
Modified on 2009/11/30 00:30 by 69.111.79.3 Categorized as Uncategorized
Sometimes you'll type the same thing over and over
Tortoise.SetPenColor("pink")
Tortoise.Move(5) 
Tortoise.SetPenColor("blue")
Tortoise.Move(7)
Tortoise.SetPenColor("pink")
Tortoise.Move(10)
Tortoise.SetPenColor("blue")
Tortoise.Move(13)
Tortoise.SetPenColor("pink")
Tortoise.Move(15)
Tortoise.SetPenColor("blue")
Tortoise.Move(17)
Tortoise.SetPenColor("pink")
 

It would be nice to not to have continually type "pink" or "blue". Variables allow you to only have to type a value one time.

FirstColor = "pink"
SecondColor = "blue"
Tortoise.SetPenColor(FirstColor)
Tortoise.Move(5) 
Tortoise.SetPenColor(SecondColor)
Tortoise.Move(7)
Tortoise.SetPenColor(FirstColor)
Tortoise.Move(10)
Tortoise.SetPenColor(SecondColor)
Tortoise.Move(13)
Tortoise.SetPenColor(FirstColor)
Tortoise.Move(15)
Tortoise.SetPenColor(SecondColor)
Tortoise.Move(17)
Tortoise.SetPenColor(FirstColor)

An added bonus is that now if you wanted to change the SecondColor to be "purple", you would only have to change it in one place.

FirstColor = "pink"
SecondColor = Colors.Purple

ScrewTurn Wiki version 3.0.5.600. Some of the icons created by FamFamFam.