Here's another way of doing it using a timer that is set at random timer.intervals.
GraphicsWindow.height=600
GraphicsWindow.width=1000
MyShape=Shapes.AddRectangle(100,100)
Timer.Tick=OnTimerTick
Timer.Interval=1000
Tick="False"
Shapes.Move(MyShape,800,400)
While "True"
If Tick = "True" and Shapes.GetLeft(MyShape)=800 then
Shapes.Move(MyShape,700,400)
Tick="False"
ElseIf Tick="True" and Shapes.GetLeft(MyShape)=700 then
Shapes.Move(MyShape,800,400)
Tick="False"
EndIf
Timer.Interval= Math.GetRandomNumber(1000)
Program.Delay(50)
EndWhile
Sub OnTimerTick
Tick="True"
EndSub
JR