
Animation is integral to many parts of GUIs, including both the fancy effects when things change used in window managers, and of course games.   The core of any animation system is a scheme for periodically changing the display while still remaining responsive to the user.   This task demonstrates this.



Task

Create a window containing the string "Hello World! " (the trailing space is significant).

Make the text appear to be rotating right by periodically removing one letter from the end of the string and attaching it to the front.

When the user clicks on the (windowed) text, it should reverse its direction.




CHARACTER string="Hello World! "
 
   WINDOW(WINdowhandle=wh, Height=1, X=1, TItle="left/right click to rotate left/right, Y-click-position sets milliseconds period")
   AXIS(WINdowhandle=wh, PoinT=20, X=2048, Y, Title='ms', MiN=0, MaX=400, MouSeY=msec, MouSeCall=Mouse_callback, MouSeButton=button_type)
   direction = 4
   msec = 100    ! initial milliseconds
   DO tic = 1, 1E20
      WRITE(WIN=wh, Align='Center Vertical') string
      IF(direction == 4) string = string(LEN(string)) // string ! rotate left
      IF(direction == 8) string = string(2:) // string(1)       ! rotate right
      WRITE(StatusBar, Name) tic, direction, msec
      SYSTEM(WAIT=msec)
   ENDDO
 END
 
SUBROUTINE Mouse_callback()
   direction = button_type ! 4 == left button up, 8 == right button up
 END 