PROGRAM JVIDEO!       Example video.f

! Code converted using TO_F90 by Alan Miller
! Date: 2001-03-15  Time: 16:04:07

USE JAPI

INTEGER :: i,breite,hoehe
INTEGER :: frame,menubar,FILE,quit,play,start,STOP
INTEGER :: canvas,obj
INTEGER,dimension(0:9) :: image
LOGICAL :: do_work
CHARACTER (LEN=256) :: filename

CALL j_setdebug(0)

IF( .NOT. j_start()) THEN
  PRINT*, "can't connect to JAPI server"
  GO TO 20
END IF

filename = "MojeVideo"
!--     Bilder Laden */
DO i=0,9      !17
  IF(i < 9) THEN
    WRITE(unit=filename,fmt="(a15,i1,a4)") "images/ms",i+1,".gif"
  ELSE
    WRITE(unit=filename,fmt="(a15,i2,a4)") "images/ms",i+1,".gif"
  END IF
  print*, "Loading ",filename
  image(i)  = j_loadimage(filename)
END DO

breite  = j_getwidth(image(0))
hoehe   = j_getheight(image(0))
frame   = j_frame("Video")

menubar = j_menubar(frame)
FILE    = j_menu(menubar,"File")
quit    = j_menuitem(FILE,"Quit")

play    = j_menu(menubar,"Video")
start   = j_menuitem(play,"Start")
STOP    = j_menuitem(play,"Stop")

canvas  = j_canvas(frame,breite,hoehe)
CALL j_setpos(canvas,10,60)

CALL j_show(frame)
CALL j_pack(frame)

i = 0
do_work = .false.
NEXTACTION: DO

IF((obj == quit) .OR. (obj == frame)) EXIT NEXTACTION

IF(do_work) THEN
  obj=j_getaction()
ELSE
  obj=j_nextaction()
END IF

IF(obj == start) do_work = .true.
IF(obj == STOP)  do_work = .false.

IF(do_work) THEN
  DO i=0,9          ! MOD not an F intrinsic 
  CALL j_drawimage(canvas,image(i),0,0)
  CALL j_sync()
  CALL j_sleep(50)
  end do             ! MOD not an F intrinsic
  !i = MOD((i+1),9)        ! 18)
END IF

END DO NEXTACTION

20      CONTINUE
CALL j_quit()

END PROGRAM JVIDEO
