Next: PWRITX
Up: Demonstration - the INDEMO Program
Previous: Demonstration - the INDEMO Program

## Fortran source

```      PROGRAM INDEMO

*+
*
*     - - - - - - -
*      I N D E M O
*     - - - - - - -
*
*   Demonstrate cursor input following NCAR AUTOGRAPH plot.
*
*   P T Wallace   Starlink   May 1987
*   P C T Rees    Starlink   April 1992
*      Added exit on cursor choice 0.
*
*+

IMPLICIT NONE

INTEGER I,N
LOGICAL LOOP
REAL V,T,X(1000),Y(1000),XU,YU,XG,YG,XA(1),YA(1)
CHARACTER S*13

REAL snx_AGUGX,snx_AGUGY

*  Fill the data arrays.
XU = 300.0
YU = 400.0

DO I=1,1000
V = REAL(I-1)
T = V/50.0
X(I) = XU + V*COS(T)/2.0
Y(I) = YU + V*SIN(T)/2.5
END DO

*  Open NCAR/SGS/GKS.
CALL snx_AGOP

*  X axis is reversed linear.
CALL AGSETI('X/ORDER.',1)

*  Y axis is logarithmic.
CALL AGSETI('Y/LOG.',1)

*  Plot the graph.
CALL snx_EZRXY(X,Y,1000,'Spiral','x','y')

*  Loop - mark positions on plot.
LOOP = .TRUE.

DO WHILE (LOOP)

*     Input a cursor position.
CALL snx_CURS(XU,YU,N)

*     Check cursor choice and finish if zero.
IF (N.LE.0) THEN

*        Finish.
LOOP=.FALSE.
ELSE

*        Transform to grid coordinates.
XG = snx_AGUGX(XU)
YG = snx_AGUGY(YU)

*        Inside or outside grid window?
IF (XG.LE.1.0.AND.XG.GE.0.0.AND.
:          YG.LE.1.0.AND.YG.GE.0.0) THEN

*           Inside - mark the selected position.
WRITE (S,'(''('',F5.1,'','',F5.1,'')'')') XU,YU
XA(1) = XU
YA(1) = YU
CALL POINTS(XA,YA,1,-2,0)
CALL snx_WRTST(XG+0.02,YG,S,0.02,0,-2)
ELSE

*           Outside - finished.
LOOP = .FALSE.
END IF
END IF

*  Next position
END DO

*  Wrap up
CALL sgs_CLOSE

END
```

Next: PWRITX
Up: Demonstration - the INDEMO Program
Previous: Demonstration - the INDEMO Program

SNX --- Starlink Extensions to the NCAR Graphics Utilities