       FUNCTION NXTSYM
C
      IMPLICIT LOGICAL*1 (B)
      DOUBLE PRECISION SYMBOL
      COMMON/PARAMS/LUNIN,LUNOUT,LUNCMD,BTAB,BSPC,NLINE,NSTMT,
     1ICLASS,BCHR,BLST,JSYM(2),NSYMTP,IPARNS,NPAGE
      COMMON /INBUFR/INSIZ,INCNT,IOUTX,MCRSIZ,INFIL,IOUTFL,
     1BDPB(2),BUFR(80),BNAM(24),BTIME(8),BDATE(9),BX(1)
      COMMON NSYM,NELM,KLIM,SYMBOL(1000),FLSYMB
C
      EXTERNAL NXTCHR
      EXTERNAL ITSTCH
      EXTERNAL IPACK
	DATA B100/"100/,B22/"22/
      DATA FLSYMB/'+-*/'/
    1 IC=1  !INIT GENERAL COUNTER
      NXTSYM=0  !INIT TYPE TO NONE
      JSYM(1)=0
      JSYM(2)=0  !CLEAR SYM/LABEL FLAG
   10 IF(BCHR.EQ.0) GO TO 99  !LEAVE IF END OF STATEMENT
      IF(BCHR.EQ.39) GO TO 60  !START OF QUOTED HOLORITH CONSTANT
      IF(BCHR.EQ.33)IOUTX=INSIZ  !MAKE BUFFER LOOK EMPTY
      IF(BCHR.EQ.40) IPARNS=IPARNS+1
      IF(BCHR.NE.41) GOTO  12
	IPARNS=IPARNS-1
	IF(IPARNS.EQ.0) GOTO 56
12	IF(ITSTCH(BCHR)-2) 20,40,15
   15 BCHR=NXNCHR(IOUTX)	!GET NXT NON-SPACE CHAR
      GO TO 10
C     TRY TO PACK RAD 50 STYLE
   20 IF (BLST.EQ.46) GO TO 65  !DOTED KEY-WORD
C      ICON=0	;THIS DOESN'T WORK, HARD TO TEL OCTAL CONSTANT FROM
C		;VARIABLE OF FORM O123 WHICH IS LEGAL FORTRAN VAR
C		;FOR NOW DON'T IGNORE OCTAL CONSTANTS
C      IF(BCHR.EQ.79) ICON=-2
   22 DO 30 J=1,3
      ITMP=0
      ICHAR=(ITSTCH(BCHR)-2)
      IF(ICHAR) 24,26,28
   24 ITMP=BCHR-B100		!ALPHA
C      ICON=ICON+1
      GO TO 27
   26 ITMP=BCHR-B22		!NUMERIC
   27 BCHR=NXTCHR(IOUTX)
   28 JSYM(IC)=IPACK(JSYM(IC),ITMP)	!PACK RAD 50 STYLE
   30 CONTINUE
      IC=IC+1
      IF(ICHAR.GT.0)GOTO 31
      IF(IC.EQ.2) GO TO 22
C31    IF(ICON.LT.0) GO TO 1  !IGNOR OCTAL CONSTANT
   31 NXTSYM=1  !FLAG SYMBOL DECODED
C***  NOW SKIP TO NEXT SPECIAL CHARACTER
32    IF(ITSTCH(BCHR).GT.3)GOTO99
	BCHR=NXTCHR(IOUTX)
	GOTO 32
C***  NUMERIC - CHECK I LABEL, CONSTANT, OF H WIDTH SPEC
   39 IC=IC+1
   40 JSYM(2)=(JSYM(2)*10)+(BCHR-48)
   41 BCHR=NXNCHR(IOUTX)
      GO TO (55,39,41,44,56),ITSTCH(BCHR)
C+
C***  COME HERE WHEN ENCOUNTED A SPECIAL CHARACTER IN
C     A NUMERIC SCAN
C   * IF ITS NOT A DOT(.), THE SCAN IS OVER, HOWEVER
C     IF ITS OF THE SET (#-*/) WE'VE FOUND A CONSTANT,
C     AND IT'S IGNORED.
C   * IF ITS A DOT, IF COULD BE:
C     I.NE.100.OR.J...
C     100.*
C     100.E-2
C     100.1E-2
C-
   44 IF(BCHR.NE.46) GO TO 50
   45 BCHR=NXNCHR(IOUTX)  !FOUND A DOT - WHATS NEXT
      IF(ITSTCH(BCHR).NE.1) GO TO 48!
C
C***  ALPHA AFTER DOT-CHECK FOR EXPONENT
C
      IF(BCHR.EQ.69) GO TO 46
      IF(BCHR.NE.68) GO TO 65  !MUST BE DOTTED KEYWORD
C
C	WE HAVE ENCOUNTERED A CONSTANT WITH 'E' OR 'D' EXPONENT
C	SKIP THE NEXT CHAR, SINCE IT MIGHT BE A '-', THEN SCAN FOR
C	THE NEXT SPECIAL CHARACTER
C
   46 BCHR=NXNCHR(IOUTX)	!SKIP THE FIRST CHAR IN EXPONENT
   47 BCHR=NXNCHR(IOUTX)
48    IF(ITSTCH(BCHR).LT.4) GO TO 47
      GO TO 1
   50 IF (LOFSET(BCHR,FLSYMB).EQ..TRUE.) GO TO 1
      GO TO 56  !FOUND SOMETHING THAT MAY BE LABEL
C
C***  NUMERIC SCAN HAS TERMINATED ON AN ALPHA
C
   55 IF(BCHR.EQ.69.OR.BCHR.EQ.68) GO TO 46
      IF(BCHR.EQ.72.OR.BCHR.EQ.82) GO TO 58
56	IF(IC.GT.5)GOTO 1	!IGNOR LONG CONSTANTS
	NXTSYM=-1		!FLAG A LABEL FOUND
      GO TO 99
C
C     HOLLORITH OR RAD50 CONSTANT
C
   58 DO 59 I=1,JSYM(2)
      BCHR=NXTCHR(IOUTX)
   59 CONTINUE
      GO TO 15
C
C***  QUOTED HOLLORITH CONSTANT-IGNOR IT!
60	CONTINUE
      BCHR=NXTCHR(IOUTX)
	IF(BCHR .EQ. 0) GOTO 95
      IF(BCHR.EQ.39) GO TO 15
      GO TO 60
65	BCHR=NXTCHR(IOUTX)
	IF(BCHR.EQ.0)GOTO 95
	IF(BCHR.NE.46) GOTO 65
	BCHR=NXTCHR(IOUTX)
	BLST=32	!ERASE PRECEEDING DOT
	GOTO 1
C
   95 CALL ERROR(10)
	GOTO 1		!TRY TO RECOVER
   99 RETURN
      END
