C**********************************************************************
C	PROGRAM PSFILE
C**********************************************************************
C    Display HARPO graphics output on the screen and write a
C    PostScript file, PSFILE.PS.
C                                  Robert S. Lawrence    June 1, 1990
C                                  (303) 442-7534
C    LINE BUFFER:
	CHARACTER*80 L
C    TEXT TO DISPLAY:
	CHARACTER*80 TEXT
        character*2 size
C    FILE NAME:
	CHARACTER*12 FNAME
C
	INTEGER*2 IFLAG, IER
	INTEGER*2 IROW, ICOL
	INTEGER*2 IX, IY
	INTEGER*2 NROW, NCOL, MAXX, MAXY
C
	WRITE(6,*) 'PSFILE -- Plots a HARPO plot file.'
	WRITE(6,*) '          and makes PostScript file "PSFILE.PS".'
        write (6,*)' Use ENTER only to select the default values [..]'
	WRITE(6,112)
  112	FORMAT(1X,'PostScript image scale factor [1.60]: ',$)
	READ(*,'(g9.3)') SF
        if (sf.eq.0)sf=1.6
	WRITE(6,113)
  113	FORMAT(1X,'PostScript image line width [0.2]: ',$)
	READ(*,'(g9.3)') SWL
        if (swl.eq.0)swl=.2
	WRITE(6,114)
  114	FORMAT(1X,'Horizontal image translation in inches [.4]: ',$)
	READ(*,'(g9.3)') TRANSH
        if (transh.eq.0)transh=.4
	WRITE(6,116)
  116	FORMAT(1X,'Vertical image translation in inches [3.]: ',$)
	READ(*,'(g9.3)') TRANSV
        if (transv.eq.0)transv=3.
        write(6,117)
  117   format(1x,'Font size in points [8]: ',$)
        read(*,'(a)')size
        if(size.eq.'  ')size='8' 
        IFL0=0
C    GRAPH BOUNDARIES FROM THE INPUT PLOT FILE:
	XH=9785.
	XL=1655.
	YH=7515.
	YL=605.
C    OPEN THE INPUT HARPO PLOT FILE.
	WRITE(6,12)
  12	FORMAT(1X,'Input file name [TAPE5]: ',$)
	READ(6,121) FNAME
        if (fname.eq.'            ')fname='tape5'
  121	FORMAT(A12)
	OPEN(UNIT=1,FILE=FNAME,STATUS='OLD')
C    READ THE NEXT RECORD, EXPECTING A COMMAND.
  21	READ(1,211,END=9,ERR=21) L
  211	FORMAT(A80)
C    ..REJECT IT IF IT IS TOO LONG TO BE A COMMAND.
	IF(LENB(L).GT.2) GOTO 21
	READ(L,212,END=9,ERR=21) LC
  212	FORMAT(I2)
	IF(LC.EQ.-2) THEN
C    "-2" COMMAND (END OF FRAME)
	  GOTO 6
	ELSEIF(LC.EQ.0) THEN
C    "0" COMMAND (START A FRAME).
C    ..DISCARD THE NEXT RECORD.
	  READ(1,212,END=9,ERR=21) LC
C    ..REJECT THIS COMMAND IF IT HAS ALREADY BEEN EXECUTED.
	  IF(IFL0.EQ.1) GOTO 21
C    ..INITIATE GRAPHICS AND GET PIXEL COUNTS OF SCREEN.
	  IFLAG=3
	  CALL M_MODE(IFLAG,IER)
	    IF(IER.NE.0) GOTO 999
	  CALL M_INIT (MAXX,MAXY,NROW,NCOL, IER)
C    ..PREPARE NORMALIZATION FACTORS FOR INPUT COORDINATES.
C         Definitions:
C            IX is the x coordinate, in pixels, corresponding to X.
C            AX,BX are coefficients so that  IX = AX*X + BX
C            XH,XL are the high and low X's of the plot as described in
C                  the plot file.
C            FHX,FLX are the corresponding fractional screen positions.
C            NRTOP,NRBOT are the number of rows allowed for text at the
C                        top and bottom of the screen.
C	     NCL,NCR are the number of columns allowed for text at the
C                    left and right edges of the screen.
C
	  NRTOP=9
	  NRBOT=4
	  NCL=9
	  NCR=21
	  FHX=(FLOAT(NCOL-NCR)-0.5)/FLOAT(NCOL)
	  FLX=(FLOAT(NCL)-0.5)/FLOAT(NCOL)
	  FHY=(FLOAT(NROW-NRTOP)-0.2)/FLOAT(NROW)
	  FLY=(FLOAT(NRBOT)+0.2)/FLOAT(NROW)
	  AX=(FHX-FLX)*FLOAT(MAXX)/(XH-XL)
	  BX=(FLX*FLOAT(MAXX))-(XL*AX)
	  AY=(FHY-FLY)*FLOAT(MAXY)/(YH-YL)
	  BY=(FLY*FLOAT(MAXY))-(YL*AY)
C    OPEN THE OUTPUT POSTSCRIPT FILE.
	  OPEN(UNIT=2,FILE='PSFILE.PS',STATUS='UNKNOWN')
C    ..INITIALIZE THE SEGMENT COUNTER.
	  NSEG=0
C    ..WRITE THE POSTSCRIPT BOILER PLATE.
	  WRITE(2,*) '% PostScript program for HARPO.'
	  WRITE(2,*) '%'
	  WRITE(2,*) 'gsave'
	  WRITE(2,*) 'newpath'
	  WRITE(2,*) '% DEFINE "gs" AS GRAPH SCALING FUNCTION.'
	  WRITE(2,*) '%   Trying to copy "Sample Case 1" on p. 45 of'
	  WRITE(2,*) '%   the HARPO manual, we will produce a graph'
	  WRITE(2,*) '%   3.0 inches wide and 2.5 inches high.  We'
	  WRITE(2,*) '%   do no translation so this puts the left'
	  WRITE(2,*) '%   edge of the graph 0.61 inches from the'
	  WRITE(2,*) '%   left edge of the display area and the'
	  WRITE(2,*) '%   bottom of the graph 0.22 inches from the'
	  WRITE(2,*) '%   bottom of the display area.  Using these'
	  WRITE(2,*) '%   figures, there are 2730 graphical scale'
	  WRITE(2,*) '%   units per inch.'
	  WRITE(2,*) '/gs {72 2730 div mul} def'
	  WRITE(2,*) '% DEFINE "ts" AS TEXT SCALING FUNCTION.'
	  WRITE(2,*) '%   Text scaling units are 10 times larger'
	  WRITE(2,*) '%   than graphical units.  Again, no translation'
	  WRITE(2,*) '%   is performed.'
	  WRITE(2,*) '/ts {72 273 div mul} def'
	  WRITE(2,*) '/inch {72 mul} def'
	  WRITE(2,221) TRANSH,TRANSV
  221	  FORMAT(1X,F5.2,' inch',F5.2,' inch translate')
	  WRITE(2,222) SF,SF
  222	  FORMAT(1X,2F6.2,' scale')
	  WRITE(2,223) SWL
  223	  FORMAT(1X,F6.2,' setlinewidth')
C..............use the following line to get Times-Roman font.
C    	  WRITE(2,*) '/Times-Roman findfont '//size//' scalefont setfont'
         WRITE(2,*) '/Helvetica findfont '//size//' scalefont setfont'
C    SET FLAG SO THIS BLOCK WILL NOT BE REPEATED.
	  IFL0=1
	ELSEIF (LC.EQ.1) THEN
C    "1" COMMAND (MOVE, PEN UP).
C    ..READ COORDINATES.
	  READ(1,231,END=9,ERR=21) X,Y
  231	  FORMAT(1X,2F5.0)
C    ..NORMALIZE THEM TO THE SCREEN COORDINATES.
	  IX=AX*X+BX
	  IY=MAXY-(AY*Y+BY)
C    ..MOVE THE BEAM TO THE POINT.
	  CALL M_MOVE(IX,IY)
C    ..ADD THE MOVE TO THE POSTSCRIPT FILE.
	  WRITE(2,2315) INT(X+0.5),INT(Y+0.5)
 2315	  FORMAT(1X,2(I6,' gs'),' moveto')
	ELSEIF (LC.EQ.2) THEN
C    "2" COMMAND (DRAW A LINE SEGMENT).
C    ..EVERY HUNDREDTH LINE SEGMENT, "stroke" THE POSTSCRIPT FILE.
	  IF(NSEG.GE.100) THEN
	    WRITE(2,*) 'stroke'
	    WRITE(2,2315) INT(X+0.5),INT(Y+0.5)
	    NSEG=0
	  ENDIF
C    ..READ COORDINATES.
	  READ(1,231,END=9,ERR=21) X,Y
C    ..NORMALIZE THEM.
	  IX=AX*X+BX
	  IY=MAXY-(AY*Y+BY)
C    ..DRAW THE LINE SEGMENT.
	  CALL M_LINE (IX,IY)
C    ..ADD THE LINE TO THE POSTSCRIPT FILE.
	  WRITE(2,232) INT(X+0.5),INT(Y+0.5)
  232	  FORMAT(1X,2(I6,' gs'),' lineto')
	  NSEG=NSEG+1
	ELSEIF (LC.EQ.3) THEN
C    "3" COMMAND (DISPLAY TEXT)
C    ..READ COORDINATES.
	  READ(1,233,END=9,ERR=21) X,Y
  233	  FORMAT(2F4.0)
C    ..IF EITHER COORDINATE IS NEGATIVE, SKIP THIS TEXT.
	  IF((X.LT.0.).OR.(Y.LT.0.)) GOTO 21
C    ..READ ORIENTATION AND NUMBER OF CHARACTERS.
	  READ(1,234,END=9,ERR=21) IOR,NCHAR
  234	  FORMAT(I3,3X,I3)
C    ....LIMIT VERTICAL LABELS TO 30 CHARACTERS AND FIX POSITION.
	  IF((IOR.EQ.1).AND.(NCHAR.GT.10)) THEN
	    NCHAR=30
	    IROW=15
	    ICOL=1
	    GOTO 2342
	  ENDIF
C    ....SPECIAL CASE: "MODELS"
	  IF((X.EQ.1050.).AND.(Y.EQ.895.)) THEN
	    IROW=5
	    ICOL=64
	    GOTO 2342
	  ENDIF
C    ..NORMALIZE THE COORDINATES TO ROW AND COLUMN.
	  IF(NCHAR.LT.11) THEN
C    ....TEXT IS A TICK LABEL.
C    ......THE ROW AT THE TOP OF THE GRAPH IS (NRTOP+1).
C    ......THE ROW AT THE BOTTOM OF GRAPH IS (NROW-NRBOT).
	    IROW=INT(FLOAT(NRTOP+1)+(YH-10.*Y)/(YH-YL)
     2               *FLOAT((NROW-NRBOT)-(NRTOP+1)))
C    ......LIMITING ROW AT BOTTOM IS (NROW-NRBOT+1).
	    LIMROW=NROW-NRBOT+1
C    ......ADJUST ADJACENT BOTTOM LABELS TO THAT ROW.
	    IF(IABS(LIMROW-IROW).LE.2) IROW=LIMROW
C    ......SPECIAL ROW ASSIGNMENTS:
	    IF(Y.EQ.11.) IROW=25
	    IF(Y.EQ.43.) IROW=24
	    IF(Y.EQ.45.) IROW=23
	    IF(Y.EQ.80.) IROW=22
C    ......THE COLUMN AT THE LEFT EDGE OF THE GRAPH IS (NCL+1).
C    ......THE COLUMN AT THE RIGHT EDGE OF THE GRAPH IS (NROW-NCR-1).
	    ICOL=INT(FLOAT(NCL+1)+(10.*X-XL)/(XH-XL)
     2               *FLOAT((80-NCR)-NCL))
	  ELSE
C    ....TEXT IS PARAMETER INFORMATION.
	    IROW=1+INT(FLOAT(1023-Y)/850.*FLOAT(NROW)+0.5)
	    IF(IROW.LT.1) IROW=1
C    ......SPECIAL ROW ASSIGNMENTS:
	    IF(Y.EQ.11.) IROW=25
	    IF(Y.EQ.43.) IROW=24
	    IF(Y.EQ.45.) IROW=23
	    IF(Y.EQ.80.) IROW=22
	    ICOL=INT(FLOAT(NCOL)-FLOAT(1300-X)/1300.*FLOAT(NCOL))
	    IF(ICOL.LT.1) ICOL=1
	  ENDIF
C    ..READ THE TEXT.
C    ....INITIALIZE THE TEXT BUFFER.
 2342	  DO 2343 I=1,80
	    TEXT(I:I)=' '
 2343	  CONTINUE
	  READ(1,235,END=9,ERR=21) (TEXT(I:I),I=1,NCHAR)
  235	  FORMAT(80A1)
	  LTEX=LENB(TEXT)
C    ..DISPLAY THE TEXT.
	  CALL M_TEXT(IROW,ICOL,TEXT(1:LTEX))
C    ..WRITE THE TEXT TO THE POSTSCRIPT FILE.
	  IF(IOR.NE.1) THEN
	    WRITE(2,2361) INT(X),INT(Y)
 2361	    FORMAT(1X,2(I6,' ts'),' moveto')
	    WRITE(2,2362) TEXT(1:LTEX)
 2362	    FORMAT(1X,'(',A,')'/' show')
	  ELSE
	    WRITE(2,2363) INT(X),INT(Y)
 2363	    FORMAT(1X,'gsave',2(I6,' ts'),' translate')
	    WRITE(2,*) '0 0 moveto 90 rotate'
	    WRITE(2,2362) TEXT(1:LTEX)
	    WRITE(2,*) 'grestore'
	  ENDIF
	ELSEIF (LC.EQ.37) THEN
C    "37" COMMAND (SET LINES TO DASHED)
	  WRITE(2,*) ' stroke'
	  WRITE(2,*) '[4] 0 setdash'
	ELSEIF (LC.EQ.38) THEN
C    "38" COMMAND (SET LINES TO SOLID)
	  WRITE(2,*) ' stroke'
	  WRITE(2,*) '[] 0 setdash'
	ENDIF
C    ..SAVE THE COMMAND.
	LCP=LC
C    ..RETURN FOR THE NEXT SEGMENT.
	GOTO 21
C    END OF FRAME.
  6	IFLAG=2
	CALL M_MODE(IFLAG,IER)
	IFLAG=0
	CALL M_MODE(IFLAG,IER)
	WRITE(2,*) 'stroke'
	WRITE(2,*) 'showpage'
	WRITE(2,221) TRANSH,TRANSV
	WRITE(2,222) SF,SF
	WRITE(2,223) SWL
C    ..SEE IF THERE IS ANOTHER FRAME IN THE FILE.
	GOTO 21
C    END OF FILE.
  9	IFLAG=1
	CALL M_MODE (IFLAG,IER)
	CLOSE(UNIT=1)
	WRITE(2,*) 'grestore'
	CLOSE(UNIT=2)
	WRITE(6,*) 'PostScript file is "PSFILE.PS".'
	WRITE(6,*) 'Use program PRUNE to shorten it if desired.'
	GOTO 7			! Normal exit
 999	CONTINUE	
	WRITE(6,*)' Video board not supported '	
   7	CONTINUE
	END


C**********************************************************************
	FUNCTION LENB(S)
C**********************************************************************
C    LENGTH, EXCLUDING TRAILING BLANKS, OF A CHARACTER ENTITY.
C                                                     RSL    6/23/86
C    INPUT:
C        S     A CHARACTER ENTITY.
C    OUTPUT:
C        LENB  THE LENGTH OF S, EXCLUDING TRAILING BLANKS.
C
	CHARACTER*(*) S
	LENB=LEN(S)
	DO 22 I=LENB,1,-1
	  IF(S(I:I).NE.' ') GOTO 4
  22	CONTINUE
	LENB=0
	GOTO 9
  4	LENB=I
  9	RETURN
	END


C**********************************************************************
C	SUBROUTINE M_MODE (IFLAG, IER)
C**********************************************************************
C					ADL 1/15/90
C	MICROSOFT FORTRAN 5.O GRAPHICS.
C	This subroutine sets up graphics mode and returns 
C	screen to text default mode.
C	
C    The following values of FLAG are defined:				
C    	FLAG = 0	        Clear screen			   	
C            = 1 		Sets screen to default mode.
C	     = 2		Waits for RETURN from keyboard		
C	     = 3		Sets videomode to graphics.		
C            = anything else    Convert it to character and write it    
C
$NOTSTRICT         ! uses structures which are non-standard conforming
$NOTRUNCATE        ! required for some names to be significant

      INTERFACE TO SUBROUTINE
     1             clearscreen[FAR,C,ALIAS:"__clearscreen"] (area)
      INTEGER*2 area
      END
C........................................................................

      INTERFACE TO FUNCTION setvideomode (mode)
      INTEGER*2 setvideomode[FAR,C,ALIAS:"__setvideomode"],mode
      END 


C**********************************************************************
	SUBROUTINE M_MODE (IFLAG, IER)
C**********************************************************************
* arguments to setvideomode()
      INTEGER*2, $DEFAULTMODE, $MRESNOCOLOR, $HERCMONO, $ERESCOLOR
      PARAMETER($DEFAULTMODE  =-1)    ! restore screen to original mode
      PARAMETER($MRESNOCOLOR   =5)    ! 320 x 200, 4 grey
      PARAMETER($HERCMONO      =8)    ! 720 x 348, BW for HGC
      PARAMETER($ERESCOLOR     =16)   ! 640 x 350, 4 or 16 color 

      INTEGER*2 setvideomode[EXTERN]

	INTEGER*2 DUMMY, IFLAG, IER 
	INTEGER*2 VERR
	CHARACTER*1 CH
C  IF IFLAG = 0, CLEAR SCREEN AND RETURN.
	IF (IFLAG.EQ.0) THEN
	  CALL clearscreen ($GCLEARSCREEN)
	  GOTO 999
	ENDIF
C  IF IFLAG = 1, SET VIDEO MODE BACK TO TEXT MODE.
	IF (IFLAG.EQ.1) THEN
	  DUMMY = setvideomode ($DEFAULTMODE)
	  GOTO 999
	ENDIF
C  IF IFLAG = 2, Wait for response from keyboard.
	IF(IFLAG.EQ.2)THEN 
	  READ(*,*)
	  GOTO 999
	ENDIF
C  IF IFLAG = 3, SET VIDEOMODE TO APPROPRIATE MODE.
	IF (IFLAG.EQ.3) THEN
	    verr = setvideomode ($ERESCOLOR)	!EGA COLOR	    
	      IF(verr .NE. 0 )  GOTO 999
            verr = setvideomode($HERCMONO)      !HERCULES      
	      IF(verr .NE. 0 )  GOTO 999
            verr = setvideomode($MRESNOCOLOR)   !CGA, NO COLOR 
	      IF(verr .EQ. 0) THEN
	          IFLAG = 1
		  DUMMY = setvideomode($DEFAULTMODE)
		  WRITE(6,*)' In M_MODE: Unsupported Graphics Board '
	          IER = -1
		  GOTO 999
	      ENDIF
            GOTO 999
	 ELSE
	   CH = CHAR(IFLAG)
C	   WRITE(6,*) CH
	 ENDIF
 999	CONTINUE
	RETURN
	END


C**********************************************************************
C	SUBROUTINE M_INIT (NX, NY, NROW, NCOL, IER )
C**********************************************************************
C       Initialization subroutine to be called from a FORTRAN program.
C	Microsoft FORTRAN graphics software base.
C							ADL 1/15/90
C       This routine sets up window of the plotting area 		  
C	of the screen and number of text rows and columns.
C	 input:								  
C		none							  
C	 output:							  
C		NX = Number of pixels in x-direction on the screen.
C		NY = Number of pixels in y-direction on the screen.
C		NROW = Number of character rows on the screen.	          
C		NCOL = Number of character columns on the screen.	  
C	        IER  = Error flag.
C		     = 0  No error.
C		     < 0  Could not find correct video mode.
C									  
C
$NOTSTRICT         ! uses structures which are non-standard conforming
$NOTRUNCATE        ! required for some names to be significant

      INTERFACE TO SUBROUTINE
     1             getvideoconfig[FAR,C,ALIAS:"__getvideoconfig"] (s)
      STRUCTURE/videoconfig/
        INTEGER*2 numxpixels       ! number of pixels on X axis
        INTEGER*2 numypixels       ! number of pixels on Y axis
        INTEGER*2 numtextcols      ! number of text columns available
        INTEGER*2 numtextrows      ! number of text rows available
        INTEGER*2 numcolors        ! number of actual colors
        INTEGER*2 bitsperpixel     ! number of bits per pixel
        INTEGER*2 numvideopages    ! number of available video pages
        INTEGER*2 mode             ! current video mode
        INTEGER*2 adapter          ! active display adapter
        INTEGER*2 monitor          ! active display monitor
        INTEGER*2 memory           ! adapter video memory in K bytes
      END STRUCTURE
      RECORD/videoconfig/s[FAR,REFERENCE]
      END


C**********************************************************************
	SUBROUTINE M_INIT (NX, NY, NROW, NCOL, IER )
C**********************************************************************
* structure for getvideoconfig() as visible to user
      STRUCTURE/videoconfig/
        INTEGER*2 numxpixels       ! number of pixels on X axis
        INTEGER*2 numypixels       ! number of pixels on Y axis
        INTEGER*2 numtextcols      ! number of text columns available
        INTEGER*2 numtextrows      ! number of text rows available
        INTEGER*2 numcolors        ! number of actual colors
        INTEGER*2 bitsperpixel     ! number of bits per pixel
        INTEGER*2 numvideopages    ! number of available video pages
        INTEGER*2 mode             ! current video mode
        INTEGER*2 adapter          ! active display adapter
        INTEGER*2 monitor          ! active display monitor
        INTEGER*2 memory           ! adapter video memory in K bytes
      END STRUCTURE
C
* external function declarations
C
      EXTERNAL getvideoconfig
      EXTERNAL M_MODE
C
C
      RECORD/videoconfig/ vc
C.........................................................................
	INTEGER*2 MAXX, MAXY       ! Number of pixels on the screen.
	INTEGER*2 NTXCL, NTXRW     ! Number of characters on the screen.
	INTEGER*2 NROW, NCOL, NX, NY
	INTEGER*2 IFLAG, IER
	IFLAG = 3
C  DETERMINE VIDEO MODE.
	CALL M_MODE (IFLAG, IER)
	IF (IER.NE.0)GOTO 999
        CALL getvideoconfig( vc )
C
            MAXX  = vc.numxpixels    ! Number of pixels on x-axis.
            MAXY  = vc.numypixels    ! Number of pixels on y-axis.
	    NTXCL = vc.numtextcols   ! Number of text columns available.
	    NTXRW = vc.numtextrows   ! Number of text rows available. 
C
	NX = MAXX
	NY = MAXY
	NROW = NTXRW
	NCOL = NTXCL	
	goto 7
 999	CONTINUE
C  ERROR EXIT, IER NOT EQUAL TO ZERO.
	RETURN
C  NORMAL EXIT
  7	CONTINUE
	RETURN
	END


C**********************************************************************
C	SUBROUTINE M_MOVE (IX, IY)
C**********************************************************************
C	Microsoft FORTRAN graphics software base.
C       Move to given point x,y.  Called from FORTRAN program.
C							ADL 1/15/90
C	 input:								  
C		IX = pixel position on x axis.
C		IY = pixel position on y axis.				
C	 output:							  
C               none.						
C-----------------------------------------------------------------------
	
$NOTSTRICT         ! uses structures which are non-standard conforming
$NOTRUNCATE        ! required for some names to be significant

      INTERFACE TO SUBROUTINE
     1             moveto[FAR,C,ALIAS:"__f_moveto"](x,y,s)
      INTEGER*2 x,y
      STRUCTURE/xycoord/
        INTEGER*2 xcoord
        INTEGER*2 ycoord
      END STRUCTURE
      RECORD/xycoord/s[FAR,REFERENCE]
      END
C


C**********************************************************************
	SUBROUTINE M_MOVE (IX, IY)
C**********************************************************************
C				ADL 1/15/90
C
      STRUCTURE/xycoord/
        INTEGER*2 xcoord
        INTEGER*2 ycoord
      END STRUCTURE
      RECORD/xycoord/XY

      EXTERNAL moveto

	INTEGER*2 IX, IY
C
	CALL  moveto(IX, IY, XY)
	RETURN
	END


C**********************************************************************
C	SUBROUTINE M_LINE  ( npx,npy )	       
C**********************************************************************
C	ADL						1/15/90	
C	Using MICROSOFT FORTRAN 5.0 GRAPHICS ROUTINES:
C	   This subroutine draws a line from the last point to               
C	   the location of pixel npx,npy.                                 
C									  
C	   INPUT: 						          
C		  npx = x position of pixel.				  
C	          npy = y position of pixel.			          
C	   OUTPUT: 						          
C	          line drawn on screen.					  
C									  
$NOTSTRICT         ! uses structures which are non-standard conforming
$NOTRUNCATE        ! required for some names to be significant

      INTERFACE TO FUNCTION lineto (x,y)
      INTEGER*2 lineto[FAR,C,ALIAS:"__lineto"],x,y
      END


C**********************************************************************
	SUBROUTINE M_LINE (npx, npy)
C**********************************************************************
        INTEGER*2 lineto[EXTERN]

	INTEGER*2 dummy, npx, npy

	dummy = lineto (npx, npy)
	RETURN
	END


C**********************************************************************
C	SUBROUTINE M_TEXT (NROW, NCOL, TEXT)
C**********************************************************************
C		                                     ADL 1/15/90
C	MICROSOFT FORTRAN 5.0 GRAPHICS BASED ROUTINE
C	  Outputs a character string 'text'.
C	INPUT:
C	     NROW	Row position to start output string.
C	     NCOL	Column position to start output string.
C	OUTPUT:
C	     TEXT	Ouput character string to the screen.
C
$NOTRUNCATE		! Required since some routines have long names.
$NOTSTRICT              ! Required for some structures.
C
C REQUIRED INTERFACES TO GRAPHICS LIBRARY.
      INTERFACE TO SUBROUTINE
     1 settextposition[FAR,C,ALIAS:"__f_settextposition"](row,col,s)
      INTEGER*2 row,col
      STRUCTURE/rccoord/
        INTEGER*2 row
        INTEGER*2 col
      END STRUCTURE
      RECORD/rccoord/s[FAR,REFERENCE]
      END
C
      INTERFACE TO SUBROUTINE
     1     gettextposition[FAR,C,ALIAS:"__f_gettextposition"](s)
      STRUCTURE/rccoord/
        INTEGER*2 row
        INTEGER*2 col
      END STRUCTURE
      RECORD/rccoord/s[FAR,REFERENCE]
      END
C
      INTERFACE TO SUBROUTINE
     1             outtext[FAR,C,ALIAS:"__f_outtext"](text)
      CHARACTER*(*) text[FAR,REFERENCE]
      END


C**********************************************************************
	SUBROUTINE M_TEXT(NROW,NCOL,text)
C**********************************************************************
* structure for text position
      STRUCTURE/rccoord/
        INTEGER*2 row
        INTEGER*2 col
      END STRUCTURE
C
* external function declarations
C
      EXTERNAL outtext
      EXTERNAL settextposition
      EXTERNAL gettextposition
C
C----------------------------------------------------------------------
	RECORD / rccoord / curpos
	INTEGER*2 NROW, NCOL 
	CHARACTER*(*) text
C----------------------------------------------------------------------------	
	 CALL settextposition (NROW, NCOL, curpos)
	 CALL outtext (text)
C	
	RETURN
	END
