locked
small basic problem RRS feed

  • Question

  • I got this program to work without a timer but with a timer i cant seem to get it right, can someone help me?

    the program is supposed to make a little waiting circle like a buffering circle (if that helps you...)

      

    GraphicsWindow.Width=350
    GraphicsWindow.Height=360
    GraphicsWindow.BrushColor=Graphicswindow.GetRandomColor()
    bol=0
    Timer.Interval = 500
    Timer.Tick = OnTick


    Sub OnTick
      bol=bol+1
        EndSub

    If bol = 1 Then
      circle1=Shapes.AddEllipse (50,50)
    Shapes.Move(circle1,150,20)
    Program.Delay(100)
    Shapes.HideShape(circle8)
    Program.Delay(100)
    EndIf

    If bol=2 Then
    circle2=Shapes.AddEllipse (50,50)
    Shapes.Move(circle2,220,50)
    Program.Delay(100)
    Shapes.HideShape(circle9)
    Program.Delay(100)
    EndIf

    If bol=3 Then
    circle3=Shapes.AddEllipse (50,50)
    Shapes.Move(circle3,260,100)
    Program.Delay(100)
    Shapes.HideShape(circle10)
    Program.Delay(100)
    EndIf

    If bol=4 Then
      circle4=Shapes.AddEllipse (50,50)
    Shapes.Move(circle4,280,160)
    Program.Delay(100)
    Shapes.HideShape(circle11)
    Program.Delay(100)
    endif

    If bol=5 Then
      circle5=Shapes.AddEllipse (50,50)
    Shapes.Move(circle5,270,220)
    Program.Delay(100)
    Shapes.HideShape(circle12)
    Program.Delay(100)
      endif

      If bol=6 Then
        circle6=Shapes.AddEllipse (50,50)
    Shapes.Move(circle6,220,270)
    Program.Delay(100)
    Shapes.HideShape(circle1)
    Program.Delay(100)
    endif


    If bol=7 then
    circle7=Shapes.AddEllipse (50,50)
    Shapes.Move(circle7,150,290)
    Program.Delay(100)
    Shapes.HideShape(circle2)
    Program.Delay(100)
    EndIf
    If bol=8 Then
    circle8=Shapes.AddEllipse (50,50)
    Shapes.Move(circle8,80,270)
    Program.Delay(100)
    Shapes.HideShape(circle3)
    Program.Delay(100)
    EndIf
    If bol=9 Then 
    circle9=Shapes.AddEllipse (50,50)
    Shapes.Move(circle9,30,220)
    Program.Delay(100)
    Shapes.HideShape(circle4)
    Program.Delay(100)
    EndIf
    If bol=10 Then
    circle10=Shapes.AddEllipse (50,50)
    Shapes.Move(circle10,20,160)
    Program.Delay(100)
    Shapes.HideShape(circle5)
    Program.Delay(100)
    EndIf
    If bol=11 Then
    circle11=Shapes.AddEllipse (50,50)
    Shapes.Move(circle11,30,100)
    Program.Delay(100)
    Shapes.HideShape(circle6)
    Program.Delay(100)
    EndIf
    If bol=12 Then
    circle12=Shapes.AddEllipse (50,50)
    Shapes.Move(circle12,80,50)
    Program.Delay(100)
    Shapes.HideShape(circle7)
    Program.Delay(100)
    endif

    Thank you in advance

    • Changed type litdev Thursday, May 14, 2015 5:25 PM
    Thursday, May 14, 2015 2:16 PM

Answers

  • put the while AFTER the sub!

    Jan [ WhTurner ] The Netherlands

    • Proposed as answer by litdev Thursday, May 14, 2015 5:25 PM
    • Marked as answer by Nonki Takahashi Sunday, May 31, 2015 1:37 PM
    Thursday, May 14, 2015 3:17 PM
    Answerer

All replies

  • When your program starts, bol=0 . None of the if is triggered, and the program ends.

    Put before If bol=1  a line with   While bol<13

    and at the end   Endwhile.


    Jan [ WhTurner ] The Netherlands

    Thursday, May 14, 2015 2:42 PM
    Answerer
  • you mean endwhile all the way at the end of the program? that doesn't work

    it then just says that endsub and endwhile are in the wrong places..

    and if i put endwhile before the sub, it starts but then does nothing

    Thursday, May 14, 2015 2:53 PM
  • I mean put the while before line 10  (just after the sub) and the endwhile as the last line of the program.

    Hint: It is better for the understanding of a program to put SUBs at the end after the Mainprogram.


    Jan [ WhTurner ] The Netherlands

    Thursday, May 14, 2015 2:57 PM
    Answerer
  • i've changed the previous program to look like this on the respective lines

    bol=0
    Timer.Interval = 500
    Timer.Tick = OnTick

    While bol<13
    Sub OnTick
      bol=bol+1
    EndSub

    and in the end i've added the endwhile, but is just says that it can't find the sub, (because it's inside the end/endwhile)


    Thursday, May 14, 2015 3:10 PM
  • put the while AFTER the sub!

    Jan [ WhTurner ] The Netherlands

    • Proposed as answer by litdev Thursday, May 14, 2015 5:25 PM
    • Marked as answer by Nonki Takahashi Sunday, May 31, 2015 1:37 PM
    Thursday, May 14, 2015 3:17 PM
    Answerer
  • oh... i'm retarded... that fixed it. thank you!

    Thursday, May 14, 2015 3:40 PM