	GLOBAL DEFINE
	  INCLUDE "Windows.inc"
	END
	
	PROGRAM XYPlot
C
C	30.10.2003 by Michael Knappertsbusch
C
C	Program to draw X,Y plots from external X,Y data to the screen.
C
	INTEGER I
	REAL X,Y
	CHARACTER*20 LIST,FILENAME
	PARAMETER(RHO=1)					! Radius of circles
C
	RECORD /Rect/rrect					! Define rectangle structure rrect
C
	rrect.top=0						! Size of rrect
	rrect.left=0
	rrect.bottom=600
	rrect.right=600
C
C
C
	WRITE(9,*) '********************************************'
	WRITE(9,*) '*                                          *'
	WRITE(9,*) '*  Program XYPlot, V.2 (Batch mode)        *'
	WRITE(9,*) '*                                          *'
	WRITE(9,*) '*  by Michael. Knappertsbusch, 30.10.2003  *'
	WRITE(9,*) '* Draws X,Y data to screen at intervals of *'
	WRITE(9,*) '*              5 outlines                  *'
	WRITE(9,*) '*                                          *'
	WRITE(9,*) '********************************************'
	WRITE(9,*) ' '
	WRITE(9,*) '. . .Enter filename with list of files'
	WRITE(9,*) 'that contain X,Y data. . .'
	WRITE(9,*) '         (max 20 chars long)'
	READ(9,5) LIST
 5	FORMAT(A20)
C
C
C	Main loop:
C
	CALL EraseRect(rrect)					! Clear screen
	OPEN(14,FILE=LIST,STATUS='OLD')
C
	I=0							! Initialize counter I
 10	K=0
 	I=I+1
 	READ(14,5,END=999) FILENAME				! Reading the filenames from the list
	OPEN(15,FILE=FILENAME,STATUS='OLD')
 20	K=K+1
 	IF ((MOD(I,5).EQ.0).AND.(K.EQ.1)) THEN			! Avoid plotting first point if MOD(I,5) is zero
	  GOTO 30
	END IF
 	READ(15,*,END=100) X,Y					! Reading X,Y coordinates from a file
	CALL DrawCircle(RHO,100+X/5,100+Y/5)			! Plot points (=circles of radius 1)
C
C	Draw intervals of 5 outlines and then pause:
C
 30	IF ((MOD(I,5).EQ.0).AND.(K.EQ.1)) THEN
	  PAUSE
	  CALL EraseRect(rrect)					! Erase previous 5 outlines from screen
	END IF
C
	GOTO 20
C
 100	CLOSE(15)
 	GOTO 10
 999	CLOSE(14)
 	PAUSE
C
	STOP
	END
	
	
	
	
	
	
	
	
	
	SUBROUTINE DrawCircle(Radius,Xm,Ym)
C
C	Draws a circle with radius Radius, and Center with coordinates
C	at Xm,Ym.
C
	RECORD /Rect/ r
	RECORD /WindowRecord/ front
	POINTER (p_front, front)
C	
	p_front=FrontWindow()
	CALL SetPort(VAL4(p_front))
C	
	r.top=Ym-Radius				! Defines a rectangle structure
	r.left=Xm-Radius
	r.bottom=Ym+Radius
	r.right=Xm+Radius
C
	CALL FrameOval(r)			! Draws the oval (or circle)
C	
	RETURN
	END