$STORAGE: 2
	SUBROUTINE GVSCAN(LINE,IBGN,LEND,LSTCHR,ID1,ID2,IVALID)
C COPYRIGHT (C) 1983 GLENN EVERHART
C ALL RIGHTS RESERVED
C VARSCN - SCAN COMMAND LINE FOR VARIABLE NAMES.
C DUMMY GRAPHICS VERSION
C (NO FUNNY ADDRESS MODES ETC.; FOR USE ON SAVED SHEETS.)
C
C	SCANS FOR VARIABLE NAMES OF FORM AAANNN WHERE AAA = LETTERS
C BETWEEN A AND Z UP TO NON-ALPHA, CORRESPONDING TO ROW, FOLLOWED BY
C NUMBERS IN THE 0-9 RANGE MAKING A DECIMAL COLUMN NUMBER.
C   THIS VERSION IS FOR USE WITH A GRAPHICS PROGRAM AND WILL NOT DECODE
C   FORMS OF TYPE P## OR D## AS WILL THE ONE IN PORTACALC. ALSO IT WILL
C   NOT MAKE CHECKS ON LIMITS OF VARIABLES SAVE FOR VERY CRUDE CHECKS OF
C   REASONABLENESS.
C
C THE LETTERS ARE FORMED BY
C A-Z ALONE GIVE ROW 1-26, COL 1. % IS ROW 27,COL1
C A1-Z1 GIVE ROW 1-26, COL 2
C AA1-ZZ1 ARE ROW 27-52, COL 2
	IMPLICIT INTEGER*2 (A-Z)
	INTEGER*2 RRW,RCL,CUP,NEL,RRCL
C	PARAMETER RRW=1000
C	PARAMETER RCL=1000
C RRCL IS USED AS A GUARD TO ENSURE AGAINST OVERFLOWS. VAX COMPLAINS OF
C INTEGER OVERFLOWS (PAIN).
C	PARAMETER RRCL=1100
C	PARAMETER CUP=1,NEL=14
C NOTE COL 1 IS DUMMY. DISPLAY THE SHEET SIDEWAYS SO WE GET USUAL VISUAL
C ROWS, COLS., AND ACCUMULATORS A-Z,% JUST APPEAR AS A FICTITIOUS ROW 0
C ON DISPLAY, INSTEAD OF REAL COLUMN 1 HERE.
	DIMENSION LINE(LEND)
	CHARACTER*1 LINE
C
	INTEGER*2 RSM,CSM,AFG,ASM,VCF,CH
	DATA RRW/1000/,RCL/1000/,RRCL/1200/,CUP/1/,NEL/14/
C ZERO OUR VARIABLES
	LPFG=0
C ! FLAG WE GOT A LOGICAL/PHYSICAL # FORM AND TYPE
	AFG=0
C ! FLAG WE SAW AN ALPHA
	ASM=0
C ! SUM OF ALPHAS HASHCODED (ACCUMULATOR)
	NSM=0
C ! ACCUMULATOR FOR NUMERICS
	NFG=0
C ! FLAG WE SAW A NUMERIC
	RSM=0
C ! AC FOR ROWS IN # FORMS
	CSM=0
C ! AC FOR COLS IN # FORMS
	ISPC=0
C ! COUNTER FOR NONSPACES SEEN (USED TO STOP ON TRAILING SPACES)
	IF(LINE(IBGN).NE.'%')GOTO 2000
	ID1=27
	ID2=1
	IVALID=1
	LSTCHR=IBGN+1
C SPECIAL CASE FOR % = AC #27
	RETURN
2000	CONTINUE
	DO 1 N=IBGN,LEND
	VCF=0
	LSTCHR=N
	CH=ICHAR(LINE(N))
C IGNORE SPACES AND TABS IF LEADING
	IF(CH.GT.32)ISPC=ISPC+1
	IF(CH.GT.0.AND.CH.LE.32.AND.ISPC.EQ.0)GOTO 1
C GET CHARACTER VALUE IN.
C MUST BE UPPERCASE.
	IF(.NOT.(CH.GE.65.AND.CH.LE.91)) GOTO 100
C CH IS AN ALPHA, RANGE A-Z
	VCF=1
C ! VALID CHAR SEEN
	AFG=1
C !SAW THE ALPHA
	IF(ASM.LT.RRCL)ASM=(CH-64)+26*ASM
	IF(CH.EQ.80)LPFG=1
C ! FLAG WE GOT PHYS. FORM MAYBE
	IF(CH.EQ.68)LPFG=2
C ! FLAG WE GOT DISPLAY FORM MAYBE
100	CONTINUE
C NEXT TEST NUMERICS
	IF(.NOT.(CH.GE.48.AND.CH.LE.57))GOTO 101
C CH IS A NUMERIC, RANGE 0-9
	VCF=1
C ! VALID CHAR SEEN
	NFG=1
C ! FLAG WE SAW NUMERIC
	IF(AFG.EQ.0)GOTO 103
102	CONTINUE
	IF(NSM.LT.RRCL)NSM=(CH-48)+10*NSM
C ! CONVERT CHARS TO BINARY AS SEEN
101	CONTINUE
	IF(VCF.EQ.0)GOTO 2
C !END ON ANY INVALID CHARACTER
1	CONTINUE
	GOTO 2
103	CONTINUE
C INVALID ... NUMERIC AND NO PRIOR ALPHA. FLAG BAD NAME AND EXIT.
	IVALID=0
	RETURN
2	CONTINUE
	IF(AFG.EQ.0)GOTO 103
	ID1=ASM
C HERE WE MAKE ID2 JUST NSM, NOT 1+NSM.
	ID2=NSM
C FLAG PURE ALPHAS NOT VALID FOR PLOTTING HERE. (THEY AREN'T SAVED ANYHOW)
	IF(NSM.LE.0)GOTO 103
	IF(ID1.GT.RRW.OR.ID1.LE.0)GOTO 103
	IF(ID2.GT.RCL.OR.ID2.LE.0)GOTO 103
	IVALID=1
C ALL IS WELL
	RETURN
	END

