1

I'm making a screensaver and I need to know what's wrong with my code.

GraphicsWindow.title="Screen Saver" 
GraphicsWindow.Width=500 
GraphicsWindow.Height=500

For i=1 To 
Colour = GraphicsWindow.GetRandomColor() 
GraphicsWindow.BrushColor=Colour
XCoord = Math.GetRandomNumber(1200) 
YCoord = Math.GetRandomNumber(1200)
width=math.GetRandomNumber (300)
GraphicsWindow.Fillellipse(XCoord,YCoord,width,width) 
Program.Delay(200) 

EndFor
ContinueForEver = "Yes" 
While ContinueForEver = "Yes"
EndWhile

I'm supposed to use for i=? to ? to make an infinite loop and I'm supposed to use While EndWhile for the continuation. So basically I'm supposed to make a screensaver which generates circles forever.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Yug
  • 13
  • 6

1 Answers1

2

Something like this?

GraphicsWindow.title="Screen Saver" 
GraphicsWindow.Width=500 
GraphicsWindow.Height=500

While 1 = 1 
  Colour = GraphicsWindow.GetRandomColor() 
  GraphicsWindow.BrushColor=Colour
  XCoord = Math.GetRandomNumber(1200) 
  YCoord = Math.GetRandomNumber(1200)
  width=math.GetRandomNumber (300)
  GraphicsWindow.Fillellipse(XCoord,YCoord,width,width) 
  Program.Delay(200) 
EndWhile

You were very close. But you can not have a For loop without an end number like this:

For i = 1 to

You need to have an end number:

For i = 1 to 10 '<-- the loop will run 10 times

A While statement will run as long as its input is true. So in this case, as long as 1 = 1 the loop will continue (Which is forever).

Does that help? :D

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Zock77
  • 951
  • 8
  • 26