	SNA			/ SKIP IF: YES
	JMP	UPDRLB		/ JUST SET NEW POSITION
	MQL			/ HOLD POSITION ON LINE OF OLD RULER
				/  SETTING
	IAC			/ SET AC = NO_SETTING RULER_SETTING_TYPE
	JMS	PUTBYT		/ PUT THIS NO_SETTING CHARACTER IN RULER
	NWRUL
UPDRLB,	CDFMNU
	TAD	RLPOSN		/ STORE NEW RULER_SETTING_TYPE'S POSITION
	DCA I	T2
UPDRLA,	TAD	RLPOSN		/ SET NEW RULER SETTING IN RULER
	MQL			/ HOLD IT'S POSITION IN RULER
	TAD	RLTYP		/ GET TYPE OF SETTING
	JMS	PUTBYT		/ PUT IT IN NWRUL
	NWRUL
	JMP I	UPDRUL		/ RETURN
RLTYP,	.-.
/
/
/

CHKCHR,	XX			/ CHECK AC FOR SPECIAL CHARACTER
	JMS	ESJCHK		/ RETURN FROM THIS SUBROUTINE WITH
				/  AC = 0 IF CHARACTER WAS JUSTIFY_SPACE,
				/  WRAPPED_LINE, WRAPPED_LINE_WITH_HYPHEN,
				/  LINE_MODIFIED_FLAG, OR RULER_MODIFIED_FLAG.
				/  IF NOT THEN AC = CHARACTER - RULER_
				/  MODIFIED_FLAG
	SZA			/ SKIP IF: CHARACTER IS ONE OF THOSE LISTED
				/  ABOVE.
	TAD	(JCHKOF-ECSTRL)	/ CHARACTER = "START_OF_RULER"?
	SZA CLA			/ SKIP IF: SO
	ISZ	CHKCHR		/ BUMP RETURN. NONE OF SPECIAL CHARACTERS
				/  LISTED HERE!
	JMP I	CHKCHR		/ RETURN

ESJCHK,	XX			/ CHECK FOR LINE OR RULER MODIFIED FLAG
	JMS	ESJTST		/ RETURN FROM ESJTST WITH AC = 0 IF CHAR.
				/  WAS A JUSTIFY_SPACE, WRAPPED_LINE, OR
				/  WRAPPED_LINE_WITH_HYPHEN.  IF NOT THEN
				/  AC = CHARACTER - ECHYLN
	SZA			/ SKIP IF: CHARACTER DETECTED DURING
				/  ESJTST WAS A JUSTIFY_SPACE, WRAPPED_
				/  LINE, OR WRAPPED_LINE_WITH_HYPHEN
	TAD	(JTSTOF-ECMDFL)	/ CHARACTER = "LINE_MODIFIED_FLAG"?
	SZA			/ SKIP IF: SO
	TAD	(ECMDFL-ECRMFL)	/ SUBTRACT "RULER_MODIFIED_FLAG" CHAR.
	JMP I	ESJCHK
JCHKOF=	ECRMFL			/ AC OFFSET ON RETURN, IF NON-ZERO

ESJTST,	XX			/ CHECK FOR JUSTIFY_SPACE, WORD_WRAP OR
				/  WRAPPED_LINE_WITH_HYPHEN
	TAD	(-ECJSPC)	/ CHARACTER = "JUSTIFY_SPACE"?
	SZA			/ SKIP IF: SO
	TAD	(ECJSPC-ECWWLN)	/ CHARACTER = "WRAPPED_LINE"?
	SZA			/ SKIP IF: SO
	TAD	(ECWWLN-ECHYLN)	/ SUBTRACT "WRAPPED_LINE_WITH_HYPHEN" CHAR.
	JMP I	ESJTST		/ RETURN
JTSTOF=	ECHYLN

EIPWFL,	PUTESC			/ SET APPLICATION KEY-PAD MODE
	"=-200

	JMS	CLSSET		/ CLEAR SCROLL VALUES FOR STATUS DISPLAY

	JMP	EINEXT		/ AND WAIT FOR NEXT EDIT CMD


/ SINCE THE ACCENTED CHARACTER TABLES HAVE BEEN MOVED TO THE PRINTER
/ SEARCH HAS BEEN MODIFIED TO LOOK IN THE PRINTER

	IFDEF	FORIN	<
/ SEARCH FOR ENTRY IN TABLE1 OR TABLE2
SEARCH,	XX
	DCA	POINT1		/ SAVE TABLE ADDRESS
	CDFPRT			/ SET TO PRINTER FIELD
	ISZ	POINT1		/ BUMP POINTER
	TAD I	POINT1		/ GET CONTENTS
	ISZ	POINT1		/ BUMP AGAIN
	SNA			/ END OF TABLE?
	JMP	SRCHEX		/ YES, TAKE 1ST EXIT
	TAD	CHAR1		/ COMPARE AGAINST CHAR. DESIRED
	SZA CLA			/ SAME?
	JMP	SEARCH+3	/ NO
	ISZ	SEARCH		/ YES, TAKE 2ND EXIT
SRCHEX,	CDFMYF			/ CHANGE BACK TO THIS FIELD
	JMP I	SEARCH
			>	/ END IFDEF FORIN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.%400+DLOEDT	/ DISK BLOCK WHERE PAGE IS LOADED


PUTMSG,	XX			/ OUTPUT MESSAGE TO SCREEN
	TAD I	PUTMSG		/ GET ADDRESS OF MESSAGE TO OUTPUT
	ISZ	PUTMSG		/ INCREMENT RETURN ADDRESS
	CDILP			/ SET DATA AN INSTRUCTION FIELD TO LP FIELD
	JMS	PUTLP		/ CALL ROUTIN IN LIST PROCESSING FIELD
	JMP I	PUTMSG		/ RETURN TO CALLER

GETBYT,	XX			/ TAD INDEX - JMS GETBYT - SPTR
	CDFMYF			/ A219 RETURNS BYTE
	TAD	(-1)
	CLL RAR
	DCA	T1		/ A219
	TAD I	GETBYT		/ GET PTR
	JMS	NRTST		/ A219
	TAD	T1		/ A219
	DCA	T1
	TAD I	T1		/ GET WORD
	SNL
	BSW			/ GET BYTE
	AND	P77		/ ISOLATE IT
	ISZ	GETBYT
	CDFMYF			/ A219
	JMP I	GETBYT		/ AND RETURN

PUTBYT,	XX			/ TAD INDEX - MQL - TAD CHAR - JMS PUTBYT - SPTR
	CDFMYF			/ A219 SETS STRING(INDEX)=CHAR
	AND	P77		/ ISOLATE CHAR
	SWP
	TAD	(-1)
	CLL RAR
	DCA	T1		/ A219
	TAD I	PUTBYT		/ GET PTR
	JMS	NRTST		/ A219
	TAD	T1		/ A219
	DCA	T1
	TAD I	T1		/ GET WORD
	SNL
	BSW			/ GET BYTE
	AND	P7700		/ ISOLATE
	MQA			/ INSERT CHAR
	SNL
	BSW
	DCA I	T1		/ PUT IT BACK IN STRING
	ISZ	PUTBYT
	CDFMYF			/ A219
	JMP I	PUTBYT		/ RETURN

CPYBUF,	XX			/ JMS COPY - -CNT - CDFA - A-1 - CDF B - B-1
	CDFMYF
	TAD	CPYBUF
	CIFLP
	JMS I	(XFCOPY)	/ AND GO DO IT IN LP FIELD

DLTRLR,	XX			/ DELETE RULER
	CDFBUF
	DCA I	CURPTR
	ADVPTR
	JMP I	DLTRLR
	TAD	(-ECNDRL)
	SZA CLA
	JMP	.-5
	DCA I	CURPTR
	JMP I	DLTRLR

ADVRUL,	XX			/ ADVANCE RULER
	TAD	CURPTR
	DCA	ADVRL1		/ SAVE CURPTR
ADVRLA,	JMS	ESNWRL		/ COLLECT NEW RULER INFO
	TAD	ADVRL1
	DCA	CURPTR
	JMS	DLTRLR		/ DELETE RULER
	ADVPTR			/ ADVANCE TO NEXT CODE
	JMP	ADVRLB
	TAD	(-ECSTRL)
	SNA CLA
	JMP	ADVRLA		/ LOOP IF STILL IN RULERS
ADVRLB,	JMS	CMPRUL
	JMP	ADVRLC		/ COMPARE WITH OLD RULER
	JMS	INSRUL		/ INSERT IF NOT A NULL CHANGE
	JMS	COPRUL		/ AND MAKE IT THE NEW CURRENT RULER
	ISZ	ADVRUL		/ BUMP TO NON-NULL RETURN
	TAD	RGTMAR		/ WIDE RULER?
	TAD	(-COLM80)
	SMA CLA
	JMS	SETSPT		/ SET SPLIT SCREEN IF SO
ADVRLC,	DCA	RLRMOD		/ CLEAR RULER CHANGE FLAG
	JMS	SCRNMD		/ LET SCREEN REFRESH
	JMP I	ADVRUL		/ AND RETURN
ADVRL1,	.-.			/ TEMP

ESNWRL,	XX			/ SET NEW RULER
	ADVPTR
	JMP I	ESNWRL
	TAD	(-ECMDRL)
	SZA CLA
	JMP	.-4		/ GET TO MIDDLE
	JMS	SETRUL
	ESADRL			/ SET NWRUL
	CDFBUF			/ RESET FIELD
	JMP I	ESNWRL


ESADRL,	XX
	ADVPTR
	NOP
	CDFMYF
	JMP I	ESADRL


/ GLOBAL SEARCH FLAG CHECK ROUTINE
/ THIS ROUTINE IS BRANCHED TO FROM THE EDITORS INPUT CHAR WAIT LOOP
/ AT SYMBOL "EDICHR" TO SEE IF THE GLOBAL SEARCH FLAG (GSRF) IS SET
/ IF IT IS SET, WE CALL IN THE REPLACE OVERLAY TO CONTINUE THE OPERATION
/ THE SEARCH AND SELECT OVERLAY WILL COME HERE WHEN THE DESIRED TEXT
/ STRING IS FOUND IN THE DOCUMENT.  THIS ROUTINE WILL THEN CALL IN THE
/ REPLACE OVERLAY, WHICH THEN CALLS IN THE SEARCH AND SELECT OVERLAY TO
/ CONTINUE.  REACHING THE END OF THE DOCUMENT OR A GOLD+HALT WILL
/ TERMINATE THE PROCESS.

GSRCK,	XX
	TAD	GSRF		/ GET THE GLOBAL SEARCH AND REPLACE FLAG
	SNA CLA			/ IS IT SET?
	JMP I	GSRCK		/ NO, RETURN TO CALLER!

	OVLJMP;OVREPL		/ YES, CALL IN THE REPLACE OVERLAY


/++
/		RLEQTE	RULER_EQUATE
/
/ FUNTIONAL DESCRIPTION:	RLEQTE
/
/	COPY CURRENT RULER BUFFER (CURUL) TO NEW RULER BUFFER (NWRUL).
/
/  RLEQTE PSEUDO CODE:
/
/	BEGIN
/	|	CALL CPYBUF
/	|	RETURN
/	END
/
/ CALLING SEQUENCE:	JMS	RLEQTE
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	NONE
/ OUTPUT PARAMETERS:	NONE
/ IMPLICIT OUTPUT:	NONE
/ COMPLETION CODE:	NONE
/ SIDE EFFECTS:		NONE
/
/--

RLEQTE,	XX			/ RULER_EQUATE
	JMS	CPYBUF
		-RULSIZ		/ COUNT
		CDFMYF		/ FIELD TO COPY FROM
		CURUL-1		/ STARTING ADDRESS TO COPY FROM
		CDFMNU		/ FIELD TO COPY TOO
		NWRUL-1		/ STARTING ADDRESS TO COPY TOO
	JMP I	RLEQTE		/ RETURN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.%400+DLOEDT	/ DISK BLOCK WHERE PAGE IS LOADED


	IFDEF	PERDEC	<
/ OK STRING - ACCEPTABLE RULER CHARACTERS
OKSTR,	5556			/ dash, period
			>	/ END IFDEF PERDEC

	IFDEF	COLDEC	<
OKSTR,	5572			/ dash, colon
			>	/ END IFDEF COLDEC

	IFDEF	COMDEC	<
OKSTR,	5554			/ dash, comma
			>	/ END IFDEF COMDEC

/ The following stings comprise the table of acceptable 7 bit characters
/ for ruler definitions.  Where an 8 bit character is required, an entry
/ should be made here of an appropriate composable 7 bit character, such
/ as the ones shown on the key beside the 8 bit (eg. e-accute and # on the
/ Italian keyboard).  The six bit representation of the 8 bit character
/ should be put in the appropriate corresponding place in EIGHTC.

	IFDEF	ENGLSH	<
	7624			/ closing angle bracket, T
	TEXT	/LRDJWPCNHF/
			>	/ END IFDEF ENGLSH

	IFDEF	V30NOR	<
	7624			/ closing angle bracket, T
	TEXT	/VUDJIASNOF/
			>	/ END IFDEF V30NOR

	IFDEF	V30SWE	<
	7617			/ closing angle bracket, O
	TEXT	/VHYRISCZAX/
			>	/ END IFDEF V30SWE

	IFDEF	ITALIAN	<
	7624			/ closing angle bracket, T
	TEXT	/SDEGIPCNLM/
			>	/ END IFDEF ITALIAN

	IFDEF	SPANISH	<						/A255
	7624			/ closing angle bracket, T		/ "
	TEXT	/SNDAIPCLGM/						/ "
			>	/ END IFDEF SPANISH			/A255

	IFDEF	FRENCH	<
	7624			/ closing angle bracket, T
	TEXT "GDIJAPCHZF"
			>	/ END IFDEF FRENCH

	IFDEF	GERMAN	<
	7624			/ closing angle bracket, T
	TEXT	/LRDJWPCNHF/
			>	/ END IFDEF GERMAN

	IFDEF	DUTCH	<
	7624			/ closing angle bracket, T
	TEXT	/LRDUIACNKF/
			>	/ END IFDEF DUTCH

	IFDEF	CANADA	<
	7624			/ closing angle bracket, T
	TEXT  /LRDJWPCNHF/
			>	/ END IFDEF CANADA

	IFDEF	NORWAY	<
	7624			/ closing angle bracket, "T"
	TEXT "VHDJIASMOF"
			>	/ END IFDEF NORWAY

	IFDEF	SWEDSH	<
	7624			/ closing angle bracket, "T"
	TEXT "VHDJISCMAF"
			>	/ END IFDEF SWEDSH

	IFDEF	DANISH	<
	7624			/ closing angle bracket, "T"
	TEXT "VHDJIACMOF"
			>	/ END IFDEF DANISH
	*.-1

	IFDEF	ENGLSH	<
	  IFNDEF V30SWE <
	  IFNDEF V30FAO <
	  TEXT	/=0123456789)!"#$%^&*(/
	  >
	  >
	  IFDEF V30FAO <
	  TEXT  '+0123456789=!"#$%&/()'		/Keyboard layout for FAO/A250
	  >
	>	/ END IFDEF ENGLSH

	IFDEF V30NOR <
	TEXT  '+0123456789=!"#$%&/()'		/Keyboard layout for NORWAY/A254
	>

	IFDEF V30SWE <
	TEXT  '+0123456789=!"#$%&/()'		/Keyboard layout for SVEEDON
	>

	IFDEF SPANISH <							/A255
	TEXT  '+0123456789=!"#$%&/()'		/Keyboard layout for SPN/ "
	>								/A255

	IFDEF	ITALIAN <
	TEXT	/-0123456789]\#"'(_7^[/	/NOTE: several of these can not be
					/obtained on an italian keyboard
					/except by a compose sequence
					/as they correspond to MCS chars
					/See eightc table for corresponding
			>		/allowable MCS chars

	IFDEF	FRENCH	<
	TEXT	:=0123456789#&["'(]?!\:
			>	/ END IFDEF FRENCH

	IFDEF	GERMAN	<
	TEXT	:+0123456789=!"#$%&/():
			>	/ END IFDEF GERMAN

	IFDEF	DUTCH	<
	TEXT	:=0123456789"]\#$%!&():
			>	/ END IFDEF DUTCH

	IFDEF	CANADA	<
	TEXT	:=0123456789)!"/$%?&*(:
			>	/ END IFDEF CANADA

	IFDEF	SCANDI	<
	TEXT	:+0123456789=!"#$%&/():
			>	/ END IFDEF SCANDI


TBSTR,	003;201;002;002;101;0;0	/ EACH BYTE IN THIS TABLE CORRESPONDS
				/  TO A RULER SETTING (SEE COMMENTS AT
				/  NWRUL).  EACH BYTE HERE TELLS US THE
				/  CLASS OF RULER SETTING.
XLSTR,	7;0;102;102;304;501;601	/ EACH BYTE IN THIS TABLE CORRESPONDS
				/  TO A RULER SETTING. (SEE COMMENTS AT
				/  NWRUL).  EACH BYTE TELLS US THE
				/  OFFSET FROM LOCATION RLSTOR-1 TO
				/  STORE THE POSITION OF THE RULER
				/  SETTING UNDER CONSIDERATION.
XLMAR,	002;400;003;100		/ TYPE OF LEFT MARGIN
PTRBLK,	ZBLOCK	NPTRS		/ SCREEN PTRS

EIGES4,	-63			/ MAX LENGTH OF SEARCH PHRASE
	ZBLOCK 63		/ 50 CHAR SEARCH BUFF

/ NWRUL IS LAODED WITH CURRENT RULER (CURUL BUFFER) PREVIOUS TO MODIFICATION
/  (GOLD-RULER). IT'S FORMAT IS AS FOLLOWS: EACH WORD IS DIVIDED INTO
/    2 BYTES, EACH BYTE CONTAINING THE RULER SETTING FOR IT'S
/     CORRESPONDING POSITION IN THE RULER. PLEASE NOTE THAT WPS USES
/	OTHER CHARACTERS TO REPRESENT THE VARIOUS SETTINGS THAT MAY APPEAR
/      IN A RULER.  THEY ARE NOT THE SAME CHARACTERS THAT APPEAR IN THE
/       RULER ON THE SCREEN.
/
/		TYPE	 CLASS				RULER SYMBOL
/ CHAR.	VALUE  IN NWRUL (TBSTR)	 MEANING		SHOWN ON SCREEN
/ -----	-----  -------  -------	 -------		---------------
/ SPACE	41	1	   0	NO SETTING			_
/   A	42	2	   3	DECIMAL TAB STOP		.
/   B	43	3	   2	RIGHT-JUST. TAB STOP	"RIGHT ANGLE BRACKET"
/   C	44	4	   1	NORMAL (LEFT-JUST.) TAB		T
/   D	45	5	   0	LEFT MARGIN, SINGLE SPACED	L
/   E	46	6	   2	RIGHT MARGIN, RAGGED		R
/   F	47	7	   0	LEFT MARGIN, DOUBLE SPACED	D
/   G	50	10	   2	RIGHT MARGIN, JUSTIFIED		J
/   H	51	11	   1	WORD WRAPPED INDENT		W
/   I	52	12	   1	PARAGRAPH INDENT		P
/   J	53	13	   0	CENTERING POINT			C
/   K	54	14	   0	LEFT MARGIN, SPACE-AND-A-HALF	N
/   L	55	15	   0	HYPHENATION ZONE		H
/   M	56	16	   0	LEFT MARGIN, HALF-SPACE		F
/
/ CURUL - CURRENT_RULER
/  CURUL HOLDS THE SETTINGS OF THE CURRENT RULER WE ARE EDITING UNDER.
/   CURUL IS THE SAME FORMAT AS NWRUL DESCRIBED ABOVE.

RULSIZ=	NWRLND-NWRUL
CURUL,	ZBLOCK	RULSIZ

GSRPRV,	0			/ PREVIOUS GLOBAL SEARCH FLAG
WIDPRV,	0			/ PREVIOUS WIDE SCREEN FLAG
NOMOVE,	0			/ FLAG FOR SEARCH MODE OPERATIONS
RPRLHN,	0			/ Rapid Paging Ruler Header block Number


/ RULER DISPLAY TEXT LITERALS
RLSTR2,	TEXT	/....:....:/
RLSTR4,	TEXT	/       /
EIPRSC,	OVLJMP;OVPRSC		/ PREV SCREEN

	X=.
/--------------------
	PAGE


NRTST,	0			/ Test if value is address of new ruler buffer
	TAD	(-NWRUL)	/ If it is, set field to menu buffer swap area
	SNA
	CDFMNU
	TAD	(NWRUL)
	CML			/ Restore link to original value
	JMP I	NRTST		/ return to caller


EIBKUP,	IAC
EIADVN,	DCA	MOVMOD+1	/ SET MODE FLAG (FORWARD/BACKWARD)
SIMCHR,	MODSET
	MOVMOD			/ PUT MODE
	JMP	EICHAR		/ SIMULATE CHAR BUTTON
MOVMOD,	SCHMOD!SLTMOD
	.-.

EILOWR,	TAD	(40)		/ CASE LOWER
EIUPPR,				/ CASE UPPER
	DCA	CASBIT		/ SET UP/LOW SWITCH
	IAC
EIUUDL,	IAC			/ REMOVE UNDERLINE
EIUBLD,	IAC			/ REMOVE BOLD
EIUNDL,	IAC			/ UNDERLINE
EIBOLD,				/ BOLD
	TAD	(BLDMOD)
	DCA	MOVMOD+1	/ SAVE FUNCTION TYPE
	TSTSLT
	JMP	SIMCHR		/ SIMULATE CHAR BUTTON IF NOT IN SELECT MODE
				/ ELSE RETURN HERE WITH
				/ CURRENT CHAR = START OF SELECT
	MODSET
	MOVMOD
	JMP	SLXMOD

ESLCT1,	TAD	(ECTMRK)	/ INSERT POSITION MARKER
	JMS	INSERT
DOSLCT,	TAD	(ECSLPT)	/ INSERT SELECT BREAK CHAR
	JMS	INSERT
	JMS	SVSLCR		/ SAVE CURSOR POSITION			/A209
	MODSET
	ESLMOD			/ SET SELECT MODE
	JMS	SCRNMD
	AC0001
	DCA	ECHFLG
	AC0001			/ GOLD S&R BUG FIX
	TAD	SCRLCT		/ ARE WE ON A NEW LINE ie NEG SCRL CNT
	SPA CLA			/ SKIP IF NO. EVERYTHING IS STILL COOL
	JMS	REJUST		/ IF YES WE MUST REJUSTIFY
	JMS	SCRLUP
	JMS	SCRNMD
	JMS	LINDNT
	JMP	GOTMRK

/	GDCASE	A SUBROUTINE TO PERFORM CASE STYLE CHECKING
/
/	CALL:
/
/	ZZCASE	(HAS A PAGE ZERO LINK)
/	TABLE-1	(ADDRESS OF THE TABLE TO COMPARE AGAINST)
/	(ON NO MATCH RETURNS HERE)
/
/	AC ==>	(VALUE TO COMPARE AGAINST)
/
/	THE COMPARE TABLE HAS THE FORMAT OF:
/
/	VALUE;ADDRESS		/ VALUE 1 AND ADDRESS TO JUMP TO ON MATCH
/	VALUE;ADDRESS		/ VALUE 2 AND ADDRESS TO JUMP TO ON MATCH
/	...			/ ETC.
/	0			/ TABLE TERMINATOR
/
/	NOTE: THIS SUBROUTINE DESTROYS THE CONTENTS OF AUTO INDEX
/	REGISTERS 6 AND 7
/
	CASTMP=IX0		/ AUTO INDEX REGISTER 6
	X7=IX1			/ AUTO INDEX REGISTER 7

GDCASE,	XX			/ ENTRY TO CASE SUBROUTINE
	DCA	CASTMP		/ SAVE AC FOR COMPARES
	RDF			/ SAVE DATA FIELD
	TAD 	CDF0		/ ADD TO CDF TO FIELD 0
	DCA	CASE02		/ AND PUT FOR RETURN
	CDFMYF			/ SET TO MYFIELD
	TAD I	GDCASE		/ GET THE TABLE ADDRESS
	DCA	X7		/ SAVE IN AUTO INDEX REGISTER
/
/	THIS IS THE CHECK LOOP FOR CASE MATCHING
/

CASE01,	TAD I X7		/ GET VALUE
	SNA			/ TERMINATOR?
	JMP	CASEXI		/ YES TAKE DEFAULT RETURN
	CIA			/ NEGATE THE OPERAND
	TAD 	CASTMP		/ COMPARE
	SNA CLA			/ MATCHED?
	JMP	CASMAT		/ YES! GO TO MATCH EXIT
	ISZ	X7		/ SKIP JUMP VECTOR
	JMP	CASE01		/ TRY THE NEXT VALUE
/
/	END OF LOOP
/
CASMAT,	TAD I	X7		/ GET RETURN ADDRESS
	DCA	GDCASE		/ STORE FOR RETURN
	SKP			/ DON'T INCREMENT
CASEXI,	ISZ	GDCASE		/ SKIP TABLE VECTOR
CASE02,	CDFMYF			/ RESET DATA FIELD
	JMP I	GDCASE		/ AND GO HOME

HDRGET,	XX			/ JMS HDRGET - HDROFST
	CDFMYF
	AC7776
	TAD I	HDRGET
	ISZ	HDRGET
	CIFFIO
	FILEIO
	XHDRGT
	JMP I	HDRGET

EICONT,	OVLJMP;OVCONT		/ ENTRY POINT FOR CONT SEARCH & SLCT
EIVIEW,	OVLJMP;OVVIEW		/ GOLD VIEW
EIGPGE,	OVLJMP;OVGPGE
EITIME,	OVLJMP;OVTIME
EIGETC,	OVLJMP;OVGETC
EIDCMT,	OVLJMP;OVDCMT		/ GOLD GET_DOC
EIMENU,	OVLJMP;OVMENU		/ ENTRY POINT FOR EDITOR MENU
EIHYP2,	OVLJMP;OVHYP2
	IFDEF CONDOR	<
EITX,	OVLJMP;OVTC		/ TECHNICAL CHARACTER OVERLAY	/A211
EICLKY,	OVLJMP;OVCLKY		/ COLUMN CUT				/A205
			>	/ END IFDEF CONDOR

	IFDEF	LFTRGT  <
EILARO,	OVLJMP;OVLARO		/ LEFT ARROW
EIRARO,	OVLJMP;OVRARO		/ RIGHT ARROW
			>	/ END IFDEF LFTRGT

RPPRRL,	0			/ Rapid Paging PRevious Ruler block ID#	/M201
RPPG0,	0			/ Minus = gone over TOP-DOC		/M201

RPBIN1,	0			/ BINARY UNITS,TENS,HUNDREDS

/ PATCH TO PUTSCH FOR HORIZ SCROLLING
CHARPT=	.
/ PUTPAT MERGED INTO PUTSCH

/ ROUTINES TO GO IN AND OUT OF 132-COLUMN DISPLAY MODE

/ This routine puts terminal in 80 column mode
/ AC UNIMPORTANT ON ENTRY
/ DATA FIELD NOT IMPORTANT ON ENTRY BUT SET TO THIS FIELD ON EXIT

CLR132,	XX
	AC0004			/ PUT AN OFFSET IN AC SO SET132
	JMS	SET132		/ WILL ACTUALLY CLEAR 132 COLUMN MODE
	JMP I	CLR132		/ RETURN

/ This routine puts terminal in 132 column mode if ac=0 or 80
/ column mode if ac= "l-"h (4)
/ DATA FIELD NOT IMPORTANT ON ENTRY BUT SET TO THIS FIELD ON EXIT

/ Modified for manual screen width choice to check the force wide/narrow /M223
/ flag (WIDNAR). SET132 is called with AC=0 to set wide, or with AC=4	 /M223
/ from CLR132 to set narrow. By adding the WIDNAR flag (0=wide, 64=nar.) /M223
/ we get four possible values of AC: 0, 4, 64, or 70. 0 means wide, so	 /M223
/ we call LP132 with 0 AC. AC=70 was a call from CLR132 to go narrow, 	 /M223
/ and WIDNAR=64 says we're forced narrow, so call LP132 with AC=4 to 	 /M223
/ go to 80 column mode. AC=64 was a call to SET132, but WIDNAR says	 /M223
/ we're forced narrow, so call LP132 with AC=4 to stay in 80 column.	 /M223
/ AC=4 is a call from CLR132 to go narrow, which we allow even though	 /M223
/ WIDNAR says force wide. This is for cases like GOLD:TOP which goes	 /M223
/ to narrow mode for messages, or GOLD:MENU for the editor menu. The	 /M223
/ basic rule is to stay in narrow mode ALWAYS, unless SET132 is called	 /M223
/ and the force wide (WIDNAR=0) flag is set.				 /M223

SET132,	XX
	CDFMYF								/A223
	TAD	WIDNAR		/ GET WIDE/NARROW FLAG			/A223
	SZA								/A223
	 AC0004			/ NARROW, OR CLR132 CALL: FORCE 80 COL.	/A223
	CDILP			/ REAL ROUTINE IN IN LP FIELD WHERE
	JMS I	(LP132)		/ THERE'S MORE ROOM
	JMP I	SET132		/ RETURN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

/	*7000			/ OVERLAY AREA 2 LOCATION

	IFNZRO .-7000 <?ERROR MUST BE AT 7000>

OV2NUM=	0			/ INITIALIZE OVERLAY TWO COUNTER
OVLAY2,	OV2NUM			/ STORE OVERLAY NUMBER AS FIRST LOCATION

/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************

CDISPL=	CDIMTH			/ DEFINE CHANGE FIELD INSTRUCTION TO SPELL
NLINES=	11			/ NUMBER OF LINES WITHIN SCROLLING REGION

INITSP,	XX			/ Entry point of initialization code.
	RDF			/ Get return field.
	TAD	CIDF0		/  ...
	DCA	INITXT		/ save return CIF CDF instruction.
	CDFEDT			/ Map current (editor) field.
	TAD	(NLINES)	/ Set edit screen size to 9 lines.
	DCA	SCRNLN		/  ...
	TAD	(NLINES)	/ Set wide screen size too.
	DCA	WIDSIZ		/  ...
	TAD	(SINZRO-1)	/ Get start of editor stuff to zap.
	DCA	X0		/  ...
	TAD	(-NINZRO)	/ Get size of initialization area.
	JMS	ZAP		/ Initial the area to zero.
	DCA	BUFBEG		/ Initialize editor buffer pointers.
	TAD	(BUFEND) 	/ ++++
	DCA	BUFSIZ		/  ....
/
/	INITIALIZE EDIT BUFFER
/	***
/
	AC7777 			/ SET POINTER TO BUFFER_BEGIN - 1
	DCA	X0
	CDFBUF
	TAD	(ECBFBG) 	/ GET BUFFER BEGIN CODE
	DCA I	X0 		/ INSTALL AT TOP OF BUFFER
	TAD	(ECSTX) 	/ GET START OF TEXT CODE
	DCA I	X0 		/ INSTALL IN NEXT BUFFER LOCATION
	TAD	(ECETX) 	/ GET END OF TEXT CODE
	DCA I	X0 		/ INSTALL IN NEXT BUFFER LOCATION
	TAD	X0 		/ SET CURPTR TO POINT AT ETX CHAR. THAT
				/  WAS JUST INSTALLED
	DCA	CURPTR		/  ...
/
/ CLEAR THE REST OF THE BUFFER
/
	TAD	(4-BUFEND)	/ Compute negative counter of # of words to clear.
	JMS	ZAP		/ Zero out the rest of the buffer.

	TAD	(ECBFND) 	/ INSTALL BUFFER_END CHARACTER
	DCA I	X0


/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************


/ INITIALIZE EDIT PTRBLK (POINTER_BLOCK) TABLE
/
	CDFEDT
	TAD	(PTRBLK-1) 	/ ++++
	DCA	X0
	TAD	(-NPTRS+1) 	/ ++++
	JMS	ZAP		/ Zero area out.
	TAD	CURPTR		/ Set last loc in PTRBLK = CURPTR.
	DCA I	X0
/
	TAD	CURPTR		/ Initialize LINE 23 pointer.
	DCA	LINE23		/  ...
	DCA	CURSOR		/ Init cursor posn.
	DCA	LOWLIM		/  and screen bais.

	TAD	(-12)		/TO TEST FOR POSTPROCESSOR		/A214
	CDFMNU			/ Get file # from menu field.
	TAD I	(MUBUF+MNTMP6)	/SET TO 12 FOR FOOTNOTING		/A214
	SNA CLA			/SKIP TO CONTINUE WITH SPELL		/A214
	JMP	PPOPEN		/OPEN FOOTNOTING FILES RETURN AT PPORET	/A214
	TAD I	(MUBUF+MNUTFN)	/ Pick up UTILITY file number to open	/M230
	CDFEDT			/ Back to our field.
	MQL			/ WPFILS wants file # in MQ.
	CIFFIO;FILEIO;XDSKIN	/ Open input file.
/d229	SPA;NOP;CLA		/  ...
	SZA CLA			/ Skip if file was opened		/A229
	 AC7777			/  ERROR - file could not be opened	/A229

PPORET,	IAC			/ AC=1 if open ok, =0 if failed		/A229
	DCA	OPNFIL		/ Save file open flag			/A229
	TAD	OPNFIL		/ See if file(s) opened ok		/A229
	SNA CLA			/ Skip if open sucessful		/A229
	 JMP	INITXT		/  else just return			/A229
	CDFSYS			/ Save start time.			/M229
	TAD I	(CLOCK+3)	/  (minutes),
	MQL			/ save in MQ.
	TAD I	(CLOCK+4)	/  (hours),
	CDFEDT			/ Save these for the editor.
	DCA	OLDHR		/  ...
	MQA			/ get minutes back.
	DCA	OLDMIN		/   ....
	AC0001			/ Set ECHO flag so that we keep screen uptodate.
	DCA	ECHFLG		/ ...
	JMS	CLRULR		/ Finally, initialize the ruler area.
	JMS	COPRUL		/ and copy default ruler in.
	JMS	LODCHR		/ Get 1st character of file.
	 JMP	INITRL		/ Insert initial ruler if file is empty.
	TAD	(-ECSTRL)	/ Is the 1st character "start of ruler"?
	SNA CLA			/ Skip if no. Insert default ruler.
	 JMP	INITDN		/ 1st char is "start of ruler" so exit.
INITRL,	CDFEDT			/  ...
	JMS	RLGETS		/ Get default ruler (ruler 0).
	JMS	INSRUL		/ Insert it.
	TAD	(ECRMFL)	/ Insert "ruler modified" flag.
	JMS	INSRL1		/  ...
	TAD	LINE23		/ Reset CURPTR to start of newly inserted ruler.
	DCA	CURPTR		/  ...
INITDN,	JMS	CLSSET		/ Init ptrs to that 1st time FXSCRL is called,
				/  CLRSCN gets called.
INITXT,	XX			/ Back to Speller.
/d229	ISZ 	OPNFIL		/ Say that file is now open.
	JMP I	INITSP		/ Return to caller.

PPOPEN,	CDFMYF			/DONT FORGET WHERE YOU ARE		/A214
	CIFMTH			/FLD 6 IS FOR FOOTING BESIDES MATH/SPEL /A214
	JMS I	(BUFEND)	/AIMING FOR 6000			/A214
	JMP	PPORET		/RETURN IN LINE AFTER OPENS		/A214

/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************

ZAP,	XX			/ routine to zero out a portion of memory.
	DCA	T1		/ Save negative count.
ZAP1,	DCA I	X0		/ Zero out next location.
	ISZ	T1 		/ ++++
	JMP	.-2
	JMP I	ZAP		/ Return when done.


OPNFIL,	0			/ 0 UNTIL FILE HAS BEEN OPENED

	X=.			/ FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE

/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************

GETCH,	XX			/ entry point.
	CDFBUF			/ Map data field to buffer field.
	CURMOV			/  ...
	 SKP			/ Handle EOF condition below.
	JMS	LODCHR		/ Get character to check.
	 SKP			/ non-skip return if E-O-F.
	  ISZ	GETCH		/ skip return if not E-O-F.
	CDISPL			/ Return CIF CDF to spell checker field.
	JMP I	GETCH		/ return to caller.


CLOSEF,	XX			/ This routine closes the correct file.
	RDF			/ Get caller's field.
	TAD	CIDF0		/ Make return CDI instruction.
	DCA	CLOSEX		/ Save for the return trip.
	CDFEDT			/ Map our field.
	JMS	SAVLMD		/ Save line modified flag.
/
	SKP CLA			/ Scan 'til end of text buffer.
CLOSE1,	AC0001			/  ...
	CHKPTR			/   ....
	SMA CLA			/ Skip if at end of buffer.
	 JMP	CLOSE1		/ Jmp if not.
CLOSE2,	AC7777			/ Copy from end of the buffer
	CHKPTR			/  (1st see if another character)
	SPA CLA			/  (skip if yes).
	 JMP	CLOSE3		/  (Jmp if no. time to exit).
	TAD I	CURPTR		/ Get last character in buffer.
	JMS	DSKCAL;XPUTET	/ and put it out to the file.
	JMP	CLOSE2		/ Loop until buffer emptied to the file.

/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************

CLOSE3,	CDFSYS
	TAD I	(CLOCK+3) 	/ ++++
	DCA	CLSMIN 		/ CURRENT MINUTES
	TAD I	(CLOCK+4) 	/ CURRENT HOUR
	CDFEDT
	JMS	CVTMIN 		/ ++++
	DCA	CLSMN2
	TAD	OLDMIN 		/ ++++
	DCA	CLSMIN 		/ INITIAL MINUTES
	TAD	OLDHR 		/ INITIAL HOURS
	JMS	CVTMIN
	CIA
	TAD	CLSMN2 		/ CURRENT TIME - INITIAL TIME
	SPA 			/ ++++
	TAD	(30^74)		/ IF NEGATIVE, THE CLOCK ROLLED OVER..
				/ ADD 60 * 24 = MINUTES IN A DAY
	DCA	CLSMN2
	TAD	(15) 		/ ++++
	CIFFIO 			/ ++++
	FILEIO 			/ ++++
	XHDRGT 			/ GET OLD TOTAL TIME
	CLL			/ DONE TO CHECK FOR OVERFLOW IN NEXT ADD
	TAD	CLSMN2 		/ NEW TOTAL TIME
	SZL			/ SKIP IF TIME < 68:15
	AC7777			/ TIME WAS RESET, SET TO MAX
	MQL 			/ ++++
	TAD	(15)
	CIFFIO 			/ ++++
	FILEIO 			/ ++++
	XHDRPT 			/ STORE NEW TOTAL TIME
	TAD	CLSMN2
	MQL 			/ ++++
	TAD	(14)
	CIFFIO 			/ ++++
	FILEIO 			/ ++++
	XHDRPT 			/ SAVE TIME THIS EDIT
	TAD	WIDNAR		/ FORCED WIDE?				/A223
	SNA CLA			/					/A223
	 JMP	CLOSE4		/ JMP IF YES, LEAVE CURRENT SIZES	/A223
	TAD	(30)		/ Set screen size back to max.
	DCA	SCRNLN		/  ...
	JMS	CLR132		/ Back to 80 col mode.
CLOSE4,	AC0003			/ Clear screen & region.		/M223
	CIFMNU			/  ...
	JMS I	(CALLN1)	/   ....
	JMS	PROMPT		/ display "filing being completed.
		MSGF		/  ...
	JMS	DSKCAL		/ and close the file.
		XDSKCL		/  ...
CLOSEX,	XX			/ Map field to return to.
	JMP I	CLOSEF		/ Return to caller.

/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************

CVTMIN,	XX			/ SUBROUTINE TO CONVERT HOURS AND MINUTES TO MINUTES
	SNA 			/ ++++
	JMP	CVTMN2 		/ IF ZERO AC (NO HOURS), JUMP
	CIA 			/ ++++
	DCA	CLSHR 		/ CVTMN1 CONTROL
CVTMN1,	TAD	(74)
	ISZ	CLSHR 		/ ++++
	JMP	CVTMN1
CVTMN2,	TAD	CLSMIN 		/ ADD MINUTES-FROM-HOURS TO MINUTES
	JMP I	CVTMIN
/
CLSMN2,	0 			/ TEMP., ALWAYS CONTAINS MINUTES
CLSMIN,	0 			/ MINUTES FOR CVTMIN
CLSHR,	0 			/ NEG OF HOURS IN CVTMIN



/***************************************************************************
/****				C A U T I O N				****
/****	THIS OVERLAY PAGE IS USED BY DECSPELL AND MUST RESIDE HERE	****
/***************************************************************************

/D222	/	PPCALL		POST PROCESSOR CALL_A_ROUTINE		/A214

	X=.			/ FIRST FREE LOCATION ON PAGE
/---------------------
	PAGE


	*7400			/ OVERLAY AREA 1 LOCATION
OVRNUM=	0			/ INITIALIZE OVERLAY ONE COUNTER
OVLAY1,	OVRNUM			/ STORE OVERLAY NUMBER AS FIRST LOCATION

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

/ THIS FIELD IS USED FOR EDITOR MATH AND GO-TO-PAGE
	FIELD	2

	CDFMYF=CDFLP

	*200

	RELOC	6400


/ THIS CODE WILL LOAD INTO THE TOP OF FIELD 5...
/ THIS IS AN EXTENSION OF THE EDITOR RESIDENT... IT CONTAINS THE SUPERKEY
/ VECTOR TABLE, AND THE COPY ROUTINE...
/ IT WAS DEVISED IN ORDER TO PREVIDE MORE SPACE IN THE RESIDENT PORTION OF THE
/ EDITOR FIELD SO THAT THE MATH INTERFACE, AND GOTO PAGE CODE CAN BE RESIDENT

DSKBLK=.-6400%400+DL3EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/	IF   doing a GOTO PAGE request ignore the GOLD-HALT
/	ELSE   process the GOLD-HALT

/ TEST FIELD 0 HALT FLAG (SET BY TYPING GOLD+HALT)
/ TAKE 1ST RETURN IF SET, 2ND RETURN IF NOT SET

XHLTST,	XX
	CDFEDT			/ CHANGE TO EDIT FIELD
	DCA	T1		/ SAVE AC
	TAD I	(USHLTS)	/ RETRIEVE CALLER'S ADDRESS
	DCA	XHLTST		/ MAKE IT RETURN ADDR

	TAD	RPACTIVE	/ GET GOTO PAGE FLAG
	SZA CLA			/ SKIP IF GOTO PAGE NOT ACTIVE
	JMP	RPIGNORE	/ JUMP TO IGNORE GOLD-HALT

	CDFMNU			/ CHANGE TO MENU FIELD
	TAD I	(LINDIF)	/ PICK UP STATUS CHANGE FLAG
	SNA CLA			/ DID THE STATUS CHANGE ?
	JMP	XHLTS1		/ NO, SKIP AROUND THE STATUS UPDATE

	CDFMYF			/ YES, CHANGE BACK TO THIS FIELD
	CIFMNU			/ CHANGE TO MENU FIELD FOR CHECK
	JMS I	(CALLN2)	/ GO CHECK FOR STATUS VALUE CHANGE

XHLTS1,	CDFSYS			/ CHANGE TO SYSTEM FIELD
	TAD I	HLTFLG		/ PICK UP THE VALUE FOR THE HALT FLAG
	SNA CLA			/ IS THE HALT FLAG SET ?

RPIGNORE,			/ GOTO PAGE EXIT POINT
	ISZ	XHLTST		/ YES, SET UP TO TAKE SKIP RETURN
	TAD	T1
	CDIEDT			/ CHANGE BACK TO EDIT FIELD
	JMP I	XHLTST

RPACTIVE, .-.			/ IF NEG., GOTO PAGE ACTIVE
				/ POS. MEANS NO GOTO PAGE

/ THIS IS THE ONLY ENTRY 'A105' YOU'LL SEE
/ BECAUSE IT IS TO SIGNIFY THE CORRECTION OF THIS SUBROUTINE
/ USED BY GOTO PAGE FOR COMPUTING THE 'CURRENT' PAGE
/ (SINCE THIS ROUTINE DIDN'T WORK BEFORE IT NOW IS CONSIDERED
/ NEW CODE)


/**************************************************
/
/ START GOTO PAGE FIND CURRENT EDIT PAGE OF ALL DOC. PAGES...
/
/*************************************************

CDFILS=	CDF	70		/ 'WPFILS' IS IN FIELD 7

/ ENTER HERE FROM A JMS WITHIN 'OVMENU'
/ CALCULATE THE CURRENT PAGE THE USER IS EDITING
/  AND THE TOTAL NUMBER OF PAGES WITHIN THE DOCUMENT
/   TO SATISFY THE 'XXX' AND 'YYY' VALUES WITHIN
/    THE FOLLOWING EDITOR MENU DISPLAY
/
/	'YOU ARE CURRENTLY EDITING PAGE XXX OF YYY PAGES'

/ X3 -	IS USED AS A TEMPORARY REGISTER (NON AUTO-INDEX MODE)
/
/ X4 -	IS USED AS A TEMPORARY HOLDING REGISTER (FOR 'ISZ'S).
/

RPPMENU,XX			/ BEGIN COUNTING CURRENT/TOTAL PAGES
	DCA	RPPAC		/ SAVE THE accumulator AT ENTRY

/ THE FIRST FEW WORDS OF THE EDIT BUFFER ARE ALWAYS
/  WORD 1 - 7777
/  WORD 2 - 7775	STX (IF REALLY START OF TEXT - ELSE REAL TEXT)
/  WORD 3 - 0016	START OF RULER (IF WORD 2 IS STX)
/  WORD 4 - ????	TEXT

	CDFEDT
	AC7777			/ INITIALIZE FLAG
	DCA	RPSTART		/ TO SIGNIFY 2ND TIME AT EXT
	TAD I	(CURPTR)	/ CURRENT LOC. IN EDIT BUFFER
	DCA	RPPCURPTR	/ START SEARCH BACK FROM HERE
	CDFLP
	AC7776			/ -2 MEANS GET THE 'PAGE COUNT'
	JMS	RPPCAL		/ (THAT MEANS THE NUMBER OF PAGES)
	XRPRD			/ WITHIN THE 'STX' BUFFER
	TAD	(-1750)		/-1000.
	DCA	RPPLSPAGE	/ START WITH ZERO PAGE COUNT (NEGATIVE NOTATION)
	DCA	RPPMSPAGE
/\	JMP	.+1

/ CALCULATE THE 'CURRENT PAGE'
/  BY SUMMING THE PAGE COUNT WITHIN EACH DATA DESCRIPTOR WORD
/   UNTIL THE DATA DESCRIPTOR OFFSET IS EQUAL TO THE OFFSET WITHIN 'SCTOP'
/ THEN READ EACH CHARACTER OF THE EDIT BUFFER
/  FOR ANY TYPE OF PAGE MARK
/   UNTIL THE POSITION WITHIN THE EDIT BUFFER
/    IS THE SAME AS THE ADDRESS WITHIN 'CURPTR'

	JMS	RPPXMENU
	DCA	RPMNT2
	RAL			/ 0, 1
	TAD	RPPMSPAGE
	DCA	RPMNT1

/ IF THE CONTENTS OF THE ac AT ENTRY IS negative
/  THEN ALSO SET THE CONTENTS OF
/   CURPG1 WITH THE CONTENTS OF RPMNT2, AND
/    CURPG2 WITH THE CONTENTS OF RPMNT1

	TAD	RPPAC		/ GET BACK AC AT ENTRY
	SNA CLA			/ SKIP NEXT IF not 'GOLD M'
	JMP	RPPMN2		/ USER REQUEST FOR 'GOLD M'
    CDFEDT
	TAD	RPMNT2
	DCA I	(CURPG1)
	TAD	RPMNT1
	DCA I	(CURPG2)
	JMP	RPREPL		/ REPLACE FILE SYS POINTERS, THEN EXIT

/ CALCULATE THE 'TOTAL PAGE' COUNT OF THE DOCUMENT
/  BY SUMMING THE PAGE COUNT FROM OUR PRESENT POSITION
/   WITHIN THE EDIT BUFFER UNTIL 'ETX'
/    THEN SUMMING THE PAGE COUNT WITHIN EACH REMAINING DATA DESCRIPTOR WORD
/     UNTIL A [0] TERMINATOR SIGNIFYING OUT OF DESCRIPTOR BLOCKS
/      OR UNTIL A [-1] TERMINATOR SIGNIFYING LAST DESCRIPTOR WORD

RPPMN2,	JMS	RPPXMENU
	DCA	RPMNT7
	RAL			/ 0, 1
	TAD	RPPMSPAGE
	DCA	RPMNT6
RPREPL,	TAD	(-4)		/ AC => - 4 TO REPLACE FILE SYSTEM POINTERS
	JMS	RPPCAL		/ TO WHERE THEY WERE AT START OF TOTAL PAGE CALCULATION
	XRPRD			/ TO ENABLE RESUMMING THE EDIT CYCLE
	CDIEDT
	JMP I	RPPMENU		/ EXIT

RPPAC,	ZBLOCK 1		/ HOLDS THE AC AT ENTRY INTO 'RPPMENU'
RPMNT2,	ZBLOCK	1		/ LOW
RPMNT1,	ZBLOCK	1		/ HIGH
RPMNT7,	ZBLOCK	1		/ LOW
RPMNT6,	ZBLOCK	1		/ HIGH

RPPSCTOP,			/ DATA DESCRIPTOR BLOCK SAME AS WITHIN 'SCTOP'

RPPNOGDS,			/ EXAUSTED ALL DATA DESCRIPTOR BLOCKS

RPPXCHARACTER,
	AC7777			/ BACK-UP EDIT BUFFER PTR
	TAD	RPPCURPTR	/ CURRENT LOC. PTR.
	SNA			/ SKIP IF NOT TOP OF BUFFER
	TAD	(5777)		/ RESUME AT BOTTOM IF AT TOP
	DCA	RPPCURPTR	/ UPDATE CURRENT LOC. PTR.

	CDFBUF			/ EDIT BUFFER FIELD
	TAD I	RPPCURPTR	/ GET CHAR. FROM EDIT BUFFER
	CDFLP			/ BACK TO THIS FIELD

	TAD	(-ECSTX)		/ TOP OR BOTTOM ID?
	SNA			/ SKIP IF NEITHER
	JMP	RPPETX		/ SEE WHERE WE ARE

	TAD	(ECSTX-ECNWPG)	/ IS IT NEW PAGE MARK?
	SZA			/ SKIP IF PAGE IN BUFFER
	TAD	(ECNWPG-ECPMRK)
	SZA CLA			/ SKIP NEXT IF PAGE MARK
	JMP	RPPXCHARACTER	/ NEITHER TYPE OF PAGE MARK

/ ANY TYPE OF PAGE MARK WAS FOUND

/ UPDATE 'RPPLSPAGE' AND 'RPPMSPAGE'

	AC0001
	JMS	RPPINCPAGECOUNT	/ GO ACCOUNT FOR PAGE IN BUFFER
	JMP	RPPXCHARACTER	/ DO UNTIL STX MARKER FOUND

RPSTART,	ZBLOCK 1	/ INDICATE # OF TIMES AROUND EDIT BUFFER
RPPCURPTR,	ZBLOCK 1	/ OUR CURPTR

/ EACH CHARACTER FROM THE TOP OF THE EDIT BUFFER
/  STARTING AT THE ADDRESS WITHIN 'BUFBEG'
/   UNTIL THE ADDRESS WITHIN 'CURPTR'
/    HAS BEEN EXAMINED FOR EITHER TYPE OF PAGE MARK
/ PROGRAM LOCATIONS 'RPPMSPAGE' AND 'RPPLSPAGE' HAVE BEEN UPDATED ACCORDINGLY
/  BUT IF THE SUM OF THE CONTENTS OF THOSE TWO LOCATIONS IS ZERO
/   THEN SET 'RPPLSPAGE' EQUIVALENT TO 1 SIGNIFYING PAGE #1

RPPATCURPTR,			/ AT THE CURRENT POINTER OF THE EDIT BUFFER
	DCA	RPPCURPTR

RPPETX,				/ MAYBE AT TOP OR BOTTOM OF ED. BUF.

	CDFEDT			/ EDITOR FIELD
	TAD I	(CURPTR)	/ ORIG. CURPTR AT START OF SEARCH
	CDFLP			/ BACK TO THIS FIELD

	CIA			/ FOR COMPARE TO OUR OWN
	TAD	RPPCURPTR	/ EDIT BUFFER POINTER
	SNA CLA			/ SKIP IF BACKED-UP TO STX
	JMP	ETXTST		/ SEE IF BACKUP TO ETX

ATEND,				/ DONE SEARCHING THRU EDIT BUFFER
	AC0001			/ 'CLL'	/
	TAD	(1750)
	TAD	RPPLSPAGE
	SZA
	CLL
	JMP	JMPIRPPXMENU	/ AT EXIT (AC) COULD = 0 AND (L) COULD = 1
				/ ELSE (AC) IS NOT ZERO AND (L) IS = 0


ETXTST,				/ ETX RECOGNIZED WITHIN BUFFER
	TAD	RPSTART		/ IF FLAG IS MINUS
	SMA CLA			/ THEN WE STARTED AT ETX MARK
	JMP	ATEND		/ ELSE, WE WENT THRU ENTIRE BUFFER-DONE
	DCA	RPSTART		/ ETX WILL BE READ AGAIN, SO GET READY
	JMP	RPPXCHARACTER	/ 1ST CHAR READ WAS ETX, SO CONTINUE

MSG132,	TEXT"^A"		/ MESSAGE USED FOR 132/80 COLOMN MODE SWITCH

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

DSKBLK=.-6400%400+DL3EDT	/ DISK BLOCK WHERE PAGE IS LOADED


RPPXMENU,	XX

RPPXDESCRIPTOR,
	AC7777			/ ... [-1] MEANS...
	JMS	RPPCAL		/ ... GET A 'RPPGDS' ...
	XRPRD			/ ... (DESCRIPTOR) WORD ...
	DCA	RPGDSHOLD	/ ... AND TEMPORARILY SAVE IT ...

/ NOTE THAT FOR COS-310 COMPATABILITY
/  THE CONTENTS OF 'SCTOP' ARE ALWAYS [2] LESS
/   (WPFILS AUTOMATICALLY ADJUSTS FOR THIS)

	TAD	(CURID-1)	/ GET ADDRESS OF CURRENT BLK ID
	MQL			/ TO SEND IN THE MQ
	AC7775			/ -3 MEANS GET THE CONTENTS
	JMS	RPPCAL		/ OF PROGRAM LOCATION 'SCTOP'
	XRPRD			/ & THE MQ = HEADER EXTENSION NUMBER
/
/ AT THE 'START' OF THE REPOSITIONING REQUEST.  PLUS PUT THE
/ 'CURRENT' VALUE OF SCTOP AND THE HDR EXTN # INTO CURID AND CURTOP...
/
	SWP			/ INTERCHANGE MQ WITH AC
	CIA			/ NEGATE THE HEADER EXTENSION NUMBER
	TAD	CURID		/ COMPARE IT WITH OUR CURRENT HDR ID
	SZA CLA			/ SKIP IF SCTOP IN THIS BLK
	JMP	RPPVALUE	/ INCLUDE THIS DESC. THEN
	MQA			/ GET THE OFFSET INTO THE HEADER INTO THE AC

/ the contents of the AC contains the contents of program location 'SCTOP'
/ at start of relative paging request...
/

	CIA
	TAD	CURTOP		/ CURRENT SCTOP
	SPA SNA CLA		/ SKIP IF AT SCTOP
	JMP	RPPVALUE	/ INCLUDE THIS DESC. THEN
	JMP	RPPSCTOP	/ JMP TO COUNT THE NUMBER OF PAGES
				/ WITHIN THE EDIT BUFFER STARTING
				/ AT 'BUFBEG' UNTIL THE ADDRESS
				/ WITHIN 'CURPTR'

/ NOTE: CURID & CURTOP MUST REMAIN TOGETHER & IN THAT ORDER
CURID,	.-.			/ CURrent blk ID #
CURTOP,	.-.			/ CURrent scTOP pointer
RPGDSHOLD,ZBLOCK	1

JMPIRPPXMENU,
	JMP I	RPPXMENU

/ 'RPPCAL' WAS COPIED AFTER 'DSKCAL'
/ (BECAUSE A 'JMS DSKCAL' FROM 'FIELD 5')
/ (WOULD BE AN INSTANT TRIP TO THE FUNNY FARM)

RPPCAL,	XX
	CDFLP			/ THIS DATA FIELD
	DCA	T1		/ SAVE AC
	TAD I	RPPCAL		/ GET VECTOR
	ISZ	RPPCAL
	DCA	.+4		/ SAVE VECTOR
	TAD	T1		/ GET BACK AC
	CIFFIO
	FILEIO
	.-.			/ the VECTOR
	CDFLP
	JMP I	RPPCAL		/ EXIT

RPPVALUE,
	TAD	RPGDSHOLD	/ GET BACK THE 'DESCRIPTOR' WORD
	CMA
	SNA
	JMP	RPPNOGDS	/ [-1] DESCRIPTOR WORD TERMINATOR FOUND
	CMA
	AND	(37)		/ BITS 7-11 IS THE PAGE COUNT
	JMS	RPPINCPAGECOUNT
	JMP	RPPXDESCRIPTOR

/ SUBROUTINE TO INCREMENT VALUES WITHIN 'RPPLSPAGE' AND 'RPPMSPAGE'

/ ENTER WITH THE CONTENTS OF THE AC
/  EQUIVALENT TO THE 'NUMBER OF PAGES'
/   TO INCREMENT

RPPINCPAGECOUNT,
	XX
	CLL
	TAD	RPPLSPAGE	/ CURRENT PAGE + # OF PAGES IN THIS BLOCK
	SZL
	ISZ	RPPMSPAGE
	SZL
	TAD	(-1750)
	DCA	RPPLSPAGE	/ UPDATE CURRENT PAGE NUMBER
	JMP I	RPPINCPAGECOUNT

RPPLSPAGE,	-1750	/1-1000	/ CURRENT PAGE NUMBER (NEGATIVE NOTATION)
RPPMSPAGE,	0		/ 1000-9000 (POSITIVE NOTATION)

/***************************************************
/
/ END GOTO PAGE FIND CURRENT EDIT PAGE OF ALL DOC. PAGES...
/
/***************************************************


/
/
/ SUBR RPXHLT PSUEDO-CODE:
/
/  take out GOLD_HALT support for both GTP and GOLD_HALT...   /A195
/
/ Determine if the user has requested a halt via the GOLD:HALT
/   key during a GOTO PAGE request;
/ If so, then
/	RPBOTF := -1;	( turn this into a GOLD:Bottom )
/	jump to RPRULE;	( never returns to caller )
/ else
/	( user did not press GOLD:HALT )
/	accumulate # of pages in document so far (in CURPG1);
/	compare current page # with desired page # ...
/	exit ...
/	( the structure of RPXHLT is fuzzy because it's not
/	  a piece of modular code that performs a distinct
/	  function--it was made into a subroutine merely
/	  as a device to move code to CDFLP. )
/
/
/ CALL:
/
/	CLA			/ AC MUST = 0
/				/ DF DOESN'T MATTER
/	CIFLP
/	JMS	RPXHLT
/	JMP	NXTDES		/ NOT AT DESIRED PAGE.
/				/ (GO READ NEXT GOTO-PAGE DESCRIPTOR
/				/  WORD AND TRY AGAIN)
/				/ CURPG1= CURRENT PAGE # ACCUMULATED BY
/				/   SCANNING GOTO-PAGE DESCRIPTOR WORDS
/	...			/ AT OR PAST DESIRED PAGE (ACCORDING TO
/				/   COMPARISON OF UNITS, TENS, AND
/				/   HUNDREDS -- STILL NEED TO COMPARE
/				/   THOUSANDS IN CURPG2)
/				/ CURPG1= -# OF PAGE MARKS TO READ,
/				/   STARTING AT CURRENT BLOCK,
/				/   TO REACH DESIRED PAGE.
/				/ AC= DESIRED PAGE # (THOUSANDS)
/				/   = RPBIN2.
/	...
/RPXRULE,...			/ 'RPXHLT' JUMPS HERE (TO TAG RPXRULE)
/				/ IF USER PRESSED GOLD:HALT.
/
/
RPXHLT,	0			/ MAY BE OVERLAID BELOW IF HALT REQUESTED
/D195	CDFSYS			/ TO SYS FIELD TO
/D195	TAD I	HLTFLG		/ GET HALT FLAG
/D195	SNA CLA			/ SKIP IF HALT SELECTED
/D195	JMP	WOHLTX		/ JUMP IF HALT NOT SELECTED

/D195	CDFLP			/ BACK TO THIS FIELD
/D195	TAD	(RPXRULE)	/ ADDR. TO CONCLUDE GOTO PAGE AT
/D195	DCA	RPXHLT		/ NEW RETURN ADDR.

/D195	CDFEDT			/ EDITOR'S DF
/D195	AC7777			/ AC = > -1
/D195	DCA I	(RPBOTF)	/ SET V2 GOLD BOTTOM REQUEST

/D195	JMP	WIHLTX		/ LEAVE AC => 0 ON RETURN

/ if desired LO page-indication found within this GTP descriptor word
/	then load contents of 'THOUSANDS' word and resume at
/	     RETURN+1 for furthur HO desired-page testing
/		else desired page not found so RETURN+0 to resume
/		     by reading the next GTP descriptor word.		/A195


WOHLTX,	CDFEDT			/ EDITOR'S DF
	TAD I	(SRCDIR)	/ PASS ALONG THE CURRENT DESCRIPTOR WORD
	AND	(37)		/ BITS 7-11 FOR # OF PAGES IN THIS BLOCK
	TAD I	(CURPG1)	/ CURRENT PAGE # + # OF PAGES IN THIS BLK
	DCA I	(CURPG1)	/ UPDATE CURRENT PAGE NUMBER
	TAD I	(RPBIN1)	/ GET DESIRED PAGE #
	CIA			/ FOR COMPARE TO
	TAD I	(CURPG1)	/ ACCUMULATED # OF PAGES FOUND

	SPA			/ SKIP IF PAGE IN THIS BLK
	JMP	WIHLTX		/ RETURN+0 TO RPDESC FOR NEXT DESC.
	CIA			/ NEG. REMAINDER OF PAGE-MARKS
	DCA I	(CURPG1)	/ MAKE A COPY
	TAD I	(SRCDIR)	/ CURRENT DESC. WORD CONTENTS
	AND	(37)		/ # OF PAGES ONLY
	TAD I	(CURPG1)	/ MINUS THOSE BEYOND OUR PAGE
	CIA			/ = # OF PAGE-MARKS TO READ TO PAGE
	DCA I	(CURPG1)	/ SUPPLY FOR NEXT OVERLAY
	TAD I	(RPBIN2)	/ LOOK AT THE THOUSANDS #
	ISZ	RPXHLT		/ RETURN+1 TO CONTINUE W/THOUS.

WIHLTX,	CDIEDT			/ EDITOR'S DF AND IF
	JMP I	RPXHLT		/ RETURN: TRYPGE IF NOT HALTED
				/	  RPRULE IF HALTED

/ just reported the page-not-found error.
/  get set to paint the screen with the last available page
/  as recorded by the descriptors.

RPERRE,	CDFEDT			/ EDITOR DF
	TAD I	(CURPG1)	/ TOTAL # OF PAGES COUNTED BEFORE -1
	DCA I	(RPBIN1)	/ BECOMES THE NEW DESIRED PAGE
	DCA I	(RPBIN2)

	AC7777			/ F.C. TO READ DESC.
	JMS	RPPCAL
	XRPRD			/ GTP ENTRY POINT
	CDFEDT			/ BACK TO EDITOR DF

	DCA I	(SRCDIR)	/ SUPPLY NEW DESCRIPTOR WORD
	TAD I	(SRCDIR)	/ GET A COPY OF IT
	DCA	T1		/ TO WORK WITH
	TAD	T1

	CMA			/ -1 FLAGS A V1 DOC. BEING USED FOR THE 1ST TIME
	SZA CLA			/ SKIP IF V1 DOC.
	JMP	RPERPG		/ JUMP IF A PAGE AVAILABLE, MAYBE
	DCA I	(CURPG1)	/ INDICATE TOP OF DOCUMENT
	CDIEDT			/ DF AND IF TO EDITOR TO RESUME EDIT CYCLE
	JMP	RPRULE		/ GO POSITION TO TOP OF DOC.

RPERPG,	TAD	T1		/ GET THE DESCRIPTOR WORD BACK
	AND	(37)		/ GET ITS' PAGE COUNT IN THIS BLOCK
	CIA
	TAD I	(CURPG1)	/ ALREADY COUNTED THEM EARLIER BEFORE -1 FOUND
	DCA I	(CURPG1)	/ PRETEND NEVER SAW THEM
	CDIEDT			/ DF AND IF TO EDITOR TO RESUME EDIT CYCLE
	JMP	TRYPGE		/ FIND PAGE WITHIN THIS BLOCK

/******************************************************

/  END OF GOTO PAGE IN FIELD 5

/******************************************************

/ PUTLP		Routine moved here this edit for space elsewhere	/a247

/ ROUTINE TO OUTPUT A MESSAGE TO THE SCREEN, ADDRESS OF MESSAGE IS
/ IN AC ON ENTRY
PUTLP,	XX
	DCA	PTLP1		/ SET UP ADDRESS
	CIFMNU
	JMS I	IOACAL		/ CALL I/O ROUTINE
	0			/ USE DEFAULT OUTPUT ROUTINE
PTLP1,	XX			/ ADDRESS OF TEXT STRING TO OUTPUT
	CDIEDT			/ SET BACK TO EDITOR FIELD
	JMP I	PUTLP		/ RETURN

/ EXERR1	Moved here this edit to gather space together		/a247

/ EXTRACTNUMBER ERROR HANDLER
EXERR1,	TAD	(EREXTR)	/ GET ERROR NUMBER
	JMS	RESCURPTR	/ FIRST RESTORE CURPTR THEN....
	JMS	EDERR-1		/ GO TO ERROR REPORTER. WON'T RETURN
SAVTP,	.-.			/ SAVED_TAB_POSITION - HOLDS TAB_POSITION
				/  OF CURRENT DECIMAL TAB FIELD. USED
				/  BY BOTH EDERR AND GETDTF ROUTINES.
				/  MUST FOLLOW JMS TO EDERR-1

	X=.		/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

DSKBLK=.-6400%400+DL3EDT	/ DISK BLOCK WHERE PAGE IS LOADED



/ EDITOR MATH CODE GOES HERE

/ THIS IS EDITOR MATH CODE USED TO EVALUATE THE MATH CONTROL BLOCKS WHILE IN
/ THE EDITOR. THIS CODE IS ACTIVATED BY THE DISCOVERY OF A CONTROL BLOCK CHAR
/ IN THE TEXT THAT IS BEING EDITED.

/ THE FOLLOWING ROUTINE SERVES AS THE ENTRY POINT TO THE EDITOR MATH
/ CONTROL BLOCK PROCESSING CODE FROM THE EDITOR "SCRLUP" ROUTINE.
/ EACH TIME A LINE IS SCROLLED UP A CALL IS MADE HERE TO CHECK THE LINE
/ WHETHER IT IS IN A CONTROL BLOCK AND IF THE CONTROL BLOCK IS MATH.
/ PROCESSING IS DONE ACCORDINGLY.

/ **** WARNING ****!! "INCTLB" IS EQUATED TO 7000  WHILE
/ CKCTRL" IS EQUATED TO 7001 IN M.PA, THEREFORE DO
/ NOT MOVE "INCTLB" OR "CKCTRL" FROM THEIR PRESENT POSITIONS
/ UNLESS CHANGING M.PA ALSO

INCTLB,	0		/"IN CONTROL BLOCK" FLAG, SET TO 1 IF NOT IN A CONTROL
			/BLOCK, AND 0 IF IN CTRL BLOCK. THIS FLAG HAS TO STAY
			/IN THIS POSITION BECAUSE IT IS DEFINED AS SUCH IN
			/WPF1.PA. THIS IS TO ALLOW IT TO BE INITIALIZED FROM
			/THE MATH FIELD AT THE SAME TIME THE EDITOR CODE IS
			/INITIALIZED. REF. "WPEDOV.PA"

/			***** CAUTION *****
/	CKCTRL ROUTINE IS FILLED WITH CDF AND CIF INSTRUCTIONS.  IF YOU
/	ADD, MODIFY, MOVE, OR DELETE CODE CHECK FIELDS ARE PROPERLY SET!

CKCTRL,	XX
	CLA			/ CLEAR AC

/D198;	IFDEF	UNBUND 	<
	/RUN CHECK TO SEE IF UNBUNDLING IS DEFINED AND IF IT IS THEN
	/SEE IF MATH IS ACTIVATED
	/		*** CAUTION ***
	/  THE HAVMTH ROUTINE RESIDES IN AN AREA OF FIELD 5 THAT IS
	/  SHARED BY LIST PROCESSING AND THE EDITOR.  HAVMTH IS NOT
	/  RESIDENT WHEN RUNNING LIST PROCESSING! THUS THE FOLLOWING
	/  TEST MUST FOLLOW THE TEST ABOVE SO THAT IF WE ARE RUNNING
	/  LIST PROCESSING WE WILL NOT CALL HAVMTH AND CRASH!

	JMS	HAVMTH		/ IF THE MATH FEATURE IS NOT ACTIVATED
	JMP	BKEDIT  	/ THEN JUST RETURN TO THE EDITOR
/D198;			>	/ END IFDEF UNBUND
	/ YES: SEE WHAT TYPE OF MATH IS WANTED (I.E. LP OR EDITOR MATH
	/  THIS IS NECESSARY BECAUSE LP ALSO MAKES USE OF THE EDITOR
	/ (SEE NOTES FOR HAVMTH CHECK BELOW BEFORE TOUCHING THIS ROUTINE!!)

	CDFMTH			/ SET TO MATH DATA FIELD
	TAD I	(MTHTYP)	/ GET "MATH TYPE" FLAG
	SNA CLA			/ IS IT EDITOR MATH THAT IS WANTED?
	JMP	BKEDIT		/  NO: THEN JUST RETURN TO LP USE OF THE EDITOR

	/   CHECK FOR ENTERING OR LEAVING A MATH AREA

	/   CHECK TO SEE IF IN BACKUP MODE
	CDFEDT			/ GET EDITOR DATA FIELD
	AC7777			/ IF EDMODE = 1 (IN BACKUP MODE)
	TAD I	(EDMODE)
	SNA CLA
	JMP	BKEDIT		/ THEN RETURN TO EDITOR

	/ CHECK TO SEE IF "MA" SWITCH IS SET TO "YES"

	CDFMNU			/ CHANGE TO MENU DATA FIELD
	TAD I	(MUBUF+MNMATH)	/ GET "MA" FLAG
	CDFMYF			/ RETURN TO THIS DATA FIELD
	SNA CLA			/ IS "MA" SET TO "YES"?
	JMP	BKEDIT		/  NO: RETURN TO EDITOR

	/  YES: CHECK WITH EDITOR TO SEE IF IN SELECT MODE

	JMS	CKSCLT		/ IF IN SELECT MODE THEN SHUT MATH OFF AND
				/ RETURN TO THE EDITOR DIRECTLY FROM "CKSCLT"
	CDFMYF
	AC7777			/ OFFSET FOR SETTING OF CURPTR
	JMS	STCURPTR	/ SET CURPTR FOR READING OF LINE

	/ CHECK TO SEE IF THIS IS A RULER LINE.  IF SO DON'T DO MATH.
CKCTRT,	JMS	CKCTR1		/ GO SEE IF THE LINE IS A RULER
	-1			/ VALUE TO AND WITH CHARACTER READ
	-ECSTRL			/ NEG. VALUE OF CHARACTER TO MATCH
				/ IF MATCH GOTO BKEDI3 FROM CKCTR1 ROUTINE.
				/  IF NO MATCH WE RETURN HERE.

	/ GO RUN CHECK ON PRESENT POSITION RELATIVE TO ANY CONTROL BLOCK
	JMP	CKCTR6		/ CHECK CONTROL BLOCK STATUS

	/ IF NOT IN A BLOCK THEN RUN A CHECK TO SEE IF JUST STARTING ONE
CKCTR2,	JMS	CKCTRS		/ ARE WE JUST STARTING A CONTROL BLOCK?
	JMP	CKCTR3		/  NO: RESET FLAG & CHECK EXTRACTION ROUTINE
	JMS	STLOC1		/  YES: IS "START CTRL" CHAR ON PREVIOUS LINE?
	JMP	CKCTR4		/  YES: GO PROCESS 1ST LINE OF BLOCK

CKCTR3,	AC0001			/  NO: GET ONE IN THE AC
	DCA	INCTLB		/ SET "IN CTRL BLOCK" FLAG = FALSE

	JMS	MASTTS		/ IS "MA" SET TO YES, AND ARE WE IN MATH AREA?
	JMP	BKEDI3		/  NO: RESET CURPTR & RETURN TO EDITOR

	JMS	CKCTR1		/ SEE IF NEW PAGE, PAGE MARKER, START OR END
				/  PRINT CONTROL.
	0177			/ VALUE TO AND WITH CHAR. READ
	-ECNWPG			/ NEG. VALUE OF CHARACTER TO MATCH
				/ IF MATCH GOTO BKEDI3 FROM CKCTR1 ROUTINE.
				/  IF NO MATCH WE RETURN HERE.
	JMP	EXTRACTNUMBER 	/ DO EDITOR MATH ON THIS LINE

	/ THIS IS FIRST TIME CTRL BLOCK IS ACCESSED, SINCE JUST STARTING
	/ BLOCK THEN INITIALIZE VALUES BEFORE START PROCESSING OF BLOCK
CKCTR4,	DCA	MTHCTL		/ SET "IN MATH CTRL BLOCK" FLAG = FALSE
	DCA	INCTLB		/ SET "IN CONTROL BLOCK" FLAG = TRUE
	DCA	VALID		/ SET  "VALID LINE FOUND" FLAG = TRUE
	CDFMTH			/ CHANGE DATA FIELD REGISTER TO MATH FIELD
	AC0001			/ GET 1 IN THE AC
	DCA I	(MTHSND)	/ SET EDIT MATH SECOND LINE FLAG = FALSE
	DCA I	(FSTLNE)	/ SET "CONTROL BLOCK FIRST LINE" FLAG = TRUE
	CDFLP			/ RESET TO THIS DATA FIELD
SETRTN,	CIFMTH			/ CHANGE PROGRAM CONTROL TO MATH FIELD
	JMS	RTRN1		/ INITIALIZE INPUT LINE BUFFER PTR TO START OF BUFFER

				/ SET UP TO PROCESS LATEST SCROLLED UP LINE
SCRLLN,	AC0001			/  NO: CONTINUE PROCESS PRESENT LINE
	DCA	LINEND		/ SET "LINE END" = FALSE (END SCROLLED LINE NOT FOUND)
	DCA	BGNLNE		/ SET "START OF NEW SCROLLED LINE" FLAG = TRUE

				/ PUT CHAR FROM SCROLLED UP LINE INTO THE LINEBUFFER

PRSCHR,	TAD	LINEND		/ GET THE "LINE END" FLAG
	SNA CLA			/ IS IT THE END OF THE SCROLLED UP LINE BEING READ IN?
	JMP	CHLINE		/  YES: GO SEE IF LINE ENDS WITH A HARD RETURN
	JMS	READNEXTCHARACTER
	JMP	BKEDIT		/ ETX RETURN.
	TAD	CRLMB		/ CHARACTER = LINE_END?
	TAD	(-ECNWLN)	/ ADD NEGATIVE OF "NEW LINE" CHAR
	SZA			/ IS IT A "NEW LINE" CHAR?
	TAD	(ECNWLN-ECNWPG)	/ NO: GET "NEW PAGE/PAGE MARKER" CHAR VAL
	SNA CLA			/ IS THE CHAR A "NEW PAGE" OR "PAGE MARKER"?
	DCA	LINEND		/  YES: SET LINE_END = TRUE

	JMS	CHKCH1		/  NO: PROCESS CHAR JUST READ IN FROM SCROLLED UP LINE

	TAD	CRWMB		/ GET CHARACTER READ
	DCA	CHROVR		/ SAVE IT IN LOCATION AFTER THE CALL TO MATH FLD
	CIFMTH			/ SET PROGRAM CONTROL TO MATH FLD
	JMS	RTRN2		/ GO PUT INPUT CHAR INTO INPUT LINE BUFFER
CHROVR,	0			/ CONTAINS INPUT CHAR TO PASS TO "RTRN2" IN MATH FLD

	JMP	EDERR1		/ SKIP RTN HERE IF MATH FIELD INPUT LINE
				/ BUFFER OVERFLOW WITHIN THE CONTEXT OF A MATH CONTROL
				/ BLOCK, OR LINES IN THE BLOCK AFTER AN "END" CTRL WORD
				/ THE AC CONTAINS THE PASSED ERROR NUMBER

NTMATH,	JMP	BKEDTX		/ DOUBLE SKIP RTN HERE FROM "RTRN2" IF INPUT LINE
				/ BUFFER OVERFLOW AND NOT A MATH CONTROL BLOCK.
				/ PROCEED TO IGNORE THE CTRL BLOCK CAUSE NOT MATH

	JMP	PRSCHR		/ TRIPLE SKIP RETURN HERE FROM "RTRN2" IF INPUT CHAR
				/ PLACED INTO INPUT LINE BUFFER WITHOUT AN OVERFLOW.
				/ GET THE NEXT CHAR TO READ IN

	/ ROUTINE TO CHECK FOR HARD RETURN AT END OF SCROLLED UP LINE

CHLINE,	TAD	CRWMB		/ GET LAST CHARACTER
	TAD	(-ECNWLN)	/ ADD TO IT NEGATIVE OF HARD RETURN
	SZA 			/ WAS THE LAST CHAR ON THE LINE A HARD RETURN
	JMP	NOTVLD		/  NO: THEN SET "VALID LINE FOUND" = FALSE
				/  AND GO BACK TO EDITOR FOR NEXT SCROLLED LINE

	DCA	VALID		/  YES: SET "VALID LINE FOUND" = TRUE
				/  AND PROCESS VALID LINE WITHIN CONTROL BLOCK

	CIFMTH			/ GO TO MATH FIELD
	JMS	RTRN3		/ PROCESS STRING OF CHARS PLACED IN LINEBUFFER

	JMP	SETRT1		/ NORMAL RTRN FORM "RTRN3", INIT LINEBUFFER & GO BACK

	JMP	EDERR1		/ SKIP RTRN TO PROCESS MATH CTRL BLCK ERR

NXMATH,	JMP	BKEDTX		/ DOUBLE SKIP RTN TO PROCESS ERROR BUT NOT MATH BLK

				/ IF VALID LINE NOT FOUND

NOTVLD,	DCA	VALID		/ SET "VALID LINE FOUND" = FALSE
	JMP	BKEDI3		/ GO RESTORE CURPTR AND THEN RETURN TO EDITOR


SETRT1,	CDFMTH			/ CHANGE TO MATH DATA FIELD
	TAD I	(MTHWRK)	/ GET "EDITOR MATH WORK AREA" FLAG
	CDFLP			/ RETURN TO LP DATA FIELD
	SZA CLA			/ ARE WE IN AN EDITOR MATH  WORK AREA?
	JMP	SETRT2		/  NO: SET UP TO PROCESS NEXT LINE

	/  YES: THEN HAVE TO STOP HERE TO ASK IF IN CTRL BLOCK.
	/ IF "INCTLB" = FALSE THEN MEANS HAVE REACHED END OF A MATH AREA
	/ WHERE THE "1414" END OF BLOCK CHAR HAS TO BE USED AS A LINE
	/ TERMINATOR IN ORDER TO PROCESS PREVIOUS INPUT WHICH REMAINS
	/ AN INVALID LINE UNTIL A VALID TERMINATOR IS FOUND. THE END OF
	/ BLOCK CHAR IS CONVERTED TO A "HARD RETURN" TO MAKE PREVIOUS
	/ LINE VALID. HOWEVER NOW HAVE THE PROBLEM OF HAVING TO PROCESS
	/ THIS LINE AFTER HAVING REACHED THE END OF A MATH BLOCK. THUS
	/ ONE DOES NOT WANT TO SET "IN MATH CTRL BLOCK" FLAG = TRUE IF
	/ THIS IS THE CASE, BECAUSE END OF THE MATH BLOCK HAS BEEN
	/ REACHED AND "MTHCTL" SHOULD BE FALSE.	THEREFORE A CHECK IS
	/ PUT IN HERE TO SEE IF THE ABOVE CASE HAS BEEN ENCOUNTERED.
	/ IF SO, THEN THE "MTHCTL" IS SET UP TO BE LEFT FALSE. FOR REF.
	/ SEE "CHKCH1" - CHECK FOR & PROCESS END OF CTRL BLOCK CHAR

	TAD	INCTLB		/ GET "IN CTRL BLOCK" FLAG
	SNA CLA			/ ARE WE STILL IN THE MATH CTRL BLOCK?
	AC0001			/  YES: GET 1 TO SET "MTHCTL" = TRUE
	DCA	MTHCTL		/  NO: THEN LEAVE IT SET TO FALSE

SETRT2,	CIFMTH			/ CHANGE PROGRAM CONTROL TO MATH FIELD
	JMS	RTRN1		/ INITIALIZE INPUT LINE BUFFER PTR TO START OF BUFFER

				/ AND RETURN TO EDITOR
BKEDI3,	JMS	RESCURPTR	/ RESTORE CURPTR
BKEDIT,	CDIEDT			/ CDI INSTRUCTION HERE TO RETURN TO EDITOR
	JMP I	CKCTRL		/ RETURN TO CALLER IN WPEDIT "SCRLUP" ROUTINE

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

DSKBLK=.-6400%400+DL3EDT	/ DISK BLOCK WHERE PAGE IS LOADED



/ ******** WARNING - "MTHCTL" DEFINED IN M.PA AS AT LOC 7200 *******
/ IF "MTHCTL" IS MOVED THEN IT MUST BE REDEFINED IN THAT PREFIX MODULE
/ IT IS REFERENCED BY "RUNCHK" RTN IN MATH MODULE

	*7200
MTHCTL,	0			/ "IN MATH CTRL BLOCK" FLAG, 0=FALSE, 1=TRUE

/ ******** WARNING - "RTNMTH" DEFINED IN M.PA AS AT LOC 7201 ******
*7201
RTNMTH,	JMP	BKEDI3		/ ENTRY POINT BACK HERE FROM MATH MODULE, JUMP
				/ HERE FROM "RUNCHK" IN TMATH.PA! GO RESTORE
				/ "CURPTR" BEFORE RETURNING TO THE EDITOR

/ ***** WARNING *****  "ZROTBL" IS DEFINED IN "M.PA" AS AT 7205 ****
/ ***** DO NOT MOVE THIS SUBRTN WITHOUT ALSO CHANGING "M.PA"    ****
/ SUBRTN CALLED FROM "SETCTL" RTN IN THE MATH FIELD, IT IS USED TO INITIALIZE
/ THE "DCHAR" AND "TCHAR" TABLES WHICH HOLD THE POINTERS TO THE VALUES OF THE
/ ":Dnn" AND ":Tnn" SYMBOLS ENCOUNTERED WHEN PARSING AN EDITOR MATH CTRL BLOCK

/++
/		ZERO_TABLES
/
/ FUNTIONAL DESCRIPTION:	ZROTBL
/
/	THIS ROUTINE IS USED TO ZERO BOTH THE DCHAR AND TCHAR TABLES OR
/	ONLY THE DCHAR TABLE BASED ON VALUE IN THE AC UPON ENTRY.
/
/ CALLING SEQUENCE:	DF MUST = CALLER'S FIELD
/			CIFLP
/			JMS	ZROTBL
/
/ INPUT PARAMETERS:	AC =  0 ---> ZERO BOTH DCHAR AND TCHAR TABLES
/			AC <> 0 ---> ZERO DCHAR TABLE ONLY
/
/ IMPLICIT INPUT:	T1
/ OUTPUT PARAMETERS:	NONE
/ IMPLICIT OUTPUT:	X5, X4, T1
/ COMPLETION CODE:	NONE
/
/ SIDE EFFECTS:		1) *CAUTION* - MQ HOLDS FLAG THOUGHOUT ROUTINE.
/
/--

	*7205
ZROTBL,	XX
	MQL			/ SAVE ENTRY FLAG = 0 - CLR D & TCHAR TABLES
				/		    1 - CLR DCHAR TABLE ONLY
	RDF			/ SET UP RETURN CDIF INSTRUCTION
	TAD	CIDF0
	DCA	ZROTB2		/ SAVE IT
	CDFLP			/ SET TO FIELD OF DCHAR & TCHAR TABLE
	TAD	(-DCHARL)	/ SET TABLE LENGTH COUNT
	DCA	T1
	TAD	(DCHAR-1)	/ SET DCHAR TABLE ADDRESS
	DCA	X5
	TAD	(TCHAR-1)	/ SET TCHAR TABLE ADDRESS
	DCA	X4
ZROTB1,	DCA I	X5		/ CLEAR DCHAR TABLE LOCATION
	MQA			/ CLEAR TCHAR TABLE LOCATION?
	SNA CLA			/ SKIP IF: NOT
	DCA I	X4		/ CLEAR TCHAR TABLE LOCATION
	ISZ	T1		/ FINISHED?
	JMP	ZROTB1		/ NO - CLEAR NEXT LOCATION
ZROTB2,	.-.			/ RETURN CDIF INSTRUCTION
	JMP I	ZROTBL		/ RETURN


/ COME HERE TO PROCESS LATEST CHAR READ IN FROM SCROLLED UP LINE

CHKCH1,	XX			/ CHECK FOR & PROCESS "END OF CTRL" BLOCK CHAR

	TAD	CRWMB		/ GET CHARACTER READ WITH MODE BITS
	TAD	(-ECPCT2)	/ ADD TO IT NEGATIVE OF "END CTRL" CHAR
	SZA CLA			/ IS IT THE END OF THE MATH CTRL BLOCK?
	JMP	CKRULE		/  NO: SKIP DOWN TO CONTINUE TO CHECK CHAR
	AC0001			/  YES: SET THE AC TO 1
	DCA	INCTLB		/ SET "IN CONTROL BLOCK" FLAG = FALSE
	DCA	MTHCTL		/ SET "IN MATH CONTROL BLOCK" FLAG = FALSE
	CDFMTH			/ CHANGE TO MATH DATA FIELD
	TAD I	(MTHSND)	/ GET "SECOND LINE" FLAG
	CDFMYF			/ RETURN TO THIS DATA FIELD
	SMA CLA			/ WAS AN "END" COMMAND JUST PROCESSED BEFORE
				/ FINDING THIS "END CTRL BLOCK" MARKER?
	JMP	CKVALD		/  NO: CONTINUE REGULAR PROCESSING
	CDFMTH			/  YES: CHANGE TO MATH DATA FIELD
	AC0001			/ GET 1 INTO THE AC
	DCA I	(MTHWRK)	/ SET TO "NOT START OF MATH WORK AREA"
	CDFMYF			/ RETURN TO THIS DATA FIELD

CKVALD,	TAD	VALID		/ GET VALID LINE FLAG
	SNA CLA			/ WAS THE LAST LINE VALID?
	JMP	BKEDI3		/  YES: GO RESET "CURPTR" & RETURN TO EDITOR
	TAD	(ECNWLN)	/  NO: GET "NEW LINE" CHAR
	DCA	CRWMB		/ REPLACE "END OF BLOCK" CHAR WITH "NEW LINE" CHAR
				/ DONE BECAUSE "LEXIC" RTN WILL NOT HANDLE EOB CHAR
				/ AS A VALID LINE TERMINATOR
	JMP	CNTPR3		/ GO SET "START OF LINE" = FALSE & RTRN TO PROCESS LINE

	/ CHECK TO SEE IF THE LINE IS A RULER

/CKRULE, TAD	SAVCHR		/ PUT CHAR JUST READ IN INTO THE AC
/	TAD	(-ECSTRL)	/ ADD TO IT NEGATIVE OF START OF RULER
/	SNA CLA			/ IS IT THE START OF A RULER?
/	JMP	BKEDIT		/  YES: THEN IGNORE PRESENT LINE WITH RULER
/				/	ON IT, GO BACK TO EDITOR & WAIT FOR
/				/	NEXT SCROLLED UP LINE
/	/ NO: THEN CONTINUE TO CHECK FOR OTHER POSSIBILITIES

CKRULE, NOP	/**** TEMP TO SEE IF NEED RULER CHECK CODE

	/ SCREEN OUT LEADING SPECIAL CHARACTERS IF START OF VALID LINE

FSTCHR,	TAD	VALID		/ GET "VALID LINE" FLAG
	SZA CLA			/ WAS THE LAST LINE VALID?
	JMP	CNTPRS		/  NO: CONTINUE TO PROCESS CHARACTER
	TAD	BGNLNE		/  YES: SEE IF START OF SCROLLED LINE
	SZA CLA			/ IS IT THE START OF A SCROLLED UP LINE
	JMP	CNTPRS		/  NO: CONTINUE TO PROCESS CHAR
	TAD	CRLMB		/  YES: GET CHARACTER
	TAD	(-41)		/ GET NEGATIVE OF UPPER LIMIT OF SPECIAL CHARACTERS
	SMA CLA			/ IS IT A SPECIAL CHAR?
	JMP	CNTPRS		/  NO: CONTINUE TO PROCESS CHARACTER
	TAD	LINEND		/  YES: GET "LINE END" FLAG
	SNA CLA			/ IS IT THE END OF THE LINE?
	JMP	BKEDI3		/  YES: GO BACK TO EDITOR & WAIT FOR NEXT LINE
	JMP	PRSCHR		/  NO: DUMP CHAR & GO READ IN NEXT CHAR FROM LINE

	/ SCREEN OUT NULLS, JUSTIFIED SPACES & BOTH TYPES OF SOFT RETURNS
	/ FROM ANYWHERE THEY OCCUR IN THE LINE - AS THE CASE MAY PERMIT

CNTPRS,	TAD	CRWMB		/ GET CHARACTER READ WITH MODE BITS
	SZA			/ SKIP IF: CHARACTER = NULL
	TAD	(-ECWWLN)	/ CHARACTER = SOFT_RETURN?
	SZA			/ SKIP IF: SO
	TAD	(ECWWLN-ECJSPC)	/ CHARACTER = SOFT_SPACE?
	SZA			/ SKIP IF: SO
	TAD	(ECJSPC-ECHYLN)	/ CHARACTER = SOFT_RETURN_WITH_HYPHEN?
	SNA CLA			/ SKIP IF: NOT
	JMP	PRSCHR		/  YES: DUMP IT & GO GET NEXT CHAR FROM LINE

	/ NO: THEN MUST BE A REGULAR CHAR - PROCESS AS SUCH

CNTPR3,	AC0001			/ GET 1 IN THE AC
	DCA	BGNLNE		/ SET "START OF NEW LINE" FLAG = FALSE

CNTPR1,	JMP I	CHKCH1		/ RETURN TO CALLER


/ THE FOLLLOWING ARE VALUES USED BY THE EDITOR MATH CONTROL BLOCK EVALUATION CODE

BGNLNE,	0			/ "START OF NEW SCROLLED LINE" FLAG
				/  (NOTE A SCROLLED LINE IS COMPOSED OF THE FIRST LINE
				/  UP FROM THE BOTTOM OF THE SCREEN)
LINEND,	0			/ 'LINE END" FLAG (I.E. END OF SCROLLED UP LINE)
HLDPTR,	0			/ HOLDS PTR TO "START" CTRL BLOCK CHAR POSITION PTR
VALID,	0			/ "VALID LINE FOUND" FLAG, = 0 IF TRUE & NOT 0 IF FALSE
				/  (NOTE A VALID LINE IS COMPOSED OF ANY NUMBER OF
				/  SCROLLED UP LINES THE END OF WHICH IS TERMINATED
				/  BY A HARD RETURN)

BKEDT1,	AC0001			/ SET AC TO 1
	DCA	INCTLB		/ SET "IN CONTROL BLOCK" FLAG =FALSE
	JMP	BKEDI3		/ RESTORE CURPTR AND THEN RETURN TO EDITOR

BKDTX1,	JMS	SCRINI		/ IF ERROR FOUND IN BLOCK WHICH IS NOT MATH THAN
				/ REINIT AS IF HAVE BACKED UP IN MATH BLOCK.
				/ THIS SHOULD INSURE TRAPPING OUT ANY POSSIBILITY
				/ OF LEAVING THE MATH MODULE (I.E. THE LINE-
				/ BUFFER, ETC.) IN A WRONG STATE, THUS PRECLUDING
				/ THE CHANGE OF LETTING SUCH THINGS AS A
				/ COMMAND SEQUENCE LIKE "BEG(HR)IN" PASS BY
				/ UNDETECTED BY THE CTRL BLOCK CODE

BKEDTX,	CLA			/ CLEAR ANY ERROR NUMBERS PASSED BACK FROM MATH
	DCA	MTHCTL		/ SET "IN MATH CTRL BLOCK" FLAG = FALSE
	JMP	BKEDI3		/ RESTORE CURPTR AND THEN RETURN TO EDITOR

/ routine backs up the descriptor block list until it finds a ruler, at
/ which point it JMP's to BACK3 to set up RPMTRL and RPRLHN for the
/ loading of the ruler.  this code is executed on a Gold Bottom request
/
/ enter with RPCUOF pointing at the block that we will start our 10 block
/ scroll at.  must adjust RPCUOF back 1 block before checking for a ruler.

BACK1,	XX			/ SAVE CALLERS RETURN ADDRESS
BACK2,	AC7777			/ ADJUST BACK 1
	JMS	AJUST		/ ADJUST RPCUOF
	CDFEDT			/ FIELD 5 ON RETURN

	TAD I	(RPCUBK)	/ IDENTIFY WHICH HDR BLK
	MQL			/ CONTAINS OUR CURRENT POSITION
	AC7776			/ -2
	TAD I	(RPCUOF)	/ OFFSET TO BLK-2 OF OUR CURRENT POSITION
	JMS	RPPCAL		/ REQUEST SCBOT AND SCTOP BE SET UP
	XRPRD			/ ENTRY POINT FOR V2 GOTO PAGE RANDOM BLK READ
	CDFEDT			/ FIELD 4 ON RETURN

	AC7777			/ -1
	JMS	RPPCAL		/ REQUEST TO READ CURRENT DESCRIPTOR WORD
	XRPRD			/ ENTRY POINT
	CDFEDT			/ DESCRIPTOR WORD IN AC ON RETURN - FIELD 4 ON RETURN

	AND	(4000)		/ DOES THE BLK CONTAIN A RULER??
	SZA CLA			/ SKIP IF NO RULER FOUND
	JMP	BACK3		/ RULER FOUND
	JMP	BACK2		/ GO BACK ANOTHER BLK

BACK4,	JMP I	BACK1		/ RETURN....

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

DSKBLK=.-6400%400+DL3EDT	/ DISK BLOCK WHERE PAGE IS LOADED


EDXVEC,				/ SPECIAL KEYBOARD XFER VECTOR
	EIPWFL			/ 	POWER FAIL DETECTED
	EIRBCH			/ 	RUB CHARACTER
	EIRBWD			/ 	RUB WORD
	EINWLN			/ 	RETURN
	EIPCMD			/ GOLD:	COMMAND
	EIPGRF			/ GOLD:	PARAGRAPH MARKER
	EITAB			/ 	TAB
/D215	EITABC			/ GOLD:	TAB CENTER
	EIINTB			/ GOLD: TAB (INDENT TAB)		/A215
	EIFILE			/ GOLD:	FILE
	EIMENU			/ GOLD:	MENU
	EICONT			/ GOLD:	CONTINUE SEARCH & SELECT
	EIRBLN			/ GOLD:	RUB LINE
	EIRBSE			/ GOLD:	RUB SENTENCE
	EIDLTC			/ 	DELETE CHARACTER
	EIDLTW			/	DELETE WORD
	EIWORD			/	WORD
	EISENT			/	SENTENCE
	EILINE			/	LINE
	EITABP			/	TAB POSITION
	EIENTR			/	< > (ENTER KEY)
	EIPAGE			/	PAGE
	EIPARA			/	PARAGRAPH
	EIADVN			/	ADVANCE
	EIBKUP			/	BACK-UP
	EIGADV			/ GOLD:	ADVANCE
	EIGBKP			/ GOLD:	BACK-UP
	EIBOLD			/	BOLD
	EISLCT			/	SELECT
	EIUPPR			/	UPPER CASE
	EIUNDL			/	UNDERLINE
	EISCUT			/	CUT
	EISWAP			/	SWAP
	EIPSTE			/	PASTE
	EIUDLT			/ GOLD:	DELETE (EITHER CHARACTER OR WORD)
	EIUBLD			/ GOLD:	BOLD
	EILOWR			/ GOLD:	UPPERCASE
	EIUUDL			/ GOLD:	UNDERLINE
	EIHYPS			/ 	HYPHEN PUSH
	EIHYPL			/ GOLD:	HYPHEN PULL
	EIHYP1			/ GOLD:	PRINTING BREAK HYPHEN
	EIHYP2			/ GOLD:	INVISIBLE HYPHEN (SHIFT PRINT HYPHEN)
	EIDEAD			/ GOLD:	DEAD KEY
	EIDICT			/ GOLD:	ABBREVIATION
	EIGETC			/ GOLD:	LIBRARY
	EIDCMT			/ GOLD:	GET DOCUMENT
	EITOP			/ GOLD:	TOP DOCUMENT
	EIBOTM			/ GOLD:	BOTTOM DOCUMENT
	EIFIND			/ GOLD:	SEARCH
	EISRCH			/ GOLD:	CONTINUE SEARCH
	EINPAG			/ GOLD:	NEW PAGE
	EIPMRK			/ GOLD:	PAGE MARKER
	EIRULR			/ GOLD:	RULER
	EICENT			/ GOLD:	CENTER
	EIGCUT			/ GOLD:	CUT
	EIGPST			/ GOLD:	PASTE
	EIGPGE			/ GOLD:	PAGE
	EIREPL			/ GOLD:	REPLACE
	EISUBS			/ GOLD:	SUBSCRIPT
	EISUPS			/ GOLD:	SUPERSCRIPT
	EIVIEW			/ GOLD:	VIEW
	EITIME			/ GOLD:	DATE & TIME
	EITC			/	TECHNICAL CHARACTER
	EIHELP			/	HELP COMMAND KEY
	EIPRSC			/	PREV SCREEN
	EINXSC			/	NEXT SCREEN
	EIUPAR			/	UP ARROW
	EIDNAR			/	DOWN ARROW
	IFDEF	CONDOR	<						/M200

	IFDEF	LFTRGT  <
	EIRARO			/	RIGHT ARROW
	EILARO			/	LEFT ARROW
			>	/ END IFDEF LFTRGT

	IFNDEF	LFTRGT  <
	EIBAD
	EIBAD
			>	/ END IFNDEF LFTRGT

	EIGRAR			/ GOLD:	RIGHT ARROW
	EIGLAR			/ GOLD:	LEFT ARROW
			>	/ END IFDIF CONDOR

	EIRQSP			/ GOLD: SPACE (REQUIRED SPACE)

	IFDEF	CONDOR	<						/A205
	EICLKY			/ COLUMN CUT				/A205
			>	/ END IFDEF CONDOR			/A205
	EIINOV			/ INSERT-OVERSTRIKE			/A254

	
EDXVLN=	.-EDXVEC

/ THIS IS THE COPY ROUTINE, MODIFIED FOR CROSS-FIELD CALLS...
/ IT LENDS ITSELF TO BEING MOVED, BECAUSE THE CALL CONTAINS THE
/ APPROPRIATE CDF INSTRUCTIONS TO MAKE IT UNIVERSAL

XFCOPY,	XX			/ JMS COPY - -CNT - CDFA - A-1 - CDF B - B-1
	DCA	COPTMP
	TAD I	COPTMP
	DCA	T1		/ GET CNT
	TAD	COPTMP
	DCA	X0
	TAD I	X0
	DCA	COPY1		/ CDF A
	TAD I	X0
	DCA	X1		/ A
	TAD I	X0
	DCA	COPY2		/ CDF B
	TAD I	X0
	DCA	X2		/ B
	RDF
	TAD	CIDF0		/ CONSTANT FOR CDF-CIF INSTRUCTION
	DCA	COPXIT
COPY1,	.-.			/ CDF
	TAD I	X1
COPY2,	.-.			/ CDF
	DCA I	X2
	ISZ	T1
	JMP	COPY1
	CDFMYF
COPXIT,	.-.
	JMP I	X0		/ RETURN

COPTMP,	0			/ TEMP FOR COPY ROUTINE

/ ROUTINE CALLED FROM SCRLDN ROUTINE  IN THE EDITOR, IT IS USED AS
/FOLLOWS:
/
/IF MA=YES & IN MATH AREA
/   THEN IF IN CONTROL BLOCK
/	    THEN SET "MTHWRK" = FALSE
/                SET "INCTLB" = FALSE
/           ELSE RETURN
/           ENDIF
/   ELSE RETURN
/   ENDIF

SCRMTH,	XX
/D198;	IFDEF	UNBUND 	<
	JMS	HAVMTH		/ IF MATH FEATURE NO ACTIVATED
		JMP	SCREX	/    THEN JUST RETURN TO EDITOR
/D198;			>	/ END IFDEF UNBUND
	CDFEDT			/  YES: CHANGE TO EDITOR DATA FIELD
	TAD I	(PCTLFL)	/ GET IN CONTROL BLOCK FLAG
	CDFMYF			/ RETURN TO THIS DATA FIELD
	SMA CLA			/ ARE WE IN A CONTROL BLOCK?
	JMP	SCREX		/  NO:  JUST RETURN
	JMS	SCRINI		/  YES: GO SHUT MATH DOWN
SCREX,	CDIEDT			/ RETURN TO SCROLL DOWN ROUTINE
	JMP I	SCRMTH		/ RETURN TO CALLER IN "SCRLDN"


/D198;	IFDEF	UNBUND 	<
/ This routine does a skip return if the math feature is activated and
/ a regular return if not
HAVMTH,	XX
	CDFMNU			/ SET TO MENU DATA FIELD
	TAD I	(MUBUF+MNOPTC)	/ GET ACTIVE FEATURES CONTROL WORD
	CDFMYF			/ RETURN TO DATA THIS FIELD
	AND	(MABIT)		/ GET ACTIVATED MATH FEATURES CONTROL WORD
	SZA CLA			/ IF THE MATH FEATURE IS ACTIVATED
	ISZ	HAVMTH		/ THEN BUMP THE RETURN ADDRESS
	JMP I	HAVMTH		/ RETURN TO CALLER
/D198;			>	/ END IFDEF UNBUND
	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

DSKBLK=.-6400%400+DL3EDT	/ DISK BLOCK WHERE PAGE IS LOADED



/ THIS ROUTINE WILL EITHER SET OR CLEAR 132 COLUMN MODE
/ MUST BE CALLED WITH "l-"h IN AC TO CLEAR OR 0 IN AC TO SET
/ DATA AND INSTRUCTION FIELD MUST BE SET TO LP FIELD (CDILP) AND IT
/ ALWAYS RETURNS WITH DATA FIELD IN EDITOR FIELD
/ CAN ONLY BE CALLED FOR EDITOR FIELD

LP132,	XX
	TAD	("H+40)		/ SET UP TO EITHER SET OR CLEAR
	DCA	SETCLR		/ 132 COLUMN MODE
IFNDEF ITALIAN <
	TAD	SETCLR		/ See if same as last time.
	CIA			/  ...
	TAD	SETSAV		/   ....
	SNA CLA			/ skip if not the same. we must do it.
	JMP	LPXIT		/ same, so exit.
	>
	TAD	SETCLR		/ Get new value.
	DCA	SETSAV		/ save it for next check.
	CIFMNU
	JMS I	IOACAL		/ CALL I/O ROUTINE
	0			/ USE DEFAULT OUTPUT ROUTINE
	MSG132			/ ADDRESS OF TEXT STRING TO OUTPUT
	S132MS			/ ADDRESS OF STRING ARGUMENT

LPXIT,	CDIEDT			/ SET BACK TO EDITOR FIELD
	JMP I	LP132		/ RETURN

/MSG132,	TEXT "^A"	/ !A MEANS USE FOLLOWING ARGUMENT AS ADDRESS
				/ OF ASCII STRING TO OUTPUT
S132MS,	ESC			/ esc
	"[			/ [
	"?			/ ?
	"3			/ 3
SETCLR,	0			/ h TO SET OR l TO CLEAR
	ESC			/ ESC
	"[			/ [
	"?			/ ?
	"1			/ 1
	"H+40			/ h
	0			/ END OF ESCAPE SEQUENCE

SETSAV,	"L+40			/ we start out in 80 col mode.

/ PUTLP		Routine moved this edit to gather space here		/a247

/ ROUTINE TO OUTPUT A MESSAGE TO THE SCREEN, ADDRESS OF MESSAGE IS
/ IN AC ON ENTRY
/d247	PUTLP,	XX
/d247		DCA	PTLP1		/ SET UP ADDRESS
/d247		CIFMNU
/d247		JMS I	IOACAL		/ CALL I/O ROUTINE
/d247		0			/ USE DEFAULT OUTPUT ROUTINE
/d247	PTLP1,	XX			/ ADDRESS OF TEXT STRING TO OUTPUT
/d247		CDIEDT			/ SET BACK TO EDITOR FIELD
/d247		JMP I	PUTLP		/ RETURN

				/ USE IOA !& CALL TO CAPITILIAZE WORDS
STXMSG,
IFDEF ENGLSH < TEXT " !&TOP " >
IFDEF V30NOR < TEXT " !&TOPP " >
IFDEF V30SWE < TEXT " !&B\VRJAN " >
IFDEF SPANISH < TEXT "&SUPERIOR" >					/A255
IFDEF ITALIAN < TEXT "!&INIZIO" >
IFDEF FRENCH < TEXT " &HAUT " >
IFDEF GERMAN < TEXT " &ANFANG " >
IFDEF DUTCH  < TEXT " &BEGIN " >
IFDEF CANADA < TEXT " &HAUT " >
IFDEF NORWAY < TEXT " &TOPP " >
IFDEF SWEDSH < TEXT " &TOPP " >
IFDEF DANISH < TEXT " &TOP " >

PGMSG1,
IFDEF ENGLSH < TEXT " !&NEW !&PAGE " >
IFDEF V30NOR < TEXT " !&NY !&SIDE " >
IFDEF V30SWE < TEXT " !&NY !&SIDA " >
IFDEF SPANISH < TEXT "&P\AGINA &NUEVA" >					/A255
IFDEF ITALIAN < TEXT "!&NUOVA !&PAGINA" >
IFDEF CANADA < TEXT " &NOUV. &PAGE " >
IFDEF FRENCH < TEXT " &NOUV. &PAGE " >
IFDEF GERMAN < TEXT " &NEUE &SEITE " >
IFDEF DUTCH  < TEXT " &NIEUWE &PAGINA " >
IFDEF NORWAY < TEXT " &NY &SIDE " >
IFDEF SWEDSH < TEXT " &NY &SIDA " >
IFDEF DANISH < TEXT " &NY &SIDE " >

PGMSG2,
IFDEF ENGLSH < TEXT " !&PAGE !&MARKER " >
IFDEF V30NOR < TEXT " !&SIDEMERKE " >
IFDEF V30SWE < TEXT " !&SIDMARKERING " >
IFDEF SPANISH < TEXT "&MARCADOR DE &P\AGIN" >			/A255
IFDEF ITALIAN < TEXT "!&INDICATORE !&PAGINA" >
IFDEF CANADA < TEXT " &CHANG. &PAGE ">
IFDEF FRENCH < TEXT " &CHGT &PAGE " >
IFDEF GERMAN < TEXT " &SEITEN &MARKE " >
IFDEF DUTCH  < TEXT " &PAGINA-&MARKERING ">
IFDEF NORWAY < TEXT " &SIDEMARKERING " >
IFDEF SWEDSH < TEXT " &SIDMARKERING " >
IFDEF DANISH < TEXT " &SIDEMARKERING " >

PGMSG3,
IFDEF ENGLSH < TEXT " !&START !&CONTROL " >
IFDEF V30NOR < TEXT " !&KONTROLL !&BEGYNN " >
IFDEF V30SWE < TEXT " &START KONTROLL" >
IFDEF SPANISH < TEXT "&INICIO &CONTROL" >				/A255
IFDEF ITALIAN < TEXT "!&INIZIO !&CONTROLLO" >
IFDEF CANADA < TEXT " &CMDE &DEBUT &IMPRESSION " >
IFDEF FRENCH < TEXT " &CDE &DEBUT &IMPRESSION " >
IFDEF GERMAN < TEXT " &START &DRUCKAUSGABE " >
IFDEF DUTCH  < TEXT " !&BEGIN !&OPDRACHT " >
IFDEF NORWAY < TEXT " &START &UTSKRIFTSKONTROLL " >
IFDEF SWEDSH < TEXT " &START &UTSKRIFTSKONTROLL " >
IFDEF DANISH < TEXT " &START &UDSKRIFTSKONTROL " >

PGMSG4,
IFDEF ENGLSH < TEXT " !&END   !&CONTROL " >
IFDEF V30NOR < TEXT " !&KONTROLL !&SLUTT  " >
IFDEF V30SWE < TEXT " &SLUTT  KONTROLL  " >
IFDEF SPANISH < TEXT "&FIN &CONTROL" >				/A255
IFDEF ITALIAN < TEXT "!&FINE !&CONTROLLO" >
IFDEF CANADA < TEXT " &CMDE &FIN &IMPRESSION " >
IFDEF FRENCH < TEXT " &CDE &FIN &IMPRESSION " >
IFDEF GERMAN < TEXT " &ENDE &DRUCKAUSGABE " >
IFDEF DUTCH  < TEXT " !&EINDE !&OPDRACHT " >
IFDEF NORWAY < TEXT " &SLUTT &UTSKRIFTSKONTROLL " >
IFDEF SWEDSH < TEXT " &SLUT &UTSKRIFTSKONTROLL " >
IFDEF DANISH < TEXT " &SLUT &UDSKRIFTSKONTROL " >

MSGF,
IFDEF ENGLSH < TEXT "--!&DOCUMENT !&FILING !&BEING !&COMPLETED--" >
IFDEF V30NOR < TEXT "--!&DOKUMENT !&ARKIVERES--" >
IFDEF V30SWE < TEXT "--&AVSLUTA--" >
IFDEF SPANISH < 
  TEXT "--&SE &HA &COMPLETADO &EL &ARCHIVO &DEL &DOC.--" >	/A255
IFDEF ITALIAN < TEXT "--!&ARCHIVIAZIONE !&DOCUMENTO !&IN !&CORSO--" >
IFDEF CANADA < TEXT "--&CLASSEMENT &DU &DOCUMENT &EN &COURS--" >
IFDEF FRENCH < TEXT "--&CLASSEMENT &DU &DOCUMENT--" >
IFDEF DUTCH  < TEXT "--!&DOCUMENT !&WORDT !&OPGESLAGEN--" >
IFDEF GERMAN < TEXT "--&DATEI &WIRD &ARCHIVIERT--" >
IFDEF NORWAY < TEXT "-- &DOKUMENTET &LAGRES --" >
IFDEF SWEDSH < TEXT "-- &DOKUMENTET &LAGRAS --" >
IFDEF DANISH < TEXT "-- &DOKUMENT &LAGRES --" >


/****************************************************************************
/ SVNTO8	SeVeN TO eight bit routine.  Takes characters from the	/a247
/		edit buffer using READNEXTCHARACTER and checks for dead	/a247
/		key sequences representing multinational characters.	/a247
/		These it converts to eight bits.			/a247
/****************************************************************************

SVNTO8,	XX			/ Start of SeVeN TO eight bit convertion/a247
	JMS	READNEXTCHAR	/ Read the next character from the buf	/a247
	JMP	EREXIT		/ If ETX found, exit			/a247
	TAD	DEADKEY		/ Check for dead key sequence introducer/a247
	SNA CLA			/ Is this a dead key we are reading?	/a247
	JMP	NOT8		/ No, just do non-error skip return	/a247
	JMS	READNEXTCHAR	/ Read the next character from the buf	/a247
	JMP	EREXIT		/ If ETX found, exit			/a247
	TAD	CRLMB		/ Get the char without mode bits	/a247
	TAD	(-ECSPC)	/ Test for multinational identifier	/a247
	SZA CLA			/ Is this a space?			/a247
	JMP	NO8NXC		/ No, therefore skip user dead key	/a247
	JMS	READNEXTCHAR	/ Read the next character from the buf	/a247
	JMP	EREXIT		/ If ETX found, exit			/a247
	JMS	READNEXTCHAR	/ Read the next character from the buf	/a247
	JMP	EREXIT		/ If ETX found, exit			/a247
	TAD	CRLMB		/ Get the seven bit representation	/a247
	TAD	(200)		/ Add the eigth bit			/a247
	DCA	CRLMB		/ Restore the character			/a247
NO8NXC,	JMS	ADUNIT		/ Advance a character without reseting	/a247
				/ CRLMB					/a247
	JMP	EREXIT		/ If ETX, exit				/a247
	TAD	(-ECNDOV)	/ Check for the end of the dead key	/a247
	SZA CLA			/ Is the current character an End Dead?	/a247
	JMP	NO8NXC		/ No, get the next character		/a247
NOT8,	DCA	DEADKEY		/ Zero the dead key flag		/a247
	ISZ	SVNTO8		/ Skip return if ETX not encountered	/a247
EREXIT,	JMP I	SVNTO8		/ Return				/a247

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	RELOC
	RELOC	200		/ CODE EXECUTED AT LOCATION 200 IN FIELD 5

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/ This space is reserved for editor math or any other editor code
/  that is GUARENTEED NOT TO BE USED WHILE IN LIST PROCESSING
/  It is loaded into field five (CDFLP) by the editor overlay which
/  initializes for a normal edit session (as opposed to using the
/  editor for list processing.
/ There are 12 pages of code available here. It is limited only by
/  the location of the BCDASC routine which currently resides at 5400
/  therefor this space can be expanded. To change the amount of of code
/  assembled here (hence the number of blocks allocated on the system
/  diskette to hold the code) it is only necessary to change the value
/  of DS4EDT in WPDL.PA.   This constant is equal to the number of
/  blocks of code (2 pages per block)

/ THE FOLLOWING TABLES ARE USED IN CONJUNCTION WITH THE ":Dnn" and ":Tnn"
/ SYMBOLS WHICH CAN BE ENTERED INTO THE SYMBOL TABLE WHILE IN EDITOR MATH
/ THERE IS A ":Dnn" TABLE - "DCHAR", AND A ":Tnn" TABLE - "TCHAR"
/ THE ENTRY OF THESE SYMBOL NAMES IN THE SYMBOL TABLE IS JOINED BY A
/ COINCIDENTAL ENTRY OF THE POINTER TO THAT SYMBOL NAME VALUE ( IN THE
/ SYMBOL TABLE) BEING PUT IN THE APPROPRIATE TABLE HERE.
/ BOTH DCHAR AND TCHAR AS WELL AS THEIR LENGTHS ARE DEFINED IN WPF1!

DCHAR,	ZBLOCK DCHARL
TCHAR,	ZBLOCK TCHARL

/ CALLED FROM "CKCTRL" RTN CHECKS IF MATH CTRL BLOCK ERR PASSED BACK FROM
/ MATH MODULE WAS ENCOUNTERED WHILE IN EDITOR MATH WORK AREA. IF IT WAS
/ NOT THEN THE LINE IS IGNORED, IF IT WAS THEN THE ERROR IS REPORTED AS
/ AS AN EDITOR MATH ERROR

EDERR1,	MQL			/ HOLD ERROR NUMBER
	CDFMTH			/ CHANGE TO  MATH DATA FIELD
	TAD I	(MTHWRK)	/ GET "EDITOR MATH WORK AREA" FLAG
	CDFLP			/ RETURN TO LP DATA FIELD
	SZA CLA			/ ARE WE IN AN EDITOR MATH WORK AREA?
	JMP	BKDTX1		/  NO: IGNORE LINE, REINIT & RETURN TO EDIT
	JMS	SCRINI		/  YES: RE-INIT TO SHUT EDITOR MATH DOWN BECAUSE
				/   AN ERROR WAS ENCOUNTERED IN A MATH CTRL BLOCK
	MQA			/ RESTORE ERROR NUMBER TO AC
	JMS	RESCURPTR	/ RESTORE CURPTR
	JMP	EDERR		/ GO TO ERROR CODE TO REPORT ERROR


/ CODE TO RUN CHECK ON PRESENT EDIT MATH CONTROL BLOCK STATUS, CALLED
/ AS PART OF IN-LINE CODE FROM "CKCTRL"

CKCTR6,	TAD	INCTLB		/ GET "IN CTRL BLOCK" FLAG
	SZA CLA			/ ARE WE ALREADY IN A BLOCK?
	JMP	CKCTR2		/  NO: SEE IF JUST STARTING BLOCK
	TAD	MTHCTL		/  YES: GET "IN MATH CTRL BLOCK" FLAG
	SZA CLA			/ ARE WE IN A MATH CTRL BLOCK?
	JMP	SCRLLN		/  YES: THEN GO PROCESS LINE
	CDFMTH			/  NO: THEN CHANGE TO MATH DATA FIELD
	TAD I	(MTHWRK)	/ GET "EDIT MATH WORK AREA" FLAG
	CDFLP			/ RETURN TO LP DATA FIELD
	SNA CLA			/ ARE WE IN EDITOR MATH WORK AREA?
	JMP	CKCTRZ		/  YES: GO SEE IF STILL IN BLOCK
	CDFMTH			/  NO: THEN CHANGE TO MATH DATA FIELD
	TAD I	(MTHSND)	/ GET EDITOR MATH "SECOND LINE" FLAG
	CDFLP			/ RETURN TO LP DATA FIELD
	SZA CLA			/ IS THE SECOND LINE NEXT TO BE PROCESSED?
	JMP	CKCTRZ		/  NO: GO SEE IF STILL IN BLOCK
	JMP	SCRLLN		/  YES: GO PROCESS LINE

CKCTRZ,	JMS	READNEXTCHARACTER	/ GET 1ST CHAR ON THE LINE
	NOP			/ ETX RETURN, SHOULD NEVER HIT HERE
	TAD	CRWMB		/ PUT CHAR WITH MODE BITS INTO AC
	TAD	(-ECPCT2)	/ ADD NEGATIVE OF "END CONTROL BLOCK" CHAR
	SNA CLA			/ REACHED THE END OF THE NON-MATH CONTROL BLOCK?
	JMP	BKEDT1		/  YES: SET "INCTLB"=FALSE & RTRN TO EDITOR
	JMP	BKEDI3		/  NO : IGNORE LINE CAUSE NOT EDIT MATH

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/ EXTRACTNUMBER ROUTINE ALONG WITH ALL ASSOCIATED SUBROUTIINES ARE
/  CLASSIFIED AS IN EDIT HISTORY!!
/
/++
/		EXTRACTNUMBER	EXTRACT_NUMBER
/
/ FUNTIONAL DESCRIPTION:	EXTRACTNUMBER
/
/ EXTRACT_NUMBER ROUTINE PERFORMS THE EXTRACTION OF NUMBERS FROM A LINE
/ OF TEXT WITHIN A DOCUMENT FOR THE PURPOSE OF PERFORMING EDITOR MATH.
/ IT ALSO CALLS MATH EXECUTION AND MATH INSERT_DELETE ROUTINES AS NEEDED.
/
/ CALLING SEQUENCE:	JMP	EXTRACTNUMBER
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	GLOBAL: MTHWRK, NWDT, MTHTOT, CURPTR, LNEPC, TABFLAGS,
/				TABPOSITION, CRLMB, CRWMB, DTABCOUNT, T1
/			LOCAL:	SEIRF
/
/ OUTPUT PARAMETERS:	NONE
/
/ IMPLICIT OUTPUT:	GLOBAL:	DTABCOUNT, LNEPC, CURPTR, T1, LTABPOSITION,
/				CRWMB
/			LOCAL:	SEIRF, EXTRA4
/
/ COMPLETION CODE:	AC = 0
/
/ SIDE EFFECTS:		1) IF INSDEL (INSERT_DELETE) ROUTINE IS NOT CALLED
/			    CURPTR IS SET TO VALUE IT WAS ON ENTRY TO
/			    EXTRACTNUMBER ROUTINE.
/
/--

EXTRACTNUMBER,
	CDFMTH			/ ARE WE IN A MATH_WORK AREA?
	TAD I	(MTHWRK)
	SZA CLA			/ SKIP IF: SO
	JMP	BKEDI3		/ RETURN TO EDITOR - DON'T DO MATH
	CDFEDT			/ DOES CURRENT RULER CONTAIN DECIMAL TABS?
	TAD I	(CURUL+NWDT-NWRUL)
	SNA CLA			/ SKIP IF: SO
	JMP	BKEDI4		/ RETURN TO EDITOR - DON'T DO MATH

/ CHECK FOR PROPER LINE TERMINATION BEFORE DOING MATH.  IF LINE IS NOT
/  TERMINATED BY HARD RETURN OR CHARACTERS EXCEED RIGHT MARGIN THEN DO
/  NOT PERFORM MATH ON THIS LINE!!

	TAD I	(CURUL+NWRMAR-NWRUL) / SET LNEPC = -(RIGHT_MARGIN + 1)
	CDFMYF
EXTR15,	CMA			/ ALSO USED SET LNEPC = -1 FROM BELOW
	DCA	LNEPC		/ SAVE IT
EXTRA6,	JMS	READNEXTCHAR	/ READ A CHARACTER
	JMP	BKEDI4		/ ETX RETURN - SHOULD NEVER READ
	TAD	CRLMB		/ GET CHARACTER READ
	TAD	(-ECNWLN)	/ CHAR. = LINE_ENDING CHARACTER?
	SNA CLA			/ SKIP IF: NOT
	JMP	EXTR14		/ CHECK FOR SPECIAL LINE_END CHAR.
	ISZ	LNEPC		/ BUMP -RIGHT_MARGIN COUNT
	JMP	EXTRA6		/ HAVE NOT EXCEEDED RIGHT MARGIN!
	TAD	CRLMB		/ CHECK FOR SPACES BEYOND RIGHT MAR.
	TAD	(-ECSPC)
	SNA CLA			/ SKIP IF: NOT A SPACE
	JMP	EXTR15		/ RESET LNEPC = -1 AND CONTINUE
	JMP	BKEDI4		/ RIGHT_MARGIN LIMIT EXCEEDED!!
				/  RETURN TO EDITOR.
EXTR14,	TAD	CRWMB		/ CHAR. = SPECIAL_LINE_ENDING?
				/  (I.E.:WRAPPED_LINE,PARA._MARK...ETC.)
	AND	(3000)
	SZA CLA			/ SKIP IF: NOT - LINE OK TO PROCESS!
	JMP	BKEDI4		/ SKIP LINE: RTRN TO EDIT. RESTORE
 				/ "TOTAL" FLAG & CURPTR ON THE WAY
	JMS	RESCURPTR	/ RESTORE OLD CURPTR
	AC7777			/ RESET CURPTR TO PROCESS MATH LINE
	JMS	STCURPTR


	DCA	DTABCOUNT	/ INITIALIZE DECIMAL_TAB_COUNT

	CDFMTH			/ CHECK IF IN MATH TOTAL AREA
	TAD I	(MTHTOT)
	CDFMYF
	SZA CLA			/ SKIP IF: NOT
	JMP	EXTRA7

	JMS	IDCST		/ INITIALIZE_DECIMAL_CHARACTER_SYMBOL_TABLE


	AC0001			/ INITIALIZE SKIP_EXECUTION_AND_
				/  INSERTION_ROUTINE_FLAG = TRUE
	DCA	SEIRF
	DCA	LTABPOSITION	/ INITIALIZE LAST_TAB_POSITION
	AC7777			/ INIT. LINE_POSITION_COUNTER = LEFT_-
				/  MARGIN - 1
	DCA	LNEPC

EXTRA1,	DCA	CRWMB		/ INITIALIZE CHARACTER_READ_WITH_MODE_BITS

EXTRA2,	JMS	READTABORLINEEND/ READ_TAB_OR_LINE_END
	JMP	EXTRA9		/ END_OF_LINE , ETX

	TAD	TABFLAGS	/ IS TAB TYPE = DECIMAL ALIGN TAB?
	SNA CLA			/ SKIP IF: SO
	JMP	EXTRA3


	TAD	DTABCOUNT	/ ADD DECIMAL_TAB_COUNT + DCHAR
	TAD	(DCHAR)		/ CHECK TO SEE IF THERES A MATCH IN
	DCA	T1		/  DCHAR TABLE FOR THIS POSITION OF THE
	TAD I	T1		/  DECIMAL TAB. IF THERE IS IT MEANS
				/  FIELD NEEDED FOR MATH COMPUTATIONS.
	SNA			/ SKIP IF: FIELD NEEDED FOR MATH COMPUTATIONS
	JMP	EXTRA1		/ NO MATCH - CLEAR CRWMB BEFORE READ NEXT CHAR.
	DCA	EXTRA4		/ SAVE POINTER INTO SYMBOL TABLE

	JMS	GETDTF		/ JMS GET_DECIMAL_TAB_FIELD
	JMP	EXTRA2		/ UNDEFINED FIELD RETURN

/ CONVERT ASCII STRING TO BCD NUMBER
EXTRA5,	CIFMTH
	JMS	ASCBCD		/ CALL ASCBCD ROUTINE
		ENASBF		/ ADDRESS OF ASCII STRING TO BE CONVERTED
EXTRA4,		.-.		/ ADDRESS IN SYMBOL TABLE WHERE BCD
				/  NUMBER WILL BE PLACED
	SKP			/ ASCBCD ERROR RETURN (AC = ERROR NUMBER)
	JMP	EXTR11		/ NO ERROR - KEEP ON TRUCKIN!!

/ CHECK IF ERROR CAUSED BY "*UN.DEF*" OR "*OVR.FLO*" STRING BEING SUBMITTED
/  TO ASCBCD ROUTINE.  IF SO THEN SET SKIP_EXECUTION_AND_INSERTION_ROUTINE_FLAG
/  = FALSE AND LABEL FIELD AS UNDEFINED IN SYMBOL TABLE (EXTR13).

	CLA CLL
	JMS	CSNF		/ SEE IF FIELD THAT CAUSED ERROR WAS EITHER
				/  "*UN.DEF*" OR "*OVR.FLO*" STRING
	JMP	EXERR1		/ ERROR NOT CAUSED BY EITHER "*UN.DEF*"
				/  OR "*OVR.FLO*" STRING SO REPORT IT!
EXTR11,	DCA	SEIRF		/ SET SKIP_EXECUTION_AND_INSERTION_
				/  ROUTINE_FLAG = FALSE
	JMP	EXTRA2		/ GET NEXT DECIMAL FIELD

/ POSITION CURPTR TO CHARACTER - 1 POSITION OF RULER TAB SETTING
EXTRA3,	TAD	TABPOSITION
	CIA
	TAD	LNEPC
	DCA	TCCNTR		/ SAVE RESULT IN TEMPORARY_CHARACTER_COUNTER
EXTR10,	ISZ	TCCNTR		/ INCREMENT COUNTER
	SKP			/ COUNT NOT YET EXHAUSTED - KEEP GOING
	JMP	EXTRA1		/ CURPTR NOW REPOSITIONED
	ISZ	LNEPC		/ INCREMENT LINE POSITION COUNTER
	JMS	READNEXTCHARACTER
	NOP			/ ETX RETURN - SHOULD NEVER SEE ETX!!
	JMP	EXTR10

EXTRA9,	TAD	SEIRF		/ CHECK SKIP_EXECUTION_AND_INSERTION_-
				/  ROUTINE_FLAG
	SZA CLA			/ SKIP IF: FALSE
	JMP	BKEDI3		/ BACK TO EDITOR, RESTORE CURPTR ON WAY

EXTRA8,	CIFMTH
	JMS	EXECUTION	/ DO MATH EXECUTION ROUTINE
	SZA			/ WAS AN ERROR RETURNED FROM THE EXECUTION CODE?
	JMP	EDERR		/  YES: GO PASS ERROR # TO ERROR REPORTING RTN
	TAD	(DCHAR-TCHAR)	/ NO: SET AC = DCHAR FOR CALL TO INSERTION

EXTRA7,	TAD	(TCHAR)		/ SET AC = TCHAR FOR CALL TO INSERTION
	JMS	INSDEL		/ DO MATH INSERTION_DELETION ROUTINE
EXTR13,	CLA CLL
	CDFMTH
	DCA I	(MTHTOT)	/ CLEAR MTHTOT FLAG
				/ DIDN'T BOTHER TO ADJUST FIELD HERE
				/  SINCE BKEDIT DOES FIELD ADJUSTMENTS
	JMP	BKEDIT


SEIRF,		.-.		/ SKIP_EXECUTION_AND_INSERTION_ROUTINE_FLAG
				/  0 = DON'T SKIP
				/  1 = SKIP
DTABCOUNT,	.-.		/ COUNT OF DECIMAL_TABS

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED



/++
/		INITIALIZE_DCHAR_SYMBOL_TABLE
/
/ FUNTIONAL DESCRIPTION:	IDCST
/
/	USING THE DCHAR TABLE ENTRYS AS POINTERS INTO THE MATH SYMBOL TABLE
/	INITIALIZE EACH SYMBOL TABLE FIELD TO UNDEFINED.
/
/ CALLING SEQUENCE:	JMS	IDCST
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	T3, X5
/
/ OUTPUT PARAMETERS:	AC = 0
/
/ IMPLICIT OUTPUT:	X5, T3, T2
/
/ COMPLETION CODE:	NONE
/ SIDE EFFECTS:		NONE
/
/--
/
IDCST,	XX			/ INITIALIZE_DECIMAL_CHARACTER_SYMBOL_TABLE
	TAD	(DCHAR-1)	/ GET STARTING ADDRESS OF DCHAR TABLE - 1
	DCA	X5		/ STORE IT
	TAD	(-DCHARL)	/ SET COUNTER = -DCHARL - 1		/C236
/D236	CMA
	DCA	T3		/ SAVE RESULT FOR COUNTER

IDCST1,	TAD I	X5		/ GET NEXT DCHAR TABLE ENTRY		/C236
	SNA			/ SKIP IF: CONTAINS POINTER INTO SYM. TABLE
	JMP	IDCST2		/ NO POINTER - GO TO NEXT ENTRY		/C236
	DCA	T2		/ SAVE POINTER INTO SYM. TABLE

	AC2000			/ SET UNDEF FLAG IN FIRST LOCATION
	CDFMTH
	DCA I	T2
	CDFMYF			/ DONE
/D236	JMP	IDCST1

IDCST2,	ISZ	T3		/ PAST END OF DCHAR TABLE?
/D236	SKP			/ NO
	JMP	IDCST1		/ NO - INIT. FOR NEXT DCHAR TABLE ENTRY
	JMP I	IDCST		/ YES - INIT COMPLETE SO RETURN		/C236


/++
/		GET_DECIMAL_TAB_FIELD
/
/ FUNTIONAL DESCRIPTION:	GETDTF
/
/	REMOVE A FIELD OF TEXT THAT HAS BEEN TABBED TO A DECIMAL TAB
/	RULER SETTING WITHIN A DOCUMENT, CHECKING FOR PROPER ALIGNMENT TO
/	THE DECIMAL TAB RULER SETTING AS FIELD IS READ.
/
/ CALLING SEQUENCE:	JMS	GETDTF
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	GLOBAL:	TABPOSITION, LNEPC, TABFLAGS, CRLMB, SAVTP
/			LOCAL:	GETD11, DFDONEF, FLDNE
/
/ OUTPUT PARAMETERS:	AC = 0
/
/ IMPLICIT OUTPUT:	GLOBAL:	LNEPC, SAVTP
/			LOCAL:	FLDNE, DFDONEF, GETDT1, GETD11, GETDTF
/
/ COMPLETION CODE:	1) RETURN CALLER+1 IF EMPTY FIELD
/			   RETURN CALLER+2 IF FIELD NOT EMPTY AND ALIGNED
/			    TO THE DECIMAL TAB SETTING.
/
/ SIDE EFFECTS:		1) IF AN ERROR CONDITION OCCURS THEN EXIT GETDTF
/			    VIA ERROR HANDLER.
/
/--
/
ENASBF=	TOKVAL			/ EXTRACT_NUMBER_ASCII_STRING_BUFFER
ENASBS=	MAXTOK			/ EXTRACT_NUMBER_ASCII_STRING_BUFFER_SIZE

GETDTF,	XX
	DCA	FLDNE		/ INITIALIZE FIELD_NOT_EMPTY_FLAG = FALSE
	DCA	DFDONEF		/ INITIALIZE DECIMAL_FIELD_DONE_FLAG = FALSE
	TAD	(ENASBF-1)	/ INITIALIZE POINTER TO EXTRACT_NUMBER_ASCII_-
				/  STRING_BUFFER
	DCA	GETDT1
	TAD	(ENASBS)	/ INITIALIZE COUNTER FOR OUTPUT BUFFER
	CIA
	DCA	GETDT2
	TAD	TABPOSITION	/ SET SAVED_TAB_POSITON = TAB_POSITION - 1
	DCA	SAVTP

GETDT3,	ISZ	LNEPC		/ INCREMENT LINE POSITION COUNTER
	JMS	SVNTO8		/					/m247
	JMP	GETDT9		/ ETX RETURN

	TAD	SAVTP		/ SET FLAG TO SHOW LINE_POINTER_COUNTER
				/  RELATIVE POSITION TO SAVED_TAB_POSITION
	CIA
	TAD	LNEPC		/ IF RESULT < 0	- PRE_TAB
				/	    = 0 - AT TAB
				/ "	"   > 0 - POST_TAB
	DCA	GETD11		/ SAVE RESULT IN TEMP.

	TAD	GETD11		/ LINE_POSITION_COUNTER => SAVED_TABPOSITION?
	SPA CLA			/ SKIP IF: SO
	JMP	GETDT8		/ LINE_POSITION_COUNTER < SAVED_TABPOSITION

	AC7777			/ CALL FINDTP TO SEARCH FOR TAB FROM
				/  CURRENT LINE POSITION - 1
	JMS	FINDTP		/ FIND_TAB_POSITION
		LNEPC

	AC4000			/ IS LINE_POSITION AT DECIMAL TAB RULER
				/  SETTING?
	AND	TABFLAGS
	SZA CLA			/ SKIP IF: NOT
	JMS	IDTABCOUNT	/ INCREMENT DECIMAL_TAB_COUNT

GETDT8,	TAD	CRLMB		/ GET CHARACTER_READ_LESS_MODE_BITS
	TAD	(-41)		/ SPECIAL CHARACTER?
	SMA			/ SKIP IF:SO
	JMP	GETDT4
	TAD	(41-ECSTOV)	/ CHARACTER_READ_LESS_MODE_BITS = START_-
				/  DEAD_KEY SEQUENCE?
	SNA			/ SKIP IF: NOT
	JMP	GETDT4
	TAD	(ECSTOV-ECTAB)	/ CHARACTER_READ_LESS_MODE_BITS = TAB?
	SZA			/ SKIP IF: SO
	TAD	(ECTAB-ECNWLN)	/ CHARACTER_READ_LESS_MODE_BITS = LINE_-
				/  ENDING CHARACTER?
	SNA			/ SKIP IF: NOT
	JMP	GETDT9		/ SET DECIMAL_FIELD_DONE_FLAG = TRUE
GETDT7,	TAD	(ECNWLN-ECSPC)	/ CHARACTER_READ_LESS_MODE_BITS = SPACE?
	SZA CLA			/ SKIP IF: SO
	JMP	GETDT3		/ IGNORE AND GET NEXT CHARACTER
	TAD	GETD11		/ ARE WE POSITIONED AT TAB?
	SNA			/ SKIP IF: NOT
	JMP	EXERR1		/ *** ERROR *** SPACE AT TAB POSITION
	SMA CLA			/ SKIP IF: POSITIONED PRE_TAB
	JMP	GETDT9		/ MUST BE POSITIONED POST_TAB
	TAD	FLDNE		/ IS THIS A LEADING SPACE?
	SNA CLA			/ SKIP IF: NOT
	JMP	GETDT3		/ IGNORE IT
	JMP	GETDT6

/d247	GETD12,	ISZ	DFDONEF		/ SET DECIMAL_FIELD_DONE_FLAG = TRUE
/d247		JMP	GETDT6

GETDT4,	TAD	(41-")+200)	/ IS CHARACTER = ")"?
	SZA			/ SKIP IF: SO
/D251	TAD	(")-".)		/ IS CHARACTER = "."?
	TAD	RADCHR		/ IS CHARACTER = RADIX POINT		/A251
	SNA CLA			/ SKIP IF: NOT
	JMP	GETD13		/ DON'T CHECK IF LEGAL CHAR. AT TAB_POSITION
	TAD	GETD11		/ LINE_POSITION_COUNTER = SAVED_TAB POSITION?
	SNA CLA			/ SKIP IF: NOT
	JMP	EXERR1		/ *** ERROR *** ILLEGAL CHAR. AT DTP

GETD13,	ISZ	FLDNE		/ SET FIELD_NOT_EMPTY_FLAG = TRUE
GETDT6,	
/d247	CLA
	ISZ	GETDT2		/ BUMP OUTPUT_BUFFER_COUNTER
	SKP			/ ROOM IN OUTPUT_BUFFER FOR CHARACTER.
GETDT9,	ISZ	DFDONEF		/ SET DECIMAL_FIELD_DONE_FLAG = TRUE
	ISZ	GETDT1		/ INCREMENT OUTPUT_BUFFER_POINTER
	TAD	DFDONEF		/ DECIMAL_FIELD_DONE_FLAG = TRUE ?
	SNA CLA			/ SKIP IF: SO
	TAD	CRLMB		/ PUT CHARACTER INTO OUTPUT_BUFFER
	CDFMTH
	DCA I	GETDT1
	CDFMYF
	TAD	DFDONEF		/ DECIMAL_FIELD_DONE_FLAG = TRUE ?
	SNA CLA			/ SKIP IF: SO
	JMP	GETDT3		/ BACK FOR THE NEXT CHARACTER

	TAD	FLDNE		/ CHECK FIELD_NOT_EMPTY_FLAG
	SZA CLA			/ SKIP IF: TRUE
	ISZ	GETDTF		/ BUMP RETURN

GETDT5,	JMP I	GETDTF		/ RETURN

GETDT1,	.-.			/ TEMP. - HOLDS POINTER INTO OUTPUT BUFFER
GETDT2,	.-.			/ TEMP. - HOLDS COUNTER FOR OUTPUT BUFFER
GETD11,	.-.			/ TEMP. - HOLDS RELATIVE LINE POSITION
				/	   INDICATOR
FLDNE,	.-.			/ FIELD_NOT_EMPTY_FLAG
				/  0: FIELD EMPTY
				/  1: FIELD CONTAINS VALID CHARACTERS
DFDONEF,			/ DECIMAL_FIELD_DONE_FLAG
	.-.			/  0: NOT FINISHED READING DECIMAL FIELD
				/  1: FINISHED READING DECIMAL FIELD
RADCHR,									/A251
	IFDEF PERDEC<							/A251
	")-".			/ RADIX = .				/A251
	>								/A251
	IFDEF COLDEC<							/A251
	")-":			/ RADIX = :				/A251
	>								/A251
	IFDEF COMDEC<							/A251
	")-",			/ RADIX = ,				/A251
	>								/A251

/ EXERR1	moved this edit to gather space in one place		/a247

/ EXTRACTNUMBER ERROR HANDLER
/d247	EXERR1,	TAD	(EREXTR)	/ GET ERROR NUMBER
/d247		JMS	RESCURPTR	/ FIRST RESTORE CURPTR THEN....
/d247		JMS	EDERR-1		/ GO TO ERROR REPORTER. WON'T RETURN
/d247	SAVTP,	.-.			/ SAVED_TAB_POSITION - HOLDS TAB_POSITION
/d247					/  OF CURRENT DECIMAL TAB FIELD. USED
/d247					/  BY BOTH EDERR AND GETDTF ROUTINES.
/d247					/  MUST FOLLOW JMS TO EDERR-1

/ CALFXS	Moved here this edit to gather space in one place	/a247

/ CALLS EDITOR FXSCRL ROUTINE
CALFXS,	XX
	CLA			/ CLEAR AC
	CDFEDT			/ IF THE SCREEN LAG COUNT IS NEGATIVE
	TAD I	(SCRLCT)	/
	CDFMYF			/
	SNA CLA 		/ THEN  CALL FXSCRL TO UPDATE SCREEN
	JMP I	CALFXS		/
	CIFEDT			/	 SET TO EDITORS INSTRUCTION FIELD
	JMS	CALLAR		/	 ALL PURPOSE ROUTINE TO CALL ANY
				/	 EDITOR ROUTINE
		FXSCRL		/	 ADDRESS OF ROUTINE IN EDITOR
		CDFBUF		/	 DATA FIELD FOR ROUTINE TO USE
	JMP I	CALFXS		/ RETURN TO CALLER

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED



/++
/	CHECK_SPECIAL_NUMBER_FIELD	CSNF
/
/ FUNTIONAL DESCRIPTION:	CSNF
/
/	CHECK IF ASCII STRING CONTAINED WITHIN ENASBF IS EITHER
/	"*OVR.FLO*" OR "*UN.DEF*".
/
/ CALLING SEQUENCE:	JMS	CSNF
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	LOCAL: ASTPTR (X5), ASP (X4), ENASBP (T2)
/
/ OUTPUT PARAMETERS:	AC AND MQ = 0
/
/ IMPLICIT OUTPUT:	LOCAL: ASTPTR (X5), ASP (X4), ENASBP (T2), CSNF
/
/ COMPLETION CODE:	1) RETURN CALLER+1 IF NO MATCH
/			   RETURN CALLER+2 IF MATCH
/
/ SIDE EFFECTS:		1) NOTE: ASTPTR=X5, ASP=X4, ENASBP=T2
/			2) OFTEXT AND UDTEXT STRINGS RESIDE IN BCDASC
/			    ROUTINE AND ARE DEFINED IN WPF1.
/--

ASTPTR=	X5
ASP=	X4
ENASBP=	T2

CSNF,	XX
	TAD	(AST-1)		/ SET ASCII_STRING_TABLE_POINTER = ASCII_-
				/  STRING_TABLE - 1
	DCA	ASTPTR

CSNF1,	TAD I	ASTPTR		/ INCREMENT ASCII_STRING_TABLE_POINTER AND
				/  GET ASCII_STRING_TABLE ENTRY
	SNA			/ SKIP IF: NOT END OF TABLE
	JMP	CSNF5		/ NO MATCH.  DO NONSKIP RETURN
	DCA	ASP		/ SET ASCII_STRING_POINTER = ASCII_STRING_-
				/  TABLE ENTRY
	TAD	(ENASBF-1)	/ SET EXTRACT_NUMBER_ASCII_STRING_BUFFER_-
				/  POINTER = EXTRACT_NUMBER_ASCII_BUFFER - 1
	DCA	ENASBP

CSNF2,	ISZ	ENASBP		/ INC. EXTRACT_NUMBER_ASCII_STRING_BUFFER_POINTER
	TAD I	ASP		/ INC. ASCII_STRING_POINTER AND GET CHARACTER
	SZA			/ SKIP IF: END OF STRING
	JMP	CSNF4		/ GO CHECK FOR MATCH
	CDFMTH			/ CHECK IF END OF EXTRACT_NUMBER_ASCII_BUFFER
				/  STRING
	TAD I	ENASBP
	CDFMYF
	SZA CLA			/ SKIP IF: SO - ASCII STRINGS MATCHED!!
	JMP	CSNF1		/ NO MATCH - TRY NEXT ASCII STRING
	ISZ	CSNF		/ INCREMENT RETURN POINTER FOR MATCH RETURN
	JMP	CSNF5		/ DO RETURN

CSNF4,	CIA			/ DOES CHAR. FROM ASCII STRING MATCH CHAR.
				/  FROM EXTRACT_NUMBER_ASCII_BUFFER?
	CDFMTH
	TAD I	ENASBP
	CDFMYF
	SNA CLA			/ SKIP IF: NOT
	JMP	CSNF2		/ MATCH - SEE IF NEXT CHAR. MATCHES
	JMP	CSNF1		/ NO MATCH - GO TRY NEXT ASCII STRING

CSNF5,	JMP I	CSNF		/ RETURN

AST,	OFTEXT-1		/ ADDRESS OF *OVR.FLO* TEXT - 1
	UDTEXT-1		/ ADDRESS OF *UN.DEF* TEXT - 1
	0			/ AST TABLE TERMINATOR


/++
/	FIND_TAB_POSITION	FINDTP
/
/ FUNTIONAL DESCRIPTION:	FINDTP
/
/	USING THE LINE POSITION POINTED TO AT CALL+1 PLUS OFFSET IN AC,
/	FIND THE NEXT TAB SETTING IN THE RULER.  STORE ITS CLASS THEN
/	SET FLAGS TO INDICATE IF IT WAS A DECIMAL ALIGN TAB AND IF LINE
/	POSITION SPECIFIED UPON CALL DIRECTLY CORRESPONDS TO TAB SETTING
/	POSITION IN RULER.
/
/ CALLING SEQUENCE:	CALL:	JMS	FINDTP
/			CALL+1:	POINTER TO ADDRESS OF LINE POSITION
/
/ INPUT PARAMETERS:	AC = OFFSET TO BE ADDED TO LINE POSITION
/
/ IMPLICIT INPUT:	GLOBAL:	TABPOSITION, TABFLAGS
/			LOCAL:	FINDT2, T3
/
/ OUTPUT PARAMETERS:	AC = TAB CLASS
/			MQ = POSITION OF TAB IN RULER
/
/ IMPLICIT OUTPUT:	GLOBAL:	TABPOSITION, TABFLAGS
/			LOCAL:	FINDT2, T3
/
/ COMPLETION CODE:	NONE
/ SIDE EFFECTS:		NONE
/
/--

FINDTP,	XX
	DCA	T1		/ SAVE ENTRY OFFSET
	TAD I	FINDTP		/ GET ADRESS OF POSITION COUNT
	DCA	T2		/ SAVE ADDRESS
	TAD	T1		/ RESTORE OFFSET
	TAD I	T2		/ ADD POSITION COUNT
	CIFMNU			/ GET DECIMAL CLASS AND POSITION	/M208
	JMS	CALSWAP		/ CALL_A_ROUTINE IN EDITOR SWAP AREA	/M208
		FNTABSTOP	/ FIND_NEXT_TAB_STOP ROUTINE
		CDFEDT		/ DATA FIELD FOR ROUTINE
	DCA	T3		/ STORE TAB CLASS
	SWP			/ GET POSITION IN AC
	DCA	TABPOSITION	/ STORE POSITION
	DCA	TABFLAGS	/ CLEAR TAB_FLAGS
	TAD	T3		/ RESTORE TAB_CLASS TO AC
	TAD	(-3)		/ CHECK FOR CLASS = DECIMAL TAB
	SZA CLA			/ SKIP IF:DECIMAL TAB
	JMP	FINDT3		/ NOT DECIMAL TAB
	ISZ	TABFLAGS	/ SET BIT11 = DECIMAL TAB DETECTED
	TAD	TABPOSITION	/ GET DECIMAL TAB POSITION
	CIA
	TAD I	T2		/ ADD POSITION COUNT
	SNA CLA			/ SKIP IF: DIRECTLY ALIGNED TO DECIMAL
				/  TAB
	AC4000			/ SET BIT1 = CHARACTER DIRECTLY ALIGNED
				/  WITH DECIMAL TAB IN RULER
	TAD	TABFLAGS	/ ADD CURRENT TAB_FLAGS
	DCA	TABFLAGS	/ SAVE UPDATED TAB_FLAGS
FINDT3,	ISZ	FINDTP		/ BUMP RETURN POINTER
	JMP I	FINDTP		/ RETURN


/++
/	READ_NEXT_CHARACTER	READNEXTCHARACTER

/ FUNTIONAL DESCRIPTION:	READNEXTCHARACTER
/
/	BUMP LINE_POSITION_COUNTER AND READ THE NEXT CHARACTER.
/
/ CALLING SEQUENCE:	JMS	READNEXTCHARACTER
/			 ETX RETURN
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	GLOBAL: CRWMB
/
/ OUTPUT PARAMETERS:	AC = 0
/
/ IMPLICIT OUTPUT:	GLOBAL:	CRWMB, CRLMB
/			LOCAL:	READNEXTCHARACTER
/
/ COMPLETION CODE:	1) ETX CHARACTER RETURN TO CALLER+1.  ALL OTHER
/			    CHARACTERS RETURN CALLER+2.
/
/ SIDE EFFECTS:		NONE
/
/--

READNEXTCHARACTER,
	XX
	JMS	ADUNIT		/ Advance one unit, returning characters/m247
				/ from within deadkeys, if required	/m247
	SKP			/ ETX RETURN
	ISZ	READNEXTCHARACTER / BUMP RETURN POINTER
	DCA	CRWMB		/ SAVE CHARACTER_READ_WITH_MODE_BITS
	TAD	CRWMB		/ Get it back				/a247
	TAD	(-ECSTOV)	/ Test for the start of a dead key	/a247
	SNA CLA			/ Is this a dead key sequence?		/a247
	ISZ	DEADKEY		/ Yes, tickle the deadkey flag.		/a247
	TAD	CRWMB		/ GET IT BACK
	AND	P177		/ STRIP MODE BITS
	DCA	CRLMB		/ SAVE CHARACTER_READ_LESS_MODE_BITS
	JMP I	READNEXTCHARACTER / RETURN


/++
/	READ_TAB_OR_LINE_END	READTABORLINEEND
/
/ FUNTIONAL DESCRIPTION:	READTABORLINEEND
/
/	THIS SUBROUTINE WILL CONTINUE TO READ CHARACTERS FROM A DOCUMENT
/ CURRENTLY BEING EDITED UNTIL ONE OF THREE CONDITIONS ARE MET: 1) READING
/ OF A TAB CHARACTER, 2) READING OF A LINE ENDING CHARACTER, OR 3) ETX
/ CHARACTER IS ENCOUNTED.  IF A TAB IS READ THEN A SKIP RETURN IS MADE
/ TO THE CALLER.  LINE ENDING AND ETX WILL RESULT IN A RETURN TO CALLER+1.
/
/ CALLING SEQUENCE:	JMS	READTABORLINEEND
/			 LINE_END OR ETX RETURN
/			 TAB RETURN
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	GLOBAL:	LNEPC, CRLMB, TABFLAGS
/
/ OUTPUT PARAMETERS:	AC = 0
/
/ IMPLICIT OUTPUT:	LOCAL:	LNEPC, READTABORLINEEND
/
/ COMPLETION CODE:	1) RETURN TO CALLER+1 IF LINE_END CHAR. OR ETX CHAR.
/			    WAS ENCOUNTED DURING READ.
/			2) RETURN TO CALLER+2 IF TAB CHAR. ENCOUNTED DURING
/			    READ.
/
/ SIDE EFFECTS:		1) LNEPC SET TO CHARACTER POSITION AT RETURN TIME.
/			2) A CHECK IS PERFORMED AFTER THE READING OF EACH
/			    CHARACTER TO TEST IF ITS DIRECTLY ALIGNED WITH
/			    A DECIMAL TAB RULER SETTING.  IF SO THEN
/			    DTABCOUNT IS INCREMENTED.  IF THE CHARACTER
/			    IS AN ECTAB THEN AN ADDITIONAL CALL IS MADE
/			    TO FINDTP SO THAT  TABPOSITION, AND TABFLAGS
/			    WILL REFLECT THE RULER SETTING ECTAB IS
/			    ASSOCIATED WITH.
/
/--

READTABORLINEEND,
	XX
	TAD	CRWMB		/ HAS CHARACTER BEEN READ ALREADY?
	SZA CLA			/ SKIP IF: SO
	JMP	READT4		/ PROCESS CHARACTER

READT1,	ISZ	LNEPC		/ INCREMENT LINE POSITION COUNTER
	NOP			/ ALLOW FOR LNEPC = -1
	JMS	READNEXTCHARACTER	/ READ_NEXT_CHARACTER
	JMP	READT2		/ ETX RETURN

	AC7777			/ CALL FINDTP TO SEARCH FOR TAB FROM
				/  CURRENT LINE POSITION - 1
	JMS	FINDTP		/ FIND_TAB_POSITION
		LNEPC

	TAD	TABFLAGS	/ CURRENT POSITION DIRECTLY ALIGNED WITH
				/  A DECIMAL TAB?
	SPA CLA			/ SKIP IF: NOT
	JMS	IDTABCOUNT	/ YES - INCREMENT DECIMAL TAB COUNT

READT4,	TAD	CRLMB		/ GET CHARACTER_READ_LESS_MODE_BITS
	TAD	(-ECTAB)	/ IS CHARACTER = TAB?
	SZA			/ SKIP IF: SO
	JMP	READT3
	ISZ	READTABORLINEEND/ INCREMENT RETURN POINTER

/ ADJUST TABFLAGS AND TABPOSITION FOR THIS TAB

	JMS	FINDTP		/ CALL FIND_TAB_POSITION
		LNEPC		/ LINE_POSITION_COUNTER

	JMP	READT2

READT3,	TAD	(ECTAB-ECNWLN)	/ IS CHARACTER = NEW_LINE?
	SZA CLA			/ SKIP IF: SO
	JMP	READT1		/ NO - GO FOR NEXT CHARACTER

READT2,	JMP I	READTABORLINEEND/ RETURN


/ SET CURPTR

/++
/			STCURPTR
/
/ FUNTIONAL DESCRIPTION:	SET_CURPTR
/
/	SAVE CURRENT VALUE OF CURPTR.  ADD OFFSET IN AC ON ENTRY WITH
/	CURRENT VALUE OF LINE23 TO PROVIDE NEW CURPTR VALUE.  TO RESTORE
/	OLD CURPTR CALL RESCURPTR ROUTINE.
/
/ CALLING SEQUENCE:	JMS	STCURPTR
/
/ INPUT PARAMETERS:	AC = OFFSET TO BE ADDED TO CURRENT VALUE OF LINE23
/
/ IMPLICIT INPUT:	GLOBAL:	CURPTR, LINE23
/
/ OUTPUT PARAMETERS:	AC = 0
/
/ IMPLICIT OUTPUT:	GLOBAL:	SAVCP, CURPTR
/
/ COMPLETION CODE:	NONE
/ SIDE EFFECTS:		NONE
/
/--

STCURPTR,
	XX
	MQL			/ HOLD ONTO OFFSET
	CDFEDT
	TAD I	(CURPTR)	/ SAVE CURPTR VALUE
	DCA	SAVCP
	SWP			/ RESTORE OFFSET AND INITIALIZE POINTER
				/  FOR READING LINE
	TAD I	(LINE23)
	DCA I	(CURPTR)
	CDFMYF
	JMP I	STCURPTR	/ RETURN

/ RESTORE CURPTR
RESCURPTR,
	XX
	MQL			/ SAVE VALUE IN AC
	TAD	SAVCP		/ RESTORE CURPTR
	CDFEDT
	DCA I	(CURPTR)
	CDFMYF
	SWP			/ RETORE AC
	JMP I	RESCURPTR	/ RETURN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/ ENTIRE INSDEL ROUTINE
/************************************************************************
/									/
/			       INSDEL					/
/									/
/	   EDITS MATH TEXT, DELETING PREVIOUS RESULTS & INSERTING	/
/	   NEW RESULTS AFTER HAVING DETERMINED THAT THESE FIT		/
/	   WITHOUT OVERLAPPING ANY OTHER FIELDS				/
/									/
/***********************************************************************/

/ This routine is divided into four phases:  scanning a line of text
/ preparing tables about the contents of the line, comparing the space
/ available on the line to the requirements determined by the results
/ to be inserted into the line, deleting any text in result fields from
/ previous passes, and inserting math results which are known to fit
/ into the slots which have been prepared for them.

/***********************************************************************/
/									/
/ PHASE 1        SCAN TEXT LINE PREPARING TABLE FLDDIM			/
/									/
/***********************************************************************/

/	NUMEROUS CORRECTIONS AND REARRANGING OF CODE WERE MADE AS
/	PART OF THE INITIAL DEBUGGING OF INSDEL. THESE ARE TOO NUMEROUS
/	AND TOO FAR-REACHING TO BE WORTH LISTING INDIVIDUALLY.

INSDEL,	XX
	DCA	DTABPR		/ SAVE DCHAR OR TCHAR POINTER
	JMS	CLRZER		/ CLEAR TABLE AREAS
		FLDDIM
		-5^MXTABS+3

	DCA	FLDCNT		/ CLEAR FIELD COUNT
	TAD	(FLDDIM)	/ INITIALIZE TABLE POINTER
	DCA	REG1
	JMS	EDITINIT	/ INITIALIZE EDIT CURSOR POINTER
	DCA	CHARCNT		/ OTHER VALUES
	DCA	BEGFLD		/ LEFT BOUNDARY OF A FIELD
	DCA	ENDFLD		/ RIGHT BOUNDARY OF A FIELD
	IAC
	DCA	PCP		/ CURRENT COLUMN POSITION OF LINE
	DCA	XPCP		/ EXTRA SPACES, SOFT (OR BETWEEN FLDS)
	DCA	DTABN		/ COUNT OF DEC. TAB POSITIONS
	DCA	FLAGS		/ THESE VALUES RETURNED BY GETTAB
	ISZ	FLDCNT


/ DETERMINE CASE

PH14,	JMS	NXCASE		/ GET NEXT CODE & RETURN ACCORDING TO CASE
	JMP	PH15		/ ALPHANUMERIC
	JMP	PH141		/ SPACE
	JMP	PH17		/ NEW LINE
	JMP	PH16		/ TAB
	JMP	PH17		/ OWN CODE
	JMP	PH15		/ DEAD KEY


/ CASE:	SPACE OR SOFT SPACE

PH141,	TAD	FLAGS		/ IF DTAB RESULT FIELD
	SMA CLA
	JMP	PH142
	TAD	CHARCNT		/ THEN IF FIELD.CHAR.COUNT # 0
	SNA CLA
	JMP	PH142
	TAD	PCP		/ END PREVIOUS FIELD
	DCA	ENDFLD
	JMS	FLDSTRT		/ START NEW FIELD WITHOUT TAB.
	DCA	FLAGS		/ CLEAR FLAGS & TABPCP,SINCE
	DCA	TABPCP		/ NEW FIELD DOES NOT CORRESPOND
	DCA	CHARCNT		/ TO ANY TAB POSITION.
	ISZ	PCP		/ EXTRA INCR AFTER ALPHANUMERICS
PH142,	ISZ	XPCP		/ INCR EXTRA SPACE COUNTER
	JMP	PH14

/ CASE:	ALPHANUMERIC

PH15,	JMS	INSEXTR		/ PCP=PCP+XPCP  I.E. ADD EXTRA SPACES TO PCP
	DCA	XPCP		/ CLEAR EXTRA SPACES COUNTER
	TAD	CHARCNT		/ FIND OUT IF THIS ALPHANUMERIC BEGINS A FIELD
	SZA CLA
	JMP	PH151
	TAD	PCP
	DCA	BEGFLD		/ SET NEW BEGINNING OF FIELD
	SKP
PH151,	ISZ	PCP		/ INCR PRINT CHARACTER POSITION
	ISZ	CHARCNT		/ INCR CHAR. COUNT
	JMP	PH14

/ CASE:	TAB CODE

PH16,	TAD	CHARCNT		/ IF FIELD.CHAR.COUNT = 0
	SZA CLA
	JMP	PH161
	JMS	INSEXTR		/ PCP=PCP+XPCP  I.E. ADD EXTRA SPACES TO PCP
	DCA	XPCP
	TAD	PCP		/ SET FIELD BEGINNING ADDRESS
	DCA	BEGFLD
	AC7777
	TAD	FLDCNT		/ IF BEGINNING OF LINE, THEN DO NOT START
	SNA CLA			/ A FIELD ON A BLANK TAB
	JMP	PH162
PH161,	AC2000			/ IF RIGHT-JUSTIFIED FIELD, THEN
	AND	TABPCP		/ DO NOT ELIMINATE ANY TRAILING
	SZA CLA			/ SPACES.
	TAD	XPCP
	TAD	PCP		/ COMPLETE PREVIOUS FLDDIM ENTRY
	DCA	ENDFLD
	JMS	FLDSTRT		/ AND START NEXT ONE
	JMS	INSEXTR		/ PCP=PCP+XPCP  I.E. ADD EXTRA SPACES TO PCP
	TAD	XPCP		/ CHECK FOR ZONE TO SWEEP AFTER! LAST FIELD
	SNA CLA								/C236
	JMP	PH162
	JMP	PH162	/ *** T E M P O R A R Y   F I X   FOR MATH BUG	/A236
			/ *** DISABLE SWEEPING ZONE FOR TABS BECAUSE	/A236
			/ *** IT DOES NOT WORK RIGHT AND CAN CAUSE A	/A236
			/ *** SYSTEM HALT FROM RECURSIVE CALLS TO REJUST/A236

	TAD	PCP		/ YES! SWEEP THIS ZONE FOR TABS.
	IAC			/ BUMP END COUNT BY ONE			/C236
	MQL			/ IT BEGINS AT END OF LAST FIELD &
	TAD	ENDFLD		/ ENDS AFTER EXTRA SPACES FOLLOWING
	JMS	TABCHK		/ THIS FIELD.
PH162,	DCA	XPCP
	ISZ	PCP		/ INCREMENT POSITION COUNTER
	TAD	PCP		/ GET NEXT TAB POSITION TO BEGIN FIELD
	JMS	GETTAB
	SZA
	ISZ	DTABN		/ COUNT DTAB POSITION, IF ANY
	DCA	FLAGS		/ THESE VALUES RETURNED BY GETTAB
	ACL
	DCA	TABPCP
	TAD	CHARCNT		/ IF FIELD IS BLANK
	SZA CLA			/ THEN DO NOT DO EXTRA INCREMENT
	ISZ	PCP		/ OF PCP. EXTRA IS REQUIRED SINCE
	ISZ	FLDCNT		/ FIRST ALPHANUMERIC OF EACH FIELD
	DCA	CHARCNT		/ IS NOT COUNTED IN ORDER TO RETARD
	JMP	PH14		/ PCP.


/ CASE:	CR OR WORD-WRAP CODE

PH17,	AC2000			/ IF RIGHT-JUSTIFIED FIELD, THEN
	AND	TABPCP		/ DO NOT ELIMINATE ANY TRAILING
	SZA CLA			/ SPACES.
	TAD	XPCP
	TAD	PCP		/ UPDATE POSITION, PCP
	DCA	PCP
	JMS	INSFEND		/ GO END CURRENT FIELD, IF ANY
	AC7777
	TAD	RIGHTM		/ SAVE RIGHT MARGIN IN MQ FOR TAB CHECK BELOW
	MQL
	AC2000			/ THEN IF LINE ENDS WITH A WORD-WRAP
	AND	CRWMB
	SNA CLA
	JMP	PH171
	TAD	ENDFLD
	IAC			/ THEN SET ABSOLUTE MARGIN AT
	SKP			/  THE END OF THAT FIELD
PH171,	TAD	RIGHTM		/ SET ABSOLUTE MARGIN=RIGHT MARGIN
	DCA	ABSOLM
	TAD	ENDFLD		/ CREATE ENTRIES IN FLDDIM FOR ALL TAB
	IAC
	JMS	TABCHK		/ POINTS TO THE RIGHT OF THE CR
	JMP	PHASE2

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/***********************************************************************/
/									/
/PHASE 2       DETERMINE IF RESULTS FIT INTO AVAILABLE SPACE		/
/									/
/***********************************************************************/

/ Phase 2 matches the entries in FLDDIM is order to assure that there
/ are no overlaps. The ending location of each field is matched against
/ the beginning location of the next field. The latter must always be
/ a greater number if there is no overlapping. If two fields do overlap,
/ then the program will determine if one or both of the fields are
/ result fields and take an error exit appropriate to the case.

PHASE2,	DCA	REG4		/ CLEAR REG4 SO THAT FIRST MATCH WORKS
	TAD	(FLDDIM-5)	/ INITIALIZE LIST POINTER
	DCA	REG1
PH21,	JMS	GETFLDS  	/ GET NEXT ENTRY FROM FLDDIM TO MATCH AGAINST
		NEWCON
	JMP	PHASE3		/ END LIST RETURN, EXIT TO NEXT PHASE
	JMS	INSBLANK	/ CHECK FOR TAB-ONLY ENTRY
	CLA								/A236
/D236	AC7777			/ NOT TAB-ONLY RETURN: DECR BEGFLD
	TAD	BEGFLD		/ TAB-ONLY RETURN
	SPA SNA			/ DO NOT LET BEGFLD BECOME <= 0
	IAC
	DCA	BEGFLD		/ SAVE RETURNED LEFT BOUNDARY
	TAD	REG4		/ MATCH RIGHT BOUNDARY OF PREVIOUS FIELD
	CIA			/ AGAINST LEFT BOUNDARY OF UPCOMING
	TAD	BEGFLD		/ FIELD
	SPA SNA CLA		/ RIGHT BOUNDARY MUST BE GREATER,
	JMP	FLDERR		/ OTHERWISE, ERROR
	JMS	SETFEND		/ ESTABLISH END OF THIS FIELD FOR NXT LOOP
	AC7777			/ TAB-ONLY RETURN-DECR ENDFLD
	TAD	ENDFLD		/ AND STORE VALUE IN REG4
	DCA	REG4
	TAD	ENDFLD		/ CHECK CURRENT ENDFLD AGAINST LINE END
	CIA
	TAD	ABSOLM		/ DO NOT EXCEED ABSOLUTE END OF LINE
	SPA CLA
	JMP	FLDERR
	JMP	PH21


/***********************************************************************/
/				ERROR EXIT				/
/***********************************************************************/


FLDERR,	JMS	RESCURPTR	/ RESET CURSOR TO VALUE PRIOR TO MATH
	TAD	(FLDER1)	/ SETUP POINTER TO STORE ERROR DATA IN
	DCA	REG3		/ CALLING SEQUENCE
	DCA	FLDER2
	DCA	FLDER4
	TAD	(-5)		/ GET POINTER TO PREVIOUS ITEM IN FLDDIM
	TAD	REG1
	DCA	REG2		/ AND PUT IT INTO REG2
	TAD	REG2		/ MAKE SURE DO NOT BACK UP BEYOND TABLE
	TAD	(-FLDDIM)	/ BEGINNING
	SPA CLA
	JMP	FLDERA
	TAD I	REG2
	SMA			/ WAS THE PREVIOUS FIELD A RESULT FIELD?
	JMP	FLDERA
	JMS	GETRES		/ GET BCD RESULT POINTER
	DCA	FLDER3		/ AND PUT IT INTO CALLING SEQ.
	ISZ	REG2
	AC7777
	TAD I	REG2		/ GET TAB PCP & PUT THIS
	AND	P377		/ INTO CALLING SEQ.
	DCA	FLDER1
	ISZ	REG3
FLDERA,	CLA
	TAD I	REG1		/ IS THE CURRENT FIELD A RESULT FIELD?
	SMA
	JMP	FLDERB		/ IF YES, THEN
	JMS	GETRES		/ AND PUT IT INTO CALLING SEQ.
	MQL
	ISZ	REG1		/ GET TAB PCP & PUT THIS
	AC7777
	TAD I	REG1		/ INTO CALLING SEQ.
	AND	P377
	DCA I	REG3
	ACL			/ RECOVER SAVED POINTER
	ISZ	REG3		/ INCR TO NEXT SLOT
	ISZ	REG3
	DCA I	REG3		/ PUT POINTER INTO PARAM LIST
FLDERB,	CLA
	TAD	REG3		/ SET ERROR CODE TO ERNOSP IF ONLY ONE
	TAD	(-FLDER3)	/ RESULT FIELD TO BE DISPLAYED
	SPA SNA CLA		/ OR TO ERNSP2 IF TWO RESULT
	JMP	FLDERC		/ FIELDS TO BE DISPLAYED.
	TAD	(ERNSP2)
	SKP
FLDERC,	TAD	(ERNOSP)
	JMS	EDERR-1		/ EXIT TO ERROR WITH ERNOSP ERROR CODE
FLDER1,		XX		/ PCP OF DTAB OF 1ST OVERLAPPING FIELD
FLDER2,		XX		/ 0 OR PCP OF DTAB OF 2ND OVERLAPPING FIELD
FLDER3,		XX		/ POINTER TO BCD RESULTS, CONTENTS OF 1ST FIELD
FLDER4,		XX		/ 0 OR PTR TO BCD RESULTS, CONTENTS OF 2ND FIELD

/ NOTE:	NO RETURN IS MADE FROM ABOVE "JMS" WHEN ERROR IS CALLED!!!
/	"JMS" WAS USED INSTEAD OF "JMP" IN ORDER TO PASS ADDRESS OF THE
/	PCP'S & POINTERS.


/************************************************************************/
/			 NORMAL (NON-ERROR) EXIT			 /
/************************************************************************/

INSEXIT,JMS	CALREJ		/ CALLED EDITOR REJUSTIFY ROUTINE
	TAD	INSDEL		/ SET UP TO EXIT
	DCA	T1
	JMP I	T1		/ EXIT

/******************************SUBROUTINE*******************************/

/ This routine will set up and call the editor rejustify routine

CALREJ,	XX
	CDFEDT
	AC7777
	DCA I	(REJFLG)	/ SET EDITOR REJUSTIFY CONDITION
	CDFMYF
	CIFEDT
	JMS	CALLAR		/ CALL EDITOR REJUSTIFY
		REJUST		/ ADDRESS OF ROUTINE IN EDITOR
		CDFBUF		/ DATA FIELD FOR REJUST TO USE
	CLA CLL
	JMP I	CALREJ		/ RETURN TO CALLER

/******************************SUBROUTINE*******************************/

/ ROUTINE USED BY PHASE1 (SCAN OF DATA) TO DETERMINE THE CONDITIONS AT THE
/ END OF TEXT LINE (FINDING CR)

INSFEND,XX
	TAD	CHARCNT		/ IF FIELD.CHAR.COUNT # 0
	SNA CLA
	JMP	INSF1
	TAD	PCP		/ THEN COMPLETE FLDDIM ENTRY
	JMP	INSF2
INSF1,	AC7777			/ IF 0, THEN LOOK FOR EMPTY LINE
	TAD	FLDCNT		/ I.E. CR ONLY
	SNA CLA
	JMP I	INSFEND		/ IF SO, THEN EXIT
	TAD	TABPCP		/ ELSE CREATE BLANK TAB ENTRY
	AND	P377
	DCA	BEGFLD		/ SET BEGFLD=ENDFLD=TABPCP
	TAD	BEGFLD
INSF2,	DCA	ENDFLD
	JMS	FLDSTRT		/ UNDATE FLDDIM TABLE
	JMP I	INSFEND

/******************************SUBROUTINE*******************************/

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/***********************************************************************/
/									/
/ PHASE 3         DELETE ANY TEXT FOUND IN RESULT FIELDS		/
/									/
/***********************************************************************/

PHASE3,	JMS	EDITINIT	/ INITIALIZE EDIT CURSOR POINTER
	TAD	(FLDDIM-5)	/ INITIALIZE TABLE TWO POINTER &
	DCA	REG1		/ COL.POSITION COUNTER
	IAC			/ INITIALIZE PCP TO 1
	DCA	PCP
	DCA	REG3		/ CLEAR TAB FLAG
PH31,	JMS	GETFLDS		/ GET NEXT ENTRY: FLAGS TABPCP BEGFLD ENDFLD
		OLDCON
		NOP		/ DO NOT EXIT UNTIL LINE END CODE FOUND

/ DETERMINE CASE

PH32,	JMS	NXCASE		/ GET NEXT CODE & RETURN ACCORDING TO CASE
	JMP	PH321		/ ALPHANUMERIC
	JMP	PH322		/ SPACE
	JMP	PH324		/ NEW LINE
	JMP	PH323		/ TAB
	JMP	PH323		/ OWN CODE
	JMP	PH321		/ DEAD KEY


/ CASE:	ALPHANUMERIC

PH321,	TAD	BEGFLD		/ TEST FOR POSITION ON LINE
	CIA			/ EITHER STARTING A NEW FIELD
	TAD	PCP		/ OR CONTINUING A FIELD
	SMA SZA CLA
	JMP	PH3211
	TAD	REG3		/ STARTING A FIELD - CHECK FOR TAB
	SZA CLA
	JMP	PH3210
	TAD	(ECMTH1+400)	/ IF THERE IS NO TAB, THEN INSERT
	JMS	INSFORCE	/ OWN FIELD MARKER
	JMP	PH3212
PH3210,	TAD	FLAGS		/ CHECK FOR PREVIOUS RESULT FIELD
	SMA CLA
	JMP	PH3212
	JMS	DELCODE		/ DELETE CODE FROM EDIT BUFFER
	ACL			/ GET ATTRIBUTES SAVED BY DELCODE
	AND	(MASKATTR)
	MQL			/ SAVE ATTRIBUTES IN MQ
	TAD I	REG1		/ GET PRESENT VALUE FROM FLDDIM
	MQA			/ & "OR" ATTRIBUTES
	DCA I	REG1		/ THEN RESTORE INTO FLDDIM.
PH3211,	TAD	FLAGS		/ CHECK RESULT FIELD (DELETION)
	SPA CLA
	JMS	DELCODE		/ YES, DELETE THIS CHARACTER
PH3212,	DCA	REG3		/ CONTINUING A FIELD - CLEAR TAB COUNTER &
	TAD	ENDFLD		/ CHECK FOR POSITION ON LINE
	CIA			/ EITHER ENDING FIELD
	TAD	PCP		/ OR CONTINUING A FIELD
	ISZ	PCP		/ INCR POSITION ON LINE
	SPA CLA
	JMP	PH32		/ CONTINUING FIELD - GET NEXT CODE
	JMP	PH31		/ ENDING A FIELD - GET NEXT FIELD ENTRY


/ CASE:	SPACE OR SOFT SPACE

PH322,	TAD	BEGFLD		/ TEST FOR POSITION ON LINE
	CIA			/ EITHER LESS THAN BEGINNING A FIELD
	TAD	PCP		/ OR GREATER THAN ENDING A FIELD
	SPA SNA CLA		/ OR WITHIN A FIELD:
	JMP	PH3221		/ IN EITHER OF THE FIRST
	TAD	ENDFLD		/ TWO CASES - DELETE THE
	CIA			/ SPACE, OTHERWISE,
	TAD	PCP		/ CONTINUE
	SPA SNA CLA
	JMP	PH3222
PH3221,	ISZ	PCP		/ INCR POSITION ON LINE
	TAD	CRWMB		/ IF OUTSIDE A FIELD, THEN
	AND	(400)		/ DELETE SPACE UNLESS UNDERLINED
	SZA CLA
	JMP	PH32
	JMS	DELCODE		/ DELETE CODE FROM EDIT BUFFER
	JMP	PH32
PH3222,	TAD	ENDFLD		/ CHECK FOR POSITION ON LINE








	CIA			/ EITHER ENDING FIELD
	TAD	PCP		/ OR CONTINUING A FIELD
	ISZ	PCP		/ INCR POSITION ON LINE
	SPA CLA
	JMP	PH32		/ CONTINUING FIELD - GET NEXT CODE
	JMP	PH31		/ ENDING A FIELD - GET NEXT FIELD ENTRY


/ CASE:	TAB

PH323,	ISZ	REG3		/ SET TAB FLAG
	ISZ	PCP		/ & INCR POSITION ON LINE
	AC2000
	AND	FLAGS		/ CHECK FOR FORCED TAB
	SZA CLA
	JMP	PH3232		/ IF FOUND, THEN GO FORCE IT.
	JMS	INSBLANK	/ CHECK FOR BLANK FIELD
	JMP	PH32		/ NON-BLANK RETURN - CONTINUE
PH3231,	JMS	GETFLDS		/ ELSE GET NEXT ENTRY &
		OLDCON		/ CONTINUE TO CHECK FOR
/D236	NOP
	JMP	PH32
PH3232,	JMS	INSTAB		/ FORCED-TAB INSERTIONS
	JMP	PH32		/ NON-SKIP, DONE
	JMP	PH3231		/ SKIP, CONTINUE


/ CASE:	NEW LINE

PH324,	TAD	REG1		/ SAVE FLDDIM POINTER
	DCA	SVREG1
PH3241,	TAD 	FLAGS		/ OTHERWISE, CHECK FOR RESULTS FIELD
	SPA CLA			/ THROUGH REST OF LIST
	JMP	PH3242
	JMS	GETFLDS		/ GET NEXT ITEM FROM LIST
		OLDCON
	JMP	PHASE4		/ IF END OF LIST IS FOUND, EXIT THIS PHASE
	JMP	PH3241
PH3242,	TAD	SVREG1		/ IF A RESULT, THEN GO INSERT FORCED-TABS
	DCA	REG1		/ BEFORE NEW LINE CODE
PH3243,	JMS	INSTAB		/ INSERT TAB
	JMP	PHASE4		/ NON-SKIP, DONE
	JMS	GETFLDS
		OLDCON
	JMP		PHASE4
	JMP	PH3243
SVREG1,	0

/****************************SUBROUTINE*********************************/

INSTAB,	XX
	AC2000			/ LOOK FOR BIT CALLING FOR FORCED TAB
	AND	FLAGS
	SNA CLA
	JMP I	INSTAB		/ NON-SKIP RETURN, DONE
	TAD	(ECTAB)		/ IF FORCED TAB BIT FOUND
	JMS	INSFORCE	/  THEN INSERT TAB CODE
	ISZ	INSTAB
	JMP I	INSTAB		/ SKIP RETURN, CONTINUE

/****************************SUBROUTINE*********************************/

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/***********************************************************************/
/									/
/ PHASE 4        INSERT RESULTS IN ASCII INTO PREPARED FIELDS		/
/									/
/***********************************************************************/

PHASE4,	JMS	EDITINIT	/ INITIALIZE EDIT CURSOR POINTER
	TAD	(FLDDIM-5)
	DCA	REG1
	DCA	FLDCNT		/ CLEAR FIELD COUNTER
	CDFEDT
	TAD I	(CURUL+NWLMAR-NWRUL)	/ GET VALUE OF LEFT MARGIN
	CDFMYF			/ AND SET PCP
	DCA	PCP



/ DETERMINE CASE

PH41,	JMS	NXCASE		/ GET NEXT CODE & RETURN ACCORDING TO CASE
	JMP	PH411		/ ALPHANUMERIC
	JMP	PH412		/ SPACE
	JMP	PH414		/ NEW LINE
	JMP	PH413		/ TAB
	JMP	PH415		/ OWN CODE
	JMP	PH411		/ DEAD KEY


/ CASE:	ALPHANUMERIC

PH411,	ISZ	PCP		/ INCR POSITION ON LINE
	JMP	PH41


/ CASE:	SPACE OR SOFT SPACE

PH412,	ISZ	PCP		/ INCR POSITION ON LINE
	JMP	PH41


/ CASE:	TAB

PH413,	JMS	GETFLDS		/ GET FLAGS, TABPCP, BEGFLD, ENDFLD
		NEWCON
	JMP	INSEXIT		/ NON-SKIP RETURN, END OF INSERTIONS
	JMS	INSBLANK	/ CHECK FOR BLANK FIELD
	SKP			/ NON-BLANK RETURN
	JMP	PH41		/ BLANK - GO GET NEXT CODE
	TAD	BEGFLD		/ SET PCP=BEGINNING OF FIELD
	DCA	PCP
	TAD	FLAGS		/ CHECK FOR DTAB RESULT FIELD
	SMA CLA
	JMP	PH41
	TAD	FLAGS		/ GET POINTER TO BCD RESULT
	JMS	GETRES
	TAD	(-1)		/  OFFSET POINTER RETURNED FROM GETRES
	DCA	PH4131		/ AND THEN DO BCD TO ASCII CONVERSION,
	JMS	BCDASC
PH4131,		XX
		NUMBUF
		CDFMYF
	DCA	REG3
	DCA I	REG3
	TAD	(NUMBUF)	/ AND FINALLY TRANSFER ASCII NUMBER
	DCA	REG3		/ FROM NUMBUF TO
PH4132,	TAD I	REG3		/ INSERTION INTO THE
	SNA CLA			/ EDIT BUFFER.
	JMP	PH41
	JMS	READNEXT	/ MOVE CURSOR POINTER ONE PLACE RIGHT
	NOP
	TAD I	REG3		/ GET ASCII CODE FROM NUMBUF
	MQL
	TAD	FLAGS
	AND	(MASKATTR)	/ GET ATTRIBUTES,
	SWP			/ CHARACTER &
	JMS	INSMCH		/ INSERT INTO EDIT BUFFER.
	ISZ	PCP
	ISZ	REG3
	JMP	PH4132


/ CASE:	NEW LINE

PH414,	JMP	INSEXIT		/ GO TO REJUSTIFY & EXIT


/ CASE:	OWN CODE, I.E. CODE INSERTED TO MARK NON-TAB, NON-DTAB FIELDS

PH415,	JMS	DELCODE		/ DELETE ECMTH1+400 FIELD MARKER
	JMS	GETFLDS		/ SET FLAGS TABPCP BEGFLD ENDFLD
		NEWCON
	JMP	INSEXIT		/ NON-SKIP RETURN ENDS INSERTION
PH4151,	TAD	BEGFLD		/ THEN INSERT SPACES, AS
	CIA			/ NEEDED TO ARRIVE AT BEGINNING
	TAD	PCP		/ OF FIELD.
	SMA CLA
	JMP	PH41
	TAD	(ECSPC)
	JMS	INSCODE		/ INSERT SPACE INTO EDIT BUFFER
	ISZ	PCP
	JMP	PH4151

/******************************SUBROUTINE*******************************/

/ GET flags tabpcp begfld (new/old dimensions) endfld (new/old dimensions)
/ FROM THE NEXT ENTRY IN FLDDIM

GETFLDS,XX
	TAD I	GETFLDS		/ GET PARAMETER IDENTIFYING TYPE OF CONTENTS
	DCA	GETF2
	ISZ	GETFLDS
GETF1,	TAD	REG1		/ ADVANCE POINTER TO NEXT ENTRY IN FLDDIM
	TAD	(5)
	DCA	REG1
	JMS	GETITEM		/ GET NEXT LEFT & RIGHT BOUNDARIES
GETF2,	XX			/ RETURNS END LIST OR AC=LT BOUNDARY
	JMP I	GETFLDS		/			MQ=RT BOUNDARY
	SNA
	JMP	GETF1		/ GET NEXT ENTRY IF ENTRY IS BLANK.
	DCA	BEGFLD
	TAD	REG1		/ GET FLAGS & TAB PCP FROM SAME ENTRY
	DCA	REG2
	TAD I	REG2		/ GET FLAGS
	DCA	FLAGS
	ISZ	REG2
	TAD I	REG2		/ GET TAB PCP
	DCA	TABPCP
	ACL
	DCA	ENDFLD		/ GET ENDFLD
	ISZ	FLDCNT		/ INCR FIELD COUNT
	ISZ	GETFLDS		/ TAKE SKIP RETURN
	JMP I	GETFLDS

/******************************SUBROUTINE*******************************/

/ "CKSCLT" CHECKS TO SEE IF IN SELECT MODE AND IF SO THEN SHUTS DOWN
/ MATH FOR A PARTICULAR WORK AREA WHETHER IN THAT AREA OR NOT. THIS
/ IS CLEANER THAN TRYING TO DETERMINE IF IN SELECT MODE AND IN EDITOR
/ MATH WORK AREA ( WHICH MUST INCLUDE SOME WAY TO TELL IF JUST STARTING
/ ONE BUT NOT CONFIRMED YET, I.E. SELECT MODE HIT AT A "BEGIN" COMMAND),
/ AND THEN HAVING TO SHUT DOWN MATH ANYWAYS.
/
/	IF IN "SELECT MODE"
/	    |	THEN SHUT DOWN MATH IN CASE IN WORK AREA
/	    |	     RETURN TO EDITOR
/	    |	ELSE RETURN TO CALLER TO CONTINUE PROCESSING
/

CKSCLT,	XX
	CDFEDT			/ GET EDITOR DATA FIELD
	TAD I	(ESLMOD+1)	/ GET SELECT MODE FLAG
	AND I	(EDMODE)	/ AND IT WITH THE EDITOR MODE
	CDFMYF			/ RETURN TO THIS DATA FIELD
	SNA CLA			/ IS THE EDITOR IN SELECT MODE?
	JMP I	CKSCLT		/  NO: RETURN TO CALLER TO CONTINUE PROCESSING
	JMS	SCRINI		/  YES: SHUT MATH DOWN IN CASE SELECT DONE IN
				/       EDITOR MATH WORK AREA
	JMP	BKEDIT		/ RETURN TO EDITOR

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/***********************************************************************/
/									/
/		   	  PROGRAM SUBROUTINES				/
/									/
/***********************************************************************/

/****************************SUBROUTINE*********************************/

/ INITIALIZE EDIT CURSOR POINTER TO START OF LINE

EDITINIT,XX
	CDFEDT
	TAD I	(CURUL+NWRMAR-NWRUL)	/ GET RIGHT MARGIN
	DCA	RIGHTM
	TAD I	(CURUL+NWLMAR-NWRUL)	/ GET LEFT MARGIN
	DCA	TABPCP		/ SAVE LEFT MARGIN SETTING
	AC7777
	TAD I	(LINE23)	/ GET POINTER TO BEGINNING OF LINE-1
	DCA I	(CURPTR)	/ AND INITIALIZE CURSOR POINTER
	CDFMYF
	JMP I	EDITINIT


/****************************SUBROUTINE*********************************/

/ GETS THE NEXT TAB POSITION FROM RULER & RETURNS DATA ABOUT IT:

/ RETURNS MQ0=1	RIGHT MARGIN	   AC0=1  RESULT FIELD
/ 	 MQ1=1	> OR J OR R	   AC6-11 DTAB NUMBER
/	 MQ4-11 TAB PCP

GETTAB,	XX
	TAD	(-1)		/ ADJUST PTR SINCE CURUL COUNTS FROM 0
	MQL			/ RESET RULER POSITION POINTER
GT0,	ACL			/ AC=POSITION WITH WHICH TO START SEARCH
	CIFMNU								/M208
	JMS	CALSWAP		/ CALL_A_ROUTINE IN EDITOR SWAP AREA	/M208
		FNTABSTOP	/ FIND NEXT TAB STOP
		CDFEDT
	AND	(0003)		/ MAKE SURE VALUE DOES NOT EXCEED LIMIT
	TAD	(TABCLASS)	/ ADD PTR TO DISPATCH TABLE
	DCA	GT1		/ SAVE IN GT1 FOR INDIRECT
	TAD I	GT1		/ GET ADDR OF TYPE ROUTINE
	DCA	GT1
	ACL			/ GET TAB POSITION INTO AC
	IAC			/ & INCREMENT (VALUE IS RETURNED 1 TO LEFT)
	MQL			/ & RETURN TO MQ
	JMP I	GT1		/ GOTO EXECUTE ROUTINE PER TYPE
GT1,	0
TABCLASS,	GT2
		GT3
		GT4
		GT5


/ TYPE 0 - L D C N H F
/ TYPE 1 - T W P

GT2=	.
GT3=	.
	JMP I	GETTAB


/ TYPE 2 - > J R

GT4,	ACL
	CIA
	TAD	RIGHTM		/ CHECK FOR RIGHT MARGIN SETTING
	SNA CLA
	AC4000			/ SET FLAG FOR RIGHT MARGIN
	TAD	(2000)		/ SET FLAG FOR > OR J TAB
	MQA
	MQL			/ MQ=TABCLASS+PCP -  AC=FLAGS=0
	JMP I	GETTAB		/ EXIT


/ TYPE 3 - .


GT5,	TAD	DTABN		/ GET NEXT DTAB NUMBER
	IAC
	JMS	GETRES		/ GET RESULT BIT & IGNORE POINTER
	CLA RAR			/ SHIFT BITS TO COMBINE WITH PCP
	TAD	DTABN		/ MQ=PCP  AC0=1 & AC6-11=DTAB NO.
	IAC
	JMP I	GETTAB


/****************************SUBROUTINE*********************************/

/ INSERT CONTENTS OF AC INTO TABLE FLDDIM AT REG1 INDIRECT + PARAMETER

/ REG1 ON ENTRY IS ASSUMED TO POINT TO CURRENT
/ ENTRY IN FLDDIM

TABINS,	XX
	DCA	TREG4		/ SAVE AC
	TAD	REG1		/ REG3 = FLDDIM + 2*FLDCNT + PARAMETER
	TAD I	TABINS
	DCA	TREG3
	TAD 	TREG4		/ RECOVER SAVED AC &
	DCA I	TREG3		/ PUT INTO TABLE.
	ISZ	TABINS		/ END OF PREVIOUS FIELD
	JMP I	TABINS
TREG3,	0
TREG4,	0

/****************************SUBROUTINE*********************************/

/ COPY VALUES FROM LOCATIONS flags  tabpcp  begfld  endfld
/ INTO FLDDIM TABLE. ALSO, IF THE FIELD DESCRIBED IS A RESULTS FIELD,
/ THEN GET THE LENGTHS LEFT & RIGHT OF DECIMAL DIGIT OF THE RESULT
/ AND COPY INTO FLDDIM.

/ REG1 IS ASSUMED TO POINT TO NEXT SLOT IN FLDDDIM

FLDSTRT,XX
	TAD	FLAGS
	JMS	TABINS		/ SET FIRST TABLE ITEM = FLAGS
		0
	TAD	CHARCNT		/ CHECK FOR EMPTY FIELD, TAB ONLY
	SNA CLA
	TAD	(1000)		/ IF EMPTY, THEN SET TAB ONLY BIT
	TAD	TABPCP
	JMS	TABINS		/ SET SECOND TABLE ITEM = TAB PCP
		1
	TAD	BEGFLD
	JMS	TABINS		/ SET THIRD TABLE ITEM = LEFT BOUNDARY
		2
	TAD	ENDFLD
	JMS	TABINS		/ SET FOURTH TABLE ITEM = RIGHT BOUNDARY
		3
	TAD	FLAGS		/ CHECK FOR DTAB RESULT FIELD
	SMA CLA
	JMP	FLDS2
	TAD	DTABN		/ IF DTAB RESULT FIELD, THEN GET LENGTHS
	JMS	GETRES		/ GET POINTER TO BCD NO. FROM DCHAR/TCHAR
	TAD	(-1)		/ AND ADJUST IT.
	DCA	FLDS1
	JMS	BCDASC		/ CALL BCD TO ASCII CONVERSION
FLDS1,		XX		/ RETURNS:	MQ=LEFT.RIGHT
		NUMBUF		/   LEFT=DIGITS LEFT OF DECIMAL
		CDFMYF		/  RIGHT=DEC.DIGITS INCLUDING DECIMAL
	ACL
	JMS	TABINS		/ SET FIFTH TABLE ITEM = 0 OR RESULTS LENGTHS
		4
FLDS2,	TAD	REG1		/ INCREMENT TABLE POINTER TO NEXT ENTRY SLOT
	TAD	(5)
	DCA	REG1
	TAD	ENDFLD		/ SAVE RIGHT BOUNDARY OF SEARCH ZONE
	MQL
	TAD	FLAGS		/ CHECK FOR DTAB FIELD
	SNA CLA
	JMP	FLDS3
	TAD	TABPCP		/ IF DTAB FIELD, THEN
	SKP			/ BEGIN SEARCH AFTER DTAB
FLDS3,	TAD	BEGFLD		/ SWEEP ZONE OF FIELD JUST CREATED FOR
	TAD	(4000)		/ SKIPPED TABS - THESE MUST BE
	JMS	TABCHK		/ PUT INTO LIST TO CATCH ANY RESULT
	JMP I	FLDSTRT		/ DTABS UNUSABLE WITHIN ANOTHER FIELD

/****************************SUBROUTINE*********************************/

/ BKEDI4	Moved here this edit to gather space in one place	/a247

/ AN EXIT IS DONE FROM THE "EXTRACTNUMBER" ROUTINE THRU "BKEDI4"
/ WHEN CONDITIONS ON THE TOTAL LINE OF EDITOR MATH ARE SUCH AS TO NOT
/ ALLOW A PROPER PARSING OF THAT LINE BECAUSE IT IS TERMINATED BY A
/ SOFT RETURN OR, NOT TO ALLOW INSERTION OF THE TOTAL VALUE BECAUSE
/ A RULER CHANGE WITH NO DECIMAL TABS IN IT HAS BEEN INSERTED PREVIOUS
/ TO THE TOTAL LINE. THIS CODE TRAPS THESE CONDITIONS BY RESETTING THE
/ "TOTAL" FLAG TO REFLECT THE ABOVE - THUS TURNING OF TOTALS INSERTION

BKEDI4,	CDFMTH			/ CHANGE TO MATH DATA FIELD
	DCA I	(MTHTOT)	/ SET "TOTAL" FLAG TO FALSE
	CDFMYF			/ RETURN TO THIS DATA FIELD
	JMP	BKEDI3		/ GO RESET CURPTR & RETURN TO THE EDITOR

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/****************************SUBROUTINE*********************************/

/ CHECK FOR RULER-DEFINED TABS BETWEEN FIELDS & CREATE DUMMY FLDDIM ENTRIES

/ AC=LEFT LIMIT OF ZONE TO SWEEP
/ PLUS AC0=0 MEANS SWEEP IS BETWEEN FIELDS
/     AC0=1 MEANS SWEEP INTERIOR OF A FIELD
/MQ=RIGHT LIMIT OF ZONE TO SWEEP
TABCHK,	XX
	DCA	REG2		/ SAVE IN ORDER TO CHECK LATER FOR TYPE
	TAD	REG2		/ OF CALL: SWEEP FIELD OR BETWEEN FIELDS
	DCA	REG3		/ SAVE LEFT LIMIT OF ZONE TO CHECK FOR TABS
	ACL
	DCA	REG4		/ SAVE RIGHT LIMIT OF ZONE TO CHECK FOR TABS
TAB1,	TAD	REG3
	AND	P377		/ GET ORIGINAL OR NEW LEFT LIMIT
	JMS	GETTAB		/ SEARCH TABLE ONE FOR NEXT GREATER TAB
	SWP			/ MAKE AC=TAB POSITION,MQ=FLAGS
	SNA
	JMP I	TABCHK		/ EXIT IF NO FURTHER TAB POINTS FOUND
	DCA	REG3		/ SAVE POSITION IF GREATER TAB POINT IS FOUND
	TAD	REG3
	AND	P377		/ CHECK IF THIS POSITION < RIGHT LIMIT
	CIA
	TAD	REG4
	SPA CLA
	JMP I	TABCHK		/ NO - EXIT
	ACL
	SZA CLA
	ISZ	DTABN		/ COUNT DTAB POSITION
	TAD	REG2		/ DO NOT FLAG TO FORCE TAB UNLESS
	RAL			/ CALL IS TO SWEEP BETWEEN FIELDS!
	ACL			/ GET FLAGS - RETURNED BY GETTAB ABOVE
	SNL
	TAD	(2000)		/ SET BITS TO FORCE INSERTION OF TAB
	JMS	TABINS		/ CREATE TAB POSITION ENTRY
		0		/ PUT FLAGS WORD INTO FLDDIM
	TAD	REG3
	JMS	TABINS		/ PUT TABPCP WORD INTO FLDDIM
		1
	ACL
	SMA CLA			/ IF DTAB RESULT FIELD, THEN FILL OUT
	JMP	TAB3		/ BEGFLD
	TAD	REG3		/ ENDFLD
	AND	P377		/ NEW.DIMENSIONS
	JMS	TABINS
		2
	TAD	REG3
	AND	P377		/ BEGFLD & ENDFLD = TAB POSITION
	JMS	TABINS
		3
	TAD	DTABN
	JMS	GETRES		/ NEW.DIMENSIONS = VALUE OF MQ RETURNED
	TAD	(-1)		/ BY BCDASC ROUTINE
	DCA	TAB2
	JMS	BCDASC
TAB2,		XX
		NUMBUF
		CDFMYF
	ACL
	JMS	TABINS		/ PUT NEW.DIMENSIONS INTO TABLE
		4
	AC6000
	TAD I	REG1		/ CHECK FOR RESULT FIELD WHERE TAB
	SMA CLA			/ CANNOT BE FORCED
	JMP	FLDERR		/ IF FOUND, THIS IS AN ERROR!
TAB3,	TAD	(5)		/ ADVANCE TO NEXT ENTRY SLOT
	TAD	REG1
	DCA	REG1
	JMP		TAB1

/****************************SUBROUTINE*********************************/

/ ACCESS DCHAR OR TCHAR AND BCD TABLES

/		CALL WITH   AC = REL. NO. OF DTAB TO CHECK

/		RETURNING   AC = POINTER TO BCD RESULTS
/			  LINK = 1 IF FIELD IS A RESULT FIELD

GETRES,	XX
	AND	P77		/ SUPPRESS FLAG BITS
	TAD	(-1)		/ TABLE ACCESSES COUNT DTAB'S FROM 0
	CLL			/ CLEAR LINE IN CASE OF NULL RETURN
	TAD	DTABPR		/ GET ADDR OF RESULTS TABLE
	DCA	GREG4		/ SET ADDR OF ENTRY IN RESULTS TABLE
	TAD I	GREG4		/ MAKE SURE THERE IS A POINTER IN DCHAR
	SNA			/ OTHERWISE,
	JMP I	GETRES		/ EXIT IF NO POINTER IN DCHAR
	DCA	GREG3		/ SAVE PTR TO DTAB VALUE
	CDFMTH			/ DTAB VALUE IN IN FIELD SIX
	TAD I	GREG3		/ GET FIRST WORD OF VALUE (FLAGS)
	CDFMYF
	AND	(400)		/ SAVE RESULT BIT (1 IF RESULT)
	CLL RTL			/ IN LINK
	RTL
	TAD I	GREG4		/ RETURN POINTER IN AC
	JMP I	GETRES
GREG3,	0
GREG4,	0


/****************************SUBROUTINE*********************************/

/ GET NEXT CODE FROM EDIT BUFFER AND DETERMINE CASE

/ RETURN IS AT RETURN + n as follows:

/ 0	alphanumeric
/ 1	space
/ 2	new line
/ 3	tab
/ 4	own code
/ 5	dead key

NXCASE,	XX
	JMS	SVNTO8		/ GET NEXT CODE
	JMP	NXCR2		/ ETX RETURN GOES TO NEW LINE
	TAD	CRLMB		/ AC=CODE WITHOUT ATTRIBUTES
	TAD	(-ECSPC)	/ MATCH AGAINST SPACE CODE
	SMA SZA			/ IS IT GREATER THAN SPACE
	JMP	NXCR0		/ IT'S GREATER: GO HANDLE ALPHANUMERIC
	SNA			/ IS IT EQUAL TO SPACE
	JMP	NXCR1		/ IT'S   EQUAL: GO HANDLE SPACE
	TAD	(ECSPC-ECTAB)	/ MATCH AGAINST TAB CODE
	SMA SZA			/ IS IT GREATER THAN TAB
	JMP	NXCR2		/ IT'S GREATER: GO HANDLE NEW LINE
	SNA			/ IS IT EQUAL TO TAB
	JMP	NXCR3		/ IT'S EQUAL: GO HANDLE TAB
	TAD	(ECTAB-ECMTH1)	/ MATCH AGAINST OUR OWN INSERT CODE
	SZA CLA			/ IF EQUAL: THEN GO HANDLE OUR OWN CODE
NXCR5,	ISZ	NXCASE		/ DEAD KEY RETURN
NXCR4,	ISZ	NXCASE		/ OUR OWN CODE RETURN
NXCR3,	ISZ	NXCASE		/ TAB RETURN
NXCR2,	ISZ	NXCASE		/ NEW LINE RETURN
NXCR1,	ISZ	NXCASE		/ SPACE RETURN
NXCR0,	CLA			/ ALPHANUMERIC RETURN - CLEAR UNWANTED VALUE
	JMP I	NXCASE		/ RETURN TO CALLER


/D236	NXCASE,	XX
/D236	JMS	READNEXT	/ GET NEXT CODE
/D236	JMP	NXC1		/ ETX RETURN GOES TO NEW LINE
/D236	TAD	CRLMB		/ AC=CODE WITHOUT ATTRIBUTES
/D236	JMS	MATCH		/ MATCH AGAINST SPACE
/D236		ECSPC
/D236	JMP I	NXCASE		/ GREATER:  ALPHANUMERIC
/D236	JMP	NXC1		/ LESS:	   FUNCTION
/D236	ISZ	NXCASE
/D236	JMP I	NXCASE		/ EQUAL:	   SPACE
/D236	NXC1,	ISZ	NXCASE
/D236	ISZ	NXCASE
/D236	TAD	CRLMB
/D236	JMS	MATCH		/ MATCH AGAINST TAB CODE
/D236		ECTAB
/D236	JMP I	NXCASE		/ GREATER:  NEW LINE
/D236	JMP	NXC2		/ LESS:	   DEAD KEY OR OWN CODE
/D236	ISZ	NXCASE		/ EQUAL:	   TAB
/D236	JMP I	NXCASE
/D236NXC2,	ISZ	NXCASE
/D236	ISZ	NXCASE
/D236	TAD	CRLMB
/D236	TAD	(-ECMTH1)	/ MATCH AGAINST OWN INSERT CODE
/D236	SZA CLA			/ EQUAL:    OWN INSERT CODE
/D236	ISZ	NXCASE		/ UNEQUAL:  DEAD KEY
/D236	JMP I	NXCASE

/****************************SUBROUTINE*********************************/

/ CKCTRS	Moved here to gather space in one place elsewhere	/a247

/ ROUTINE USED IN "CKCTRL" TO SEE IF IN A CONTROL BLOCK OR NOT. DOES A
/ SKIP RETURN IF IN BLOCK AND A NORMAL RETURN IF NOT.

CKCTRS,	XX
	CDFEDT			/ CHANGE OVER TO EDITOR DATA FIELD
	TAD I	(PCTLFL)	/ GET CONTROL BLOCK FLAG
	CDFLP			/ BACK TO THIS DATA FIELD
	SPA CLA			/ FOUND A CONTROL BLOCK?
	ISZ	CKCTRS		/  YES: SET UP SKIP RETURN
	JMP I	CKCTRS		/  NO: DO NORMAL RETURN

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/****************************SUBROUTINE*********************************/

/D236	/ MATCH CONTENTS OF AC TO PARAMETER CODE
/D236	/ CALLING SEQUENCE IS:
/D236	/	     AC=CODE1
/D236	/	JMS	MATCH
/D236	/		CODE2
/D236	/	  -RETURN IF CODE1 > CODE2
/D236	/	  -RETURN IF CODE1 < CODE2
/D236	/	  -RETURN IF CODE1 = CODE2
/D236	MATCH,	0
/D236	CIA
/D236	TAD I	MATCH
/D236	ISZ	MATCH
/D236	SMA
/D236	ISZ	MATCH
/D236	SNA CLA
/D236	ISZ	MATCH
/D236	JMP I	MATCH

/****************************SUBROUTINE*********************************/

/ STMPDK	SToMP on Dead Keys.  This routine tests the character	/a247
/		in the edit buffer pointed to by the AC on entry.  If	/a247
/		it is an End of Dead Key, previous characters will be	/a247
/		overwritten until an Start of Dead key is found.  If it	/a247
/		is not, then just this character is overwritten.	/a247
/
/		Calling sequence should be:-				/a247
/
/			AC=Address of character				/a247
/			CDFBUF						/a247
/			JMS	STMPDK					/a247

STMPDK,	XX			/ Stomp on poor, unsuspecting dead keys	/a247
	DCA	DELPTR		/ Store the address passed in the AC	/a247
	TAD I	DELPTR		/ Get the character at this address	/a247
	TAD	(-ECNDOV)	/ Test for End of Dead Key character	/a247
	SZA CLA			/ Is this a Dead Key Sequence?		/a247
	JMP	NOSTMP		/ No, only stomp this character		/a247
FNDEND,	TAD I	DELPTR		/ Get the character again		/a247
	MQL			/ Save it				/a247
	DCA I	DELPTR		/ Stomp on character in Dead Key	/a247
	AC7777			/ Backup to previous character		/a247
	TAD	DELPTR		/					/a247
	DCA	DELPTR		/					/a247
	TAD I	DELPTR		/ And get it				/a247
	TAD	(-ECSTOV)	/ Test for Start of Dead character	/a247
	SZA CLA			/ Have we stomped all the Dead Key yet?	/a247
	JMP	FNDEND		/ No, still got to find the Start	/a247
NOSTMP,	DCA I	DELPTR		/ Delete the character (or Start Dead)	/a247
	JMP I	STMPDK		/ Return				/a247

DELPTR,	0

/****************************SUBROUTINE*********************************/

/ GET BEGINNING & ENDING FIELD BOUNDARYS FROM FLDDIM

/ REG1 IS ASSUMED TO POINT TO THE NEXT
/ ITEM IN THE TABLE TO BE ACCESSED.
/ REG1 WILL NOT BE CHANGED UNLESS A DUMMY
/ ENTRY IS ENCOUNTERED, IN WHICH CASE REG1
/ WILL BE LEFT POINTED TO THE NEXT NON-DUMMY ENTRY.

GETITEM,XX
	TAD	REG1		/ GET POINTER & INITIALIZE WORKING POINTER
	DCA	REG2
	TAD I	REG2		/ CHECK FOR RESULT FIELD (AC0=1)
	SMA CLA
	JMP	GETIT1
	TAD I	GETITEM		/ NEW OR OLD CONTENTS WANTED?
	SNA CLA
	JMP	GETIT1
	ISZ	REG2		/ GET NEW RESULT FIELD & COMPUTE BOUNDARIES
	TAD I	REG2		/ GET DTAB PCP
	AND	P377
	DCA	GTREG
	ISZ	REG2
	ISZ	REG2
	ISZ	REG2
	TAD I	REG2		/ GET WORD:  LEFT BYTE=NO. LT DIGITS
	AND	P77		/	    RIGHT BYTE=NO. RT DIGITS
	TAD	(-1)
	TAD	GTREG		/ RIGHT BOUNDARY=PCP-1+NO.RT DIGITS
	MQL			/ MQ=RIGHT BOUNDARY
	TAD I	REG2
	BSW
	AND	P77		/ LEFT BOUNDARY=PCP-NO.LT DIGITS
	CIA
	TAD	GTREG		/ AC=LEFT BOUNDRY,MQ=RIGHT BOUNDRY
	JMP	GETIT5		/ THEN EXIT
GETIT1,	AC2000
	AND I	REG2		/ CHECK FOR A FORCED-TAB ENTRY
	SNA CLA			
	JMP	GETIT2
	ISZ	REG2		/ IF FORCED-TAB, THEN SET BOUNDRIES
	TAD I	REG2
	AND	P377
	MQL
	ACL
	JMP 	GETIT5
GETIT2,	ISZ	REG2		/ CHECK FOR END OF FLDDIM
	TAD I	REG2
	ISZ	REG2
	SZA CLA
	JMP	GETIT3
	TAD I	REG2		/ IF BOTH TABPCP & BEGFLD = 0, THEN
	SNA CLA
	JMP	GETIT6		/ EXIT, END OF FLDDIM, NON-SKIP RETURN

GETIT3,	TAD I	REG2		/ CHECK FOR DUMMY ENTRY IN FLDDIM, SKIPPED TAB
	SZA			/ POSITION,I.E. BEGFLD=0
	JMP	GETIT4
	TAD	REG1		/ SKIPPED ENTRY: SETUP RETURN AC=0 & MQ=TABPCP
	IAC
	DCA	REG2
	TAD I	REG2		/ SET AC=TABPCP
	AND	P377
	MQL			/ SET MQ=TABPCP - AC=0
	JMP	GETIT5
GETIT4,	MQL			/ NORMAL ENTRY,MQ=LEFT BOUNDARY
	ISZ	REG2
	TAD I	REG2		/ AC=RIGHT BOUNDARY
	SWP			/ AC=LEFT BOUNDARY, MQ=RIGHT BOUNDARY
GETIT5,	ISZ	GETITEM		/ NORMAL SKIP EXIT
GETIT6,	ISZ	GETITEM		/ END OF LIST NON-SKIP EXIT
	JMP I	GETITEM
GTREG,	0


/****************************SUBROUTINE*********************************/

/ INSERT CODE FOUND IN AC INTO TEXT STREAM AT CURRENT CURSOR VALUE
/ THEN BYPASS THIS CODE PLUS THE FOLLOWING CODE

/ AC=CODE TO INSERT INTO EDIT BUFFER

INSFORCE,XX
	JMS	INSCODE		/ ECMTH1 CODE TO MARK FIELD BEGINNING
	JMS	READNEXT	/ AFTER INSERT, AVOID RE-READING
	NOP			/ INSERTED CODE
	JMP I	INSFORCE

/****************************SUBROUTINE*********************************/

/ INSERT CODE INTO EDIT BUFFER

/ AC=CODE TO INSERT INTO EDIT BUFFER

INSCODE,XX
	CIFEDT
	JMS	CALLAR		/ CALL INSERT ROUTINE
		INSERT
		CDFBUF
	JMP I	INSCODE

/****************************SUBROUTINE*********************************/

/ CLEAR AN AREA TO ZEROS
/
/		JMS	  CLRZER
/		-PTR TO START OF ZONE TO CLEAR
/		-NEG. OF NUMBER OF WORDS TO CLEAR

CLRZER,	XX
	TAD I	CLRZER		/ INITIALIZE POINTER
	DCA	REG2
	ISZ	CLRZER
	TAD I	CLRZER		/ INITIALIZE COUNTER
	DCA	REG1
	ISZ	CLRZER
CLRZ1,	DCA I	REG2		/ CLEAR ONE LOCATION
	ISZ	REG2		/ ADVANCE POINTER
	ISZ	REG1		/ LOOP UNTIL COUNTER=0
	JMP	CLRZ1
	JMP I	CLRZER

/****************************SUBROUTINE*********************************/

/ PCP=PCP+XPCP

INSEXTR,XX
	TAD	PCP		/ ADVANCE POSITION PTR PAST
	TAD	XPCP		/   ANY EXTRA SPACES
	DCA	PCP		/   PCP = PCP + XPCP
	JMP I	INSEXTR

/****************************SUBROUTINE*********************************/

/ CHECK FOR TYPE OF FIELD & ADJUST ENDFLD ACCORDING TO CASE

SETFEND,XX
	AC2000
	AND	TABPCP		/ IF '>' FIELD &
	SNA
	JMP	SETFE1
	RAR			/ THAT FIELD IS NOT BLANK
	AND	TABPCP		/ THEN TAKE SKIP RETURN
	SNA CLA
	SKP
SETFE1,	JMS	INSBLANK	/ ELSE, CHECK FOR BLANK (TAB-ONLY) FIELD
	ISZ	SETFEND
	JMP I	SETFEND

/****************************SUBROUTINE*********************************/

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/****************************SUBROUTINE*********************************/

/ CHECK FOR BLANK FIELD & TAKE NON-SKIP RETURN IF NOT BLANK

INSBLANK,XX
	TAD I	GETF2A		/ IF FIELD ACCESSED IS NEW CONTENTS
	TAD	NEWLIT		/ THEN
	SZA CLA			/ DO CHECK
	JMP	INSBL0		/ FOR RESULT FIELD
	TAD	FLAGS		/ FIRST CHECK FOR RESULT FIELD
	SPA CLA
	JMP I	INSBLANK	/ IF SO, TAKE NON-BLANK RETURN
INSBL0,	AC2000			/ ELSE, CHECK FOR FORCE-TAB BIT
	AND	FLAGS
	SZA CLA
	JMP	INSBL1		/ IF SET, TAKE BLANK RETURN
	AC2000			/ ELSE, IF BLANK BIT SET
	RAR			/ (AC2000 & RAR=2000,NO LITERAL
	AND	TABPCP		/ THEN TAKE BLANK RETURN
	SZA CLA
INSBL1,	ISZ	INSBLANK	/ IF BLANK DO SKIP RET.
	JMP I	INSBLANK   	/ IF NON-BLANK, RETURN
GETF2A,	GETF2			/ MUST AVOID ASSEMBLY ADDR AT FOOT OF PAGE
NEWLIT,	-NEWCON			/ DITTO

/****************************SUBROUTINE*********************************/
/ INMATH	Moved here this edit to gather space together elsewhere	/a247

/ THIS ROUTINE MAKES A SKIP RETURN IF WE ARE IN A MATH AREA OR A CONTROL
/ BLOCK AND A REGULAR RETURN IF NOT
INMATH,	XX			/
	CLA			/
	CDFEDT			/ SET TO EDITORS DATA FIELD
	TAD I	XPCTLFL		/ TEST CONTROL_BLOCK FLAG
				/	=0 IF NOT IN CONTROL BLOCK
				/      =-1 IF IN A CONTROL BLOCK
	CIA			/     AC=0 IF IN     = 1 IF NOT IN
	CDFMYF			/
				/     =0 IF NOT IN MATH AREA
				/     =1 IF IN A MATH AREA
	ISZ	INMATH		/    BUMP RETURN ADDRESS IF EITHER
				/	FLAG IS SET
	JMP I	INMATH		/ RETURN

XPCTLFL,PCTLFL			/ It says above that auto links should	/a247
				/ not be generated.  Who am I to argue?	/a247

/***********************************************************************/
/									/
/			ALLOCATE TABLE AREA				/
/									/
/***********************************************************************/

/ THE TABLE FLDDIM IS COMPRISED OF FIVE WORDS PER ENTRY, AS FOLLOWS:
/
/ FLAGS		BIT 0=1		INDICATES RESULT FIELD
/		BIT 1=1		INDICATES TAB MUST BE INSERTED
/		BITS 2-4	FIELD/CHARACTER ATTRIBUTES
/		BITS 6-11	GIVES DTAB NUMBER OF DTAB FIELDS
/
/ TABPCP	BIT 0=1		INDICATES 'R' ENTRY
/		BIT 1=1		INDICATES '>' 'J' OR 'R' ENTRY
/		BIT 2=1		INDICATES FIELD WITHOUT DATA,TAB ONLY
/		BITS 4-11	GIVES POSITION OF TAB
/
/ BEGFLD	BITS 0-11	GIVES POSITION OF FIELD BEGINNING,
/				FIRST NON-SPACE CODE IN THE FIELD
/
/ ENDFLD	BITS 0-11	GIVES POSITION OF FIELD ENDING,
/				LAST NON-SPACE CODE IN THE FIELD,
/				UNLESS THE FIELD IS RIGHT
/				JUSTIFIED, IN WHICH CASE SPACES
/				ARE COUNTED
/
/ RESULTS	BITS 0-5	NUMBER OF POSITIONS TO THE
/				LEFT OF THE DECIMAL POINT
/		BITS 6-11	NUMBER OF POSITIONS TO THE
/				RIGHT OF THE DECIMAL POINT
/				AND INCLUDING THE DECIMAL POINT
/

FLDDIM,	ZBLOCK	5^MXTABS+3

/ ALLOCATE BUFFER TO HOLD ASCII NUMBER CONVERTED FROM BCD PRIOR TO
/ BEING INSERTED INTO THE EDIT BUFFER!

NUMBUF,	ZBLOCK	MXASCII+1


	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED

/ PSEUDO-CODE TO SET UP SYMBOL TABLE ENTRIES FROM EDITOR MATH TO FIT INTO
/ TABLES THAT HOLD POINTERS TO THE VALUES OF ":Dnn" and ":Tnn".

/ START PROGRAM
/
/ GET LEAD CHAR
/
/ IF  (LEAD CHAR = "D" OR "T") AND NOT LAST CHAR
/ THEN SET UP CORRESPONDING TABLE FOR ENTRY
/ |    GET NEXT CHAR
/ |    IF NOT LAST CHAR
/ |    THEN IF CHAR VALUE RANGE = NUMERICAL 1 TO 3
/ |    |    THEN CALCULATE FIRST PART OF OFFSET TO TABLE
/ |    |    |    GET NEXT CHAR
/ |    |    |    IF LAST CHAR AND CHAR VAL RANGE = NUM 0 TO 9
/ |    |    |    THEN CALCULATE REST OF OFFSET TO TBL
/ |    |    |    |    PUT SYM VALUE PTR IN TABLE
/ |    |    |    ENDIF
/ |    |    ENDIF
/ |    ELSE IF CHAR VALUE RANGE = NUMERICAL 1 TO 9
/ |    |    THEN CALCULATE OFFSET TO TABLE
/ |    |    |    PUT SYM VALUE PTR IN TABLE
/ |    |    ENDIF
/ |    ENDF
/ ENDIF
/
/ RETURN TO CALLER
/
/ END PROGRAM
/


/ VALUES USED IN EDITOR MATH SYMBOL NAME PROCESSING CODE

STRMT1,	0	/ CONTAINS SYM PTR TABLE PTR TO SYM NAME PTR
STRPTR,	0	/ CONTAINS PTR TO SYM NAME IN SYMBOL TABLE
HLDTBL,	0	/ CONTAINS BASE ADDR OF TABLE TO INSERT SYM VAL PTR
TBLOFS,	0	/ CONTAINS OFFSET INTO TABLE WHERE TO PUT SYM VAL PTR

/ ROUTINE TO RUN CHECK ON SYMBOLS ADDED TO SYMBOL TABLE WHEN IN EDITOR MATH
/ NOTE - RETAIN MATH DATA FIELD TO SET UP POINTERS

CHKNME,	XX
	DCA	STRMT1		/ POINTER & SAVE IT
	TAD I	STRMT1		/ INDIRECT THRU IT TO GET PTR TO  NAME IN SYM TABLE
	DCA	STRPTR		/ SAVE IT

/ CHECK IF FIRST LETTER (AFTER THE COLON) OF THE SYM NAME IS A  "T"
/ OR "D"

	ISZ	STRPTR		/ ADVANCE START OF NAME PTR TO SKIP ":"
	TAD I	STRPTR		/ GET FIRST CHAR AFTER COLON
	SPA			/ IF IT IS LAST CHAR IN NAME
	JMP	EXTCHK		/ THEN EXIT (NOT A VALID COLUMN NAME)
	TAD	(-"D+200)	/ GET NEGATIVE 7 BIT ASCII VALUE FOR A "D"
	SNA			/ IS THE CHAR A "D"?
	JMP	DTAB		/  YES: GO SET UP FOR RIGHT TABLE IF PROCESS IT
	TAD	("D-"T)		/  NO:  RESET AC AND GET NEG OF ASCII FOR "T"
	SZA CLA			/ IF CHAR NOT A "T"
	JMP	EXTCHK		/ THEN EXIT (NOT A VALID COLUMN NAME)
	TAD	(TCHAR-DCHAR)	/ GET START OF "T"PROCESSING TABLE
DTAB,	TAD	(DCHAR)		/ GET START OF "D" PROCESSING TABLE
	DCA	HLDTBL		/ INITIALIZE D OR T PROCESSING TABLE

/ CHECK FOR SYMBOL NAME SIZE

CONCHK,	ISZ	STRPTR		/ MOVE DOWN TO NEXT CHAR IN NAME
	TAD I	STRPTR		/ GET NEXT CHARACTER IN NAME
	SPA			/ IF THIS IS THE LAST CHAR
	JMP	PRSONE		/ THEN GO TO HANDLE A ":Dn" NAME

/ PROCESS TWO DIGITS LEFT AFTER "D" OR "T"

	JMS	RNGECK		/ CHECK THE RANGE ON THE DIGIT
	-"1+200			/ PASS NEGATIVE OF LOWER LIMIT OF RANGE
	-"3+200			/ PASS NEGATIVE OF UPPER LIMIT OF RANGE
	JMP	EXTCHK		/ IF NOT IN RANGE THEN EXIT (NOT A VALID COLUMN NAME)
				/ RETURN HERE IF IN RANGE SPECIFIED -
	CLL RAL			/ MULTIPLE IT BY 2
	DCA	TBLOFS		/ SAVE IT
	TAD	TBLOFS		/ GET IT BACK
	CLL RTL			/ MULTIPLE IT BY 8
	TAD	TBLOFS		/ ADD MULTIPLICATON BY 2
	DCA	TBLOFS		/ SAVE THE NUM AS PART OF AN OFFSET TO THE TABLE
	ISZ	STRPTR		/ SET PTR TO SECOND OF TWO DIGITS
	TAD I	STRPTR		/ GET THE CHAR
	SMA			/ IF NOT THE LAST CHAR
	JMP	EXTCHK		/ THEN EXIT (NOT A VALID COLUMN NAME)
	AND	P177		/ STIP OFF MINUS BIT (WHICH INDICATES LAST CHAR)
	JMS	RNGECK		/ CHECK THE RANGE ON THE DIGIT
	-"0+200			/ PASS NEGATIVE OF LOWER LIMIT OF RANGE
	-"9+200			/ PASS NEGATIVE OF UPPER LIMIT OF RANGE
	JMP	EXTCHK		/ RETURN HERE IF NOT IN RANGE - RETURN TO CALLER
				/ RETURN HERE IF IN RANGE AC = 0 TO 9
	TAD	TBLOFS		/ ADD IN THE VALUE OF  FIRST DIGIT * 10
	JMP	SAVSYM		/ GO INSERT PTR TO SYM NAME VALUE IN THE TABLE

/ PROCESS ONE DIGIT LEFT AFTER "D" OR "T"

PRSONE,	AND	P177		/ STRIP OFF SIGN BIT
	JMS	RNGECK		/ CHECK THE RANGE ON THE DIGIT
	-"1+200			/ PASS NEGATIVE OF LOWER LIMIT OF RANGE
	-"9+200			/ PASS NEGATIVE OF UPPER LIMIT OF RANGE
	JMP	EXTCHK		/ RETURN HERE IF NOT IN RANGE - RETURN TO CALLER
/ RETURN HERE IF IN RANGE - AC = CHAR - 60

/ INSERT PTR TO SYMBOL NAME VALUE INTO THE APPROPRIATE TABLE

SAVSYM,	DCA	TBLOFS		/ SAVE OFFSET INTO TABLE
	AC7777			/ DECREMENT TABLE ADDRESS BY 1 TO ALLOW THE USE
				/ OF THE FIRST LOC OF TBL,SINCE NEVER SEE "<:D0>"
	TAD	HLDTBL		/ GET START OF TABLE TO PROCESS CHAR
	TAD	TBLOFS		/ GET OFFSET TO THE TABLE
	DCA	TBLOFS		/ USE IT TO SET UP A POINTER
	CDFLP			/ RETURN TO LP DATA FIELD
	AC0002			/ SET TO MOVE PTR BY FORMAT WORD TO START OF VALUE
	TAD	STRPTR		/ ADD TO IT PTR TO END OF SYM NAME
	DCA I	TBLOFS		/ PLACE IT INTO THE PROPER PLACE IN THE TABLE
EXTCHK,	CDIMTH			/ SET PROGRAM CONTROL BACK TO MATH FIELD
	CLA
	JMP I	CHKNME		/ RETURN TO CALLER IN MATH FIELD

/ ROUTINE TO RANGE CHECK ON A SPECIFIC CHARACTER. CALL TO THIS ROUTINE IS
/ SET UP AS FOLLOWS:
/ 		     .
/ 		     .
/		(CHAR TO BE CHECKED PASSED IN THE AC)	/
/		JMS	RNGECK				/
/ 		   (NEGATIVE OF LOWER LIMIT OF RANGE)	/
/		   (NEGATIVE OF UPPER LIMIT OF RANGE)	/
/	 	RETURN HERE IF NOT IN RANGE		/
/		RETURN HERE IF IN RANGE			/
/		(AC HAS CHAR -60 ON EXIT WEATHER FOUND OR NOT)
/		     .

RNGCHR, 0			/ CHAR PASSED IN AC

RNGECK,	XX			/ RANGE CHECK ROUTINE
	CDFLP			/ CDF TO MY FIELD
	DCA	RNGCHR		/ SAVE CHAR PASSED FOR RANGE CHECK
	TAD I	RNGECK		/ GET NEG OF LOW END OF RANGE
	TAD	RNGCHR		/ ADD TO IT CHAR FOR CHECK
	SPA CLA			/ IS CHAR IN RANGE?
	JMP	OUTRNG		/  NO: SET SKIP RETURN TO PROCESS ACCORDINGLY
	ISZ	RNGECK		/  YES: SET P.C. TO PICK UP UPPER RANGE LIMIT
	TAD I	RNGECK		/ GET NEG OF UPPER LIMIT INTO AC
	TAD	RNGCHR		/ ADD TO IT CHAR FOR CHECK
	SPA SNA CLA		/ IS CHAR IN RANGE?
OUTRNG,	ISZ	RNGECK		/  YES: SET RETURN TO PROCESS ACCORDINGLY
	ISZ	RNGECK		/  NO: SET RETURN TO SKIP PROCESSING
	CDFMTH			/ CDF BACK TO MATH FIELD
	TAD	RNGCHR		/ GET DIGIT BACK IN AC
	TAD	(-60)		/ CHANGE FROM ASCII TO BINARY
	JMP I	RNGECK		/ RETURN TO CALLER

/ Here on a Gold Bottom request.  Gold Bottom goes to the end of the
/ descriptor list and then backs up 10 blocks.  if the last ruler found
/ was below the 10 blocks, the wrong ruler will be loaded for the scroll.
/ this routine starts searching from this 10th block up, looking for the
/ first ruler.  when found return to load this ruler and continue the
/ scroll

/	delete this logic from GOLD_BOTTOM...			/A195

/D195RULCHK,	XX			/ SAVE CALLERS RETURN ADDRESS
/D195	TAD I	(RPCUOF)	/ SAVE CURRENT OFFSET
/D195	DCA I	(RPMTBK)	/ FOR SCROLL AFTER FINDING RULER
/D195	TAD I	(RPCUBK)	/ ALONG WITH BLK ID #
/D195	DCA I	(RPBKID)
/D195	JMS	BACK1		/ GO LOOK FOR BLK W/RULER
/D195	CIFEDT			/ FOR RETURN TO OVERLAYS
/D195	JMP I	RULCHK		/ RETURN

/ routine sets up blocks for ruler load and resets blocks for scroll

BACK3,	TAD I	(RPCUOF)	/ RULER FOUND AT THIS OFFSET
	DCA I	(RPMTRL)	/ SET UP THE BLKS FOR THE RULER LOAD
	TAD I	(RPCUBK)	/ BLK ID #
	DCA I	(RPRLHN)
	TAD I	(RPMTBK)	/ RETRIEVE LOC. FOR START OF SCROLL
	DCA I	(RPCUOF)	/ CURRENT OFFSET FOR START
				/ BLK ID IS SET UP ON RETURN LOC IN OVERLAY
	JMP	BACK4		/ RETURN


/ THE FOLLOWING ROUTINE IS CALLED FROM WITHIN "CKCTRL". IT IS USED TO
/ MAKE SURE THAT THE 1ST TIME A CONTROL BLOCK IS ENCOUNTERED, IT IS
/ THE FIRST LINE AFTER THE "START CONTROL" CHAR. THIS IS NECESSARY
/ SINCE SUCH THINGS AS A "GOLD-BOTTOM" OR "BACK-UP LINE" CAN LEAVE THE
/ USER IN ANY KIND OF A  CONTROL BLOCK SITUATION, BUT NOT NECESSARILY ON
/ THE FIRST LINE OF THAT CONTROL BLOCK. IF HOWEVER THE LINE THE USER IS
/ LEFT ON STARTS WITH A "WPSMATH" (CR) "BEGIN" (CR), EVEN IF THERE ARE
/ ILLEGAL MATH CTRL BLOCK LINES PRECEEDING IT, THE CODE WILL THINK IT IS
/ THE BEGINNING OF A VALID EDITOR MATH WORK AREA. THIS CODE IS INSURANCE
/ THAT THIS WILL NOT HAPPEN.


STLOC2,	0			/ LOC TO HOLD ADDR TO START OF 2ND LINE FROM
				/ THE BOTTOM OF THE SCREEN, KEEP ON SAME PAGE
				/ WITH "STLOC1" ROUTINE

STLOC1,	XX
	CDFEDT			/ CHANGE TO EDITOR DATA FIELD
	TAD I	(PTRBLK+NPTRS-2)/ PTR TO THE 2ND LINE FROM THE BOTTOM
	DCA	STLOC2		/ SAVE IT
	CDFBUF			/ CHANGE TO EDIT BUFFER DATA FIELD
	TAD I	STLOC2		/ GET THE FIRST CHAR ON THAT LINE
	CDFMYF			/ RETURN TO THIS DATA FIELD
	TAD	(-ECPCT1)	/ ADD TO IT NEGATIVE OF "START CTRL" CHAR
	SZA CLA			/ IS 2ND LINE FROM BOTTOM A "START CONTROL"?
	ISZ	STLOC1		/  NO: SET SKIP RETURN TO HANDLE
	JMP I	STLOC1		/  YES: NORMAL RETURN TO CONTINUE PROCESSING

/ DELCODE	moved here to gather space elsewhere in one place	/a247
/ DELETE CODE FROM EDIT BUFFER

DELCODE,XX
	CDFEDT
	TAD I	(CURPTR)	/ DELETE BY OVERWRITING CODE POINTED TO
/d247	DCA	DELPTR		/ BY CURPTR WITH A NULL
	CDFBUF
	DCA	DELTEMP		/ Save the pointer			/a247
	TAD I	DELTEMP		/ Get it back to save in the MQ register/a247
	MQL			/ ...					/a247
	TAD	DELTEMP		/ Get the address back to pass on	/a247
/d247	TAD I	DELPTR		/ GET CODE TO SAVE ATTRIBUTES
	JMS	STMPDK		/ Stomp on the character pointed to	/a247
/d247	MQL
/d247	DCA I	DELPTR
	CDFMYF
	JMP I	DELCODE

DELTEMP,0

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED

TRANTP=.			/ TOP OF TRANSLATIONS PAGE		/A258
/ THESE MESSAGES BROUGHT IN FROM THE EDITOR OVERLAYS. THEY ARE SPECIAL
/ IN THAT THEY ARE NEVER USED WHILE IN LIST PROCESSING.










EIFND1,
	IFDEF ENGLSH < TEXT "!&ENTER !&PHRASE: " >
	IFDEF V30NOR < TEXT "!&ANGI !&UTTRYKK: " >
	IFDEF V30SWE < TEXT "&SKRIV FRAS: " >
	IFDEF SPANISH < TEXT "&TECLEE &FRASE: " >			/A255
	IFDEF ITALIAN <TEXT "&INTRODURRE LA FRASE:" >
	IFDEF CANADA < TEXT "&TAPER &L'&EXPRESSION: " >
	IFDEF FRENCH < TEXT "&TAPER &L'&EXPRESSION : " >
	IFDEF DUTCH  < TEXT "&TYP &DE &ZOEKTEKST: " >
	IFDEF GERMAN < TEXT "&BEGRIFF &EINGEBEN: " >
	IFDEF NORWAY < TEXT "&SKRIV &S\KEBEGREP: " > 	/L.PHI
	IFDEF SWEDSH < TEXT "&SKRIV &S\KBEGREPP: " > 	/L.U.O
	IFDEF DANISH < TEXT "&SKRIV &S\GEBEGREP : " >	/L.PHI

EIGES1,
	IFDEF ENGLSH < TEXT "!&ENTER !&NAME: " >
	IFDEF V30NOR < TEXT "!&ANGI !&NAVN: " >
	IFDEF V30SWE < TEXT "&SKRIV NAMN: " >
	IFDEF SPANISH < TEXT "&TECLEE &NOMBRE: " >			/A255
	IFDEF ITALIAN <TEXT "&INTRODURRE IL NOME:" >
	IFDEF CANADA < TEXT "&TAPER &LE &NOM: " >
	IFDEF FRENCH < TEXT "&TAPER &LE &NOM : " >
	IFDEF DUTCH  < TEXT "&TYP &DE &NAAM: " >
	IFDEF GERMAN < TEXT "&NAME &EINGEBEN: " >
	IFDEF NORWAY < TEXT "&SKRIV &NAVN: " >
	IFDEF SWEDSH < TEXT "&SKRIV &NAMN: " >
	IFDEF DANISH <TEXT "&SKRIV &NAVN : " >

EIGER2,
	IFDEF ENGLSH < TEXT "!&NOT !&FOUND-!&REENTER: " >
	IFDEF V30NOR < TEXT "!&IKKE !&FUNNET-!&LEGG INN P\E NYTT: " >
	IFDEF V30SWE < TEXT "&HITTAS INTE - &F\VRS\VK IGEN: " >
	IFDEF SPANISH < TEXT "&NO &SE &ENCUENTRA-&TECLEE OTRA VEZ: " >/A255
	IFDEF ITALIAN <TEXT "&NON TROVATO - &REINTRODURRE:" >
	IFDEF CANADA < TEXT "&INTROUVABLE-&REESSAYER:">
	IFDEF FRENCH < TEXT "&INTROUVABLE--&REESSAYER : " >/L.A.E
	IFDEF DUTCH  < TEXT "&NIET &AANWEZIG-&PROBEER &OPNIEUW: " >
	IFDEF GERMAN < TEXT "&NICHT &GEFUNDEN--&NOCH &EINMAL: " >
	IFDEF NORWAY < TEXT "&IKKE &FUNNET--&PR\V &IGJEN: " > /L.PHI
	IFDEF SWEDSH < TEXT "&FINNS &INTE--&F\RS\K &IGEN: " > /L.U.O, L.U.O
	IFDEF DANISH <TEXT "&IKKE &FUNDET--&PR\V &IGEN : " >/ L.PHI

/ FOLLOWING TEXT STATEMENTS MOVED IN FROM EDITOR OVERLAYS SINCE THEY
/ MUST NOW RESIDE IN FIELD 5
RANBAD,	
	IFDEF ENGLSH <	TEXT " - &UP &TO 4 &DIGITS &ALLOWED" >
	IFDEF V30NOR <	TEXT " - &INNTIL 4 SIFFER ER TILLATT" >
	IFDEF V30SWE <	TEXT " - &MAXIMALT 4 TECKEN \DR TILL\ETNA" >
	IFDEF SPANISH <	TEXT " - &SE &PERMITE &HASTA 4 &D\MGITOS" >		/A255
	IFDEF ITALIAN <	TEXT " - &MAX. 4 CIFRE" >
	IFDEF DUTCH <   TEXT " - &MAX. 4 CIJFERS">

CHABAD,	
	IFDEF ENGLSH <	TEXT " - &NUMBERS &ONLY &PLEASE" >
	IFDEF V30NOR <	TEXT " - &BARE TALL" >
	IFDEF V30SWE <	TEXT " - &SKRIV ENDAST TAL" >
	IFDEF SPANISH <	TEXT " - &S\SLO &N\ZMEROS" >		/A255
	IFDEF ITALIAN <	TEXT " - &SOLO NUMERI" >
	IFDEF DUTCH   < TEXT " - &GEBRUIK ALLEEN CIJFERS" >


RPPME9,	
	IFDEF ENGLSH <	TEXT " - &MULTIPLE &MATH &START &BLOCKS" >
	IFDEF V30NOR <	TEXT " - &FLERE &START-BLOKKER FOR &REGNING" >
	IFDEF V30SWE <	TEXT " - &FLERTAL &MATEMATIK &START &BLK" >
	IFDEF SPANISH <	TEXT " - &BLOQUES &INICIO &MAT &M\ZLTIPLE" >	/A255
	IFDEF ITALIAN <	
TEXT " - &C'\H UN SECONDO COMANDO !&INIZIO NELL'AREA MATEMATICA" >
	IFDEF DUTCH  < TEXT " - &MEERDERE !&BEGIN (REKENEN) OPDRACHTEN" >

RPPRETRY,
	IFDEF ENGLSH <	TEXT " - &PRESS !&RETURN &TO &CONTINUE" >
	IFDEF V30NOR <	TEXT " - &TRYKK P'E !&RETUR FOR \E FORTSETTE" >
	IFDEF V30SWE <	TEXT " - &TRYCK P\E RETUR F\VR ATT FORTS\DTTA" >
	IFDEF SPANISH <	TEXT " - &PULSE !&RETORNO &PARA &CONTINUAR" >	/A255
	IFDEF ITALIAN <	TEXT " - &PREMERE !&RETORNO" >
	IFDEF DUTCH   < TEXT " - &DRUK OP !&RETURN" >

EIRPG1,	
	IFDEF ENGLSH <	TEXT "&ENTER &PAGE &NUMBER:" >
	IFDEF V30NOR <	TEXT "&ANGI SIDETALL:" >
	IFDEF V30SWE <	TEXT "&SKRIV SIDNUMMER:" >
	IFDEF SPANISH <	TEXT "&TECLEE &PAG. &N\ZMERO:" >			/A255
	IFDEF ITALIAN <	TEXT "&INTRODURRE IL NUMERO DI PAGINA:" >
	IFDEF DUTCH   < TEXT "&TYP HET PAGINA-NUMMER: " >

EIRRAB,	
	IFDEF ENGLSH <	TEXT "&PRESS !&ADVANCE OR !&BACK !&UP" >
	IFDEF V30NOR <	TEXT "&TRYKK P'E !&FREM EL. !&TILBAKE" >
	IFDEF V30SWE <	TEXT "&TRYCK P\E FRAM\ET ELLER BAK\ET" >
	IFDEF SPANISH <	TEXT "&PULSE !&ADELANTE O !&ATRAS" >	/A255
	IFDEF ITALIAN <	TEXT "&PREMERE !&AVANTI O !&INDIETRO" >
	IFDEF DUTCH  <	TEXT "&DRUK OP !&VOORUIT OF !&TERUG" >

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE
IFNZRO	.-TRANTP-200	<?TRANS TOO BIG>				/A258

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED

/ THE FOLLOWING IS PART OF THE EDITOR MATH ERROR REPORTING CODE.

/ This routine places a caret ("^"), on line 6. if wide screen and
/ on line 16. if narrow screen, in the column which was passed
/ to this routine in the ac.
EDRTW,				/ subroutine head used for temporary storage
EDRCOL,	XX
	CDFEDT
	TAD I	(LOWLIM)	/ ADD LOWLIMIT TO COLUMN NUMBER	TO MAKE
				/  SURE THAT CARET CAN BE PLACED IN
				/  POSITION PASSED TO EDRCOL.
	DCA	EDRTX		/ SAVE RESULT
	TAD	EDRTX		/ POSITION LESS THAN LEFT SCREEN LIMIT?
	SPA SNA			/ SKIP IF: NOT
	JMP	EDRCO1		/ EXIT (CAN'T DISPLAY CARET)
	TAD	(-205)		/ POSITION GTR THAN RIGHT SCREEN LIMIT?
	SMA CLA			/ SKIP IF: NOT (OK TO DISPLAY CARET)
	JMP	EDRCO1		/ EXIT (CAN'T DISPLAY CARET)

	TAD	(-7)		/ set line number
	DCA I	(CURLIN)
	CDFMYF
	TAD	EDRTX		/ get the column number
	CIFEDT			/ position the cursor
	JMS	CALLAR
		PCUR
		CDFEDT
	TAD	("^&177)	/ write the caret
	CIFEDT
	JMS	CALLAR
		EDOCHR
		CDFEDT
EDRCO1,	CLA CLL
	CDFMYF
	JMP I	EDRCOL

/ This routine gets the next argument from EDERR's arg list,
/ which is a pointer to the oversize result in BCD.  (The arg list
/ will have one or two such args.)  The BCD result must be translated
/ into ASCII for IOA, and then displayed at the location which
/ was passed to this routine in the ac.
EDRTX,				/ subroutine head used for temporary storage
EDRDYR,	XX
	DCA	EDRPSN		/ put cursor position in IOA call
	ISZ	EDRALP		/ get next argument less one
	TAD	EDRALP
	DCA	EDRTW
	AC7777
	TAD I	EDRTW
	DCA	EDRBCD		/ put it in BCDASC call
	JMS	BCDASC		/ call the conversion routine
EDRBCD,		.-.
		NUMBUF		/ ADDRESS TO PUT ASCII RESULTS
		CDFMYF
	DCA	EDRBCD		/ mark the end of the ASCII string
	DCA I	EDRBCD		/   with a 0
	CIFMNU			/ call IOA to display a cursor
	JMS I	IOACAL		/   position (where the result goes),
		0		/   and an ASCII string (the result)
		EDRIND
EDRPSN,		.-.
		NUMBUF		/ ADDRESS OF ASCII NUMBER
	JMP I	EDRDYR		/ exit subr


/ the following was moved here from the overlays
/ offset ADJUSTMENT subroutine
/
/ adjust (INCREMENT OR DECREMENT) the offset to the rppgds
/ and the pointer to the rppgds block
/
/ the contents of the AC at entry = positive for forward adjustment, or
/ = negative for backward adjustment

AJUST,	XX			/ THE CONTENTS OF THE AC IS THE COUNT
	CDFEDT			/ CHANGE TO EDITOR FIELD
	SPA			/ SKIP NEXT IF POSITIVE MEANING ADJUST FORWARD
	JMP	ADJBACK		/ ADJUST IN THE REVERSE DIRECTION

/ adjust in the forward direction

	ISZ I	(RPCUOF)	/ ADJUST FORWARD BY 1 COUNT (ALWAYS)
	AC7775			/ ARE WE PROCESSING THE THIRD EXT.??
	TAD I	(RPCUBK)
	SZA CLA			/ SKIP IF SO
	JMP	ADJUS1		/ NOT IN THE THIRD EXT.
	TAD I	(RPCUOF)	/ IF WE HAVE REACHED
	TAD	(-362)		/ 362 IN THE THIRD EXT., RESET
	SNA CLA			/ SKIP IF LESS THAN 362
	JMP	ADJUS2		/ AT 362, RESET...
ADJUS1,	TAD I	(RPCUOF)
	TAD	(-400)		/
	SPA CLA			/
	JMP	ADJEX3		/ EXIT

/ gone to far forward

ADJUS2,	AC0002			/ 2	/
/\	DCA I	(RPCUOF)	/
	ISZ I	(RPCUBK)	/
	JMP	ADJEX2		/ EXIT

/ adjust in the backward direction

ADJBACK,TAD I	(RPCUOF)	/ GET POINTER VALUE BEFORE ADJUSTMENT
	DCA I	(RPCUOF)	/ SAVE BACKWARD ADJUSTED VALUE
	TAD I	(RPCUBK)	/
	CLL RAR			/
	SNA CLA			/
	JMP	RPPH01		/
	AC7776			/ -2	/
	TAD I	(RPCUOF)	/
	SMA			/
	JMP	ADJEX1		/ STILL WITHIN LIMITS OF RPPGDS BLOCK AFTER ADJUSTMENT

/ the contents of the AC is a negative number
/  which means out of the logical boundries
/   of the RPPGDS block after the backward adjustment

	DCA	ADJTMP		/ SAVE CURRENT VALUE OF RPCUOF
	TAD I	(RPCUBK)	/ ARE WE IN THE FOURTH EXT.???
	TAD	(-4)
	SNA CLA			/ SKIP IF NOT
	TAD	(7762)		/ GET BACK TO 361 IN THIRD EXT.
	TAD	(400)		/
	TAD	ADJTMP		/ RETRIEVE RPCUOF
	DCA I	(RPCUOF)	/ RPCUOF IS NOW CORRECTED
	AC7777			/ -1	/
	TAD I	(RPCUBK)	/
	DCA I	(RPCUBK)	/
	JMP	ADJEX3		/ EXIT
ADJTMP,	0			/ TEMP. WORKING STORAGE

/ special boundry testing
/  because the pointer adjusted
/   is in the 1st RPPGDS descriptor block
/    (which has unique limits)
/
/  55 - is the 'top' of the block where the 1st RPPGDS descriptor word is
/ 377 - is  the 'bottom' of the block where the last descriptor word is

RPPH01,	TAD	(-55)		/
	TAD I	(RPCUOF)	/
ADJEX1,	SMA CLA			/
	JMP	ADJEX3		/ EXIT - STILL WITHIN LIMITS AFTER ADJUSTMENT
	TAD	(55)		/
ADJEX2,	DCA I	(RPCUOF)	/
ADJEX3,	CDFLP
	JMP I	AJUST		/ EXIT

/ ADJUS0	Moved here this edit to gather space in one place	/a247
/
ADJUS0,	XX			/ SAVE RETURN ADDRESS
	DCA	ADJTM1		/ ADJUST DIRECTION IN MQ
	RDF			/ GET CALLERS (RETURN) FIELD
	TAD	CIDF0		/ MAKE A RETURN CID INSTR.
	DCA	ADJEX4		/ SAVE FOR RETURN TO CALLER
	TAD	ADJTM1		/ SUPPLY ADJUST DIRECTION
	JMS	AJUST		/ DO ADJUST
ADJEX4,	.-.			/ CALLERS FIELD
	JMP I	ADJUS0		/ RETURN

ADJTM1,	.-.			/ TEMP FOR ADJUST DIRECTION

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/		* * * * * * * * * * * * * * * * *
/		*				*
/		*  EDITOR MATH ERROR REPORTING  *
/		*				*
/		* * * * * * * * * * * * * * * * *

/ Most of the display work is done in the menu.  This routine accepts
/ an error code and up to four parameters.  It passes the error code and
/ the first two parameters to menu block DLMLP5, list proc & ed math
/ error reporting.  A flag passed back by the menu processor tells this
/ routine whether to either just exit, or to call PELINE to show the
/ partially parsed formula or command appropriate to some error messages.
/ For two of the messages (ERNOSP and ERNSP2), this routine will not call
/ PELINE, but will make a display which shows results which do not fit.

/ calling sequence:
/
/	for ERNOSP and ERNSP2 --
/		TAD	(error code)
/		CDFMYF
/		JMS	EDERR-1
/		pcp to the first result's tab stop
/		pcp to the second result's tab stop
/		pointer to the first oversize result
/		pointer to the second oversize result
/
/	for EREXTR --
/		TAD	(error code)
/		CDFMYF
/		JMS	EDERR-1
/		pcp to the erroneous number
/
/	for all other errors --
/		TAD	(error code)
/		JMP	EDERR

/ pseudo-code
/ EDERR: proc
/	save ac
/	if in view mode then exit view mode endif
/	eliminate any screen lag
/	MNTMP4 = SPLTFL
/	if SPLTFL then EDRDIF = 0 else EDRDIF = #1200 endif
/	do
/	    { error code passed in ac }
/	    MNTMP5 = saved ac
/	    { tell menu processor that we're editor math }
/	    MNTMP1 = 1
/	    call MENU_INTERPRETER
/	{ the menu process will clear the error code to show that no }
/	{ further processing is needed }
/	until MNTMP5==0 here
/	    { check to see what flavor of further processing is needed }
/	    select MNTMP5 of
/	    case EREXTR
/		call EDRCOL ( arg1 )
/	    case ERNOSP
/		call EDRDYR ( #744 )	{ will use arg3 }
/		call EDRCOL ( arg1 )
/	    case ERNSP2
/		call EDRDYR ( #744 )	{ will use arg3 }
/		call EDRDYR ( #1044 )	{ will use arg4 }
/		call EDRCOL ( arg2 )
/		call EDRCOL ( arg1 )
/	    otherwise
/		call PELINE
/	    endselect
/	    { tell menu processor that it's being called a second time }
/	    saved ac = 1
/	enddo
/	fix up the screen
/	goto editor re-entry
/
/ EDRCOL: proc
/	save ac
/	call PCUR ( [CURLIN=-7] saved ac )
/	call EDOCHR ( '^' )
/	return
/
/ EDRDYR: proc
/	save ac plus EDRDIF
/	ac = next argument of EDERR
/	call BCDASC ( ac, NUMBUF )
/	mark end of NUMBUF with 0
/	call IOA ( 0, "^P^A", saved ac, NUMBUF )
/	return

/ real-code

EDRALP,	XX			/ sometimes called with JMS in order to
				/   establish an argument list pointer
EDERR,	DCA	EDRTZ		/ save error code
	CDFEDT			/ view overlay??
	TAD I	(OVLAY1)
	TAD	(-VIEWF1)
	SZA CLA
	JMP	EDRJ1		/ not view overlay
	TAD I	(VIEWF2)	/ view mode??
	SNA CLA
	JMP	EDRJ1		/ not view mode
	DCA I	(VIEWF2)	/ exit view mode
	AC2000
	DCA I	(SCRLCT)
	AC2000
	DCA I	(SCRNFL)
EDRJ1,	CDFMYF			/ get first two arguments
	TAD I	EDRALP
	DCA	EDRT1
	ISZ	EDRALP
	TAD I	EDRALP
	DCA	EDRT2
	CDFEDT			/ eliminate any screen lag
	AC0001
	DCA I	(ECHFLG)
	JMS	CALFXS		/ CALL EDITORS FXSCRL ROUTINE

/D232	CIFMNU			/ CHANGE TO MENU FIELD
/D232	PGSWAP			/ AC=0 SAVE SWAP AREA & RELOAD MENU CODE

	TAD	EDRTZ		/ get saved error code
EDRRPT,	CDFMNU			/ pass error code to menu processor
	DCA I	(MUBUF+MNTMP5)
	AC0001			/ signal that we're editor math
	DCA I	(MUBUF+MNTMP1)	/   (list proc uses a 0)
	CDFMYF			/ call the menu processor on the "list

	CIFMNU			/ CHANGE TO MENU FIELD			/M232
	PGSWAP			/ AC=0 SAVE SWAP AREA & RELOAD MENU CODE /M232

	CIFMNU			/   proc & ed math errors" block
	JMS I	MNUCAL
		DLMLP5

	AC7777			/ SET AC=-1				/M232
	CIFMNU			/ CHANGE TO MENU FIELD			/M232
	PGSWAP			/ AC=-1, SO JUST LOAD IN THE SAVE AREA	/M232

	CDFMNU			/ see if the menu process cleared the
	TAD I	(MUBUF+MNTMP5)	/   error code or whatever
	CDFMYF
	SNA CLA
	JMP	EDREND		/ err code cleared -- all done
	JMS	EDRTYP		/ not cleared -- which error??
	JMP	EDROTH		/   other -- go call PELINE
	JMP	EDRXTR		/   EREXTR -- display one caret only
	JMP	EDRONE		/   ERNOSP -- display one big result
	JMS	EDRDSP		/   ERNSP2 -- display two big results
	2144			/ screen position for display
	JMS	EDRDYR		/ one result after "...results: "
	JMS	EDRDSP		/ calculate correct screen position
	2244			/ screen position for display
	JMS	EDRDYR		/ one result after "...and: "
	TAD	EDRT2		/ one caret at column arg2
	JMS	EDRCOL
	JMP	EDRXTR

EDRONE,	JMS	EDRDSP		/ calculate correct screen position
	2142			/ screen position for display
	JMS	EDRDYR		/ one result after "...result: "
EDRXTR,	TAD	EDRT1		/ one caret at column arg1
	JMS	EDRCOL
	JMP	EDRAGN		/ go call the menu proc to finish up

EDROTH,	JMS	EDRDSP		/ calculate correct screen position
	2200			/ screen position for display
				/ it's not one of those listed, so assume
	CIFMTH			/   it's the kind of error with something
	JMS	PELINE		/   informative in the line buffer

EDRAGN,	AC0001			/ tell the menu processor that this is
	JMP	EDRRPT		/   a second call


/ This routine calculates the correct screen position for the error display.
/
/	The call is as follows:
/		JMS	EDRDSP	/ Calculate correct screen position
/		value		/ Position to use for no status lines
/		...		/ Return with AC = correct location

EDRDSP,	XX			/ Calculate correct screen position
	CDFMNU			/ Switch to menu field
	TAD I	(MUBUF+MNSTAT)	/ Pick up value of status line count
	CDFMYF			/ Switch back to this field
	BSW			/ Swap low order bits with high order bits
	CIA			/ Make value negative for a subtract
	TAD I	EDRDSP		/ Combine with NO-STATUS-LINE value
	ISZ	EDRDSP		/ Bump return address over value
	JMP I	EDRDSP		/ Return to caller

/ This routine examines the saved error code (in EDRTZ) and takes an
/ alternate return depending on the specific error.
/	JMS+1 (normal return)	-- not one of those tested for
/	JMS+2 (skip 1)		-- EDRTZ = EREXTR
/	JMS+3 (skip 2)		-- EDRTZ = ERNOSP
/	JMS+4 (skip 3)		-- EDRTZ = ERNSP2
EDRTYP,	XX
	TAD	EDRTZ
	TAD	(-EREXTR)
	SNA
	JMP	EDRTR1
	TAD	(EREXTR-ERNOSP)
	SNA
	JMP	EDRTR2
	TAD	(ERNOSP-ERNSP2)
	SZA CLA
	JMP I	EDRTYP
	ISZ	EDRTYP
EDRTR2,	ISZ	EDRTYP
EDRTR1,	ISZ	EDRTYP
	JMP I	EDRTYP

/ some useful things
EDRTZ,	0			/ error code (passed to EDERR in ac)
EDRT1,	0			/ arg1
EDRT2,	0			/ arg2


/ come here to exit from error reporting to the editor
EDREND,
/D232	AC7777			/ SET AC=-1
/D232	CIFMNU			/ CHANGE TO MENU FIELD
/D232	PGSWAP			/ AC=-1, SO JUST LOAD IN THE SAVE AREA

	CDFEDT			/ fix up the screen
	TAD	(-10)
	DCA I	(SCRLCT)
	DCA I	(CURLIN)
	DCA I	(CURPOS)
	JMS	CALFXS		/ CALL EDITORS FXSCRL ROUTINE
	CDFBUF			/ jump to the editor
	CIFEDT
	JMP	EIFXT2

/ some useful things
EDRIND,	TEXT "^P^A"

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE

	DSKBLK=.-200%400+DL4EDT	/ DISK BLOCK WHERE PAGE IS LOADED


/ THE FOLLOWING ROUTINE IS USED TO GET THE STATUS OF THE "MA" SWITCH, AND
/ INFO REGARDING WHETHER IN MATH AREA OR NOT!
/
/ IF MA = YES
/   THEN IF IN MATH WORK AREA = TRUE
/           THEN DO SKIP RETURN
/           ELSE DO NORMAL RETURN
/           ENDIF
/   ELSE SET "IN MATH WORK AREA" FLAG = FALSE
/        SET "IN CONTROL BLOCK" FLAG  = FALSE
/        DO NORMAL RETURN
/   ENDIF

MASTTS,	XX
	CDFMNU			/ CHANGE TO MENU DATA FIELD
	TAD I	(MUBUF+MNMATH)	/ GET "MA" FLAG
	CDFMYF			/ RETURN TO THIS DATA FIELD
	SNA CLA			/ IS "MA" YES?
	JMP	MASTT1		/  NO: GO FIX FLAGS
	CDFMTH			/  YES: CHANGE TO MATH DATA FIELD
	TAD I	(MTHWRK)	/ GET "IN MATH WORK AREA" FLAG
	CDFMYF			/ RETURN TO THIS DATA FIELD
	SNA CLA			/ ARE WE IN A MATH WORK AREA?
	ISZ	MASTTS		/  YES: SET UP FOR A SKIP RETURN
	JMP I	MASTTS		/  NO: RETURN TO CALLER

/ TAKE TIME HERE TO SET FOLLOWING FLAGS IN CASE "MA" IS SHUT OFF
/ IN THE MIDDLE OF A MATH AREA.

MASTT1,	AC0001			/ GET 1 IN THE AC
	CDFMTH			/ CHANGE TO MATH DATA FIELD
	DCA I	(MTHWRK)	/ SET IN MATH WORK AREA FLAG TO FALSE
	CDFMYF			/ RETURN TO THIS DATA FIELD
	AC0001			/ GET 1 IN THE AC
	DCA	INCTLB		/ SET "IN CONTROL BLOCK" FLAG = FALSE
	JMP I	MASTTS		/ RETURN TO CALLER


/ THIS RTN IS CALLED FROM "SCRMTH" AND "EDERR1". IT IS USED TO SHUT
/ DOWN EDITOR MATH IN THE CASE OF BACKING UP INTO, IN, OR OUT OF A CTRL
/ BLOCK IN AN EDITOR MATH WORK AREA. ALSO IT IS USED TO SHUT IT DOWN IF
/ AN ERROR IS ENCOUNTERED IN AN EDITOR MATH CONTROL BLOCK

SCRINI,	XX			/ SUBRTN USED TO SHUT EDITOR MATH DOWN
	CDFMTH			/  YES: CHANGE TO MATH DATA FIELD
	AC0001			/ GET 1 IN THE AC
	DCA I	(MTHWRK)	/ SET "IN MATH WORK AREA" = FALSE
	DCA I	(MTHTOT)	/ SET "MATH TOTAL" FLAG = FALSE
				/ DONE IN CASE "TOTAL" COMMAND IS PUT IN 1ST
				/ BLOCK OF EDITOR MATH AREA. IF PROCESS THRU 1ST
				/ BLOCK OF MATH AREA, THEN BACK UP TO TOP OF AREA
				/ AND RESCROLL, DEPENDING ON WHERE THE "TOTAL"
				/ HAS BEEN PLACED RELATIVE TO THE "FORMULAS" IN
				/ THE BLOCK, INCONSISTENCIES CAN RESULT IN THE
				/ EXECUTION OF THE 1ST LINE OF THE TABLE
				/ FOLLOWING THE BLOCK
	DCA I	(FSTLNE)	/ SET "CONTROL BLOCK FIRST LINE" FLAG = TRUE
				/ THIS IS DONE TO COVER THE CASE WHERE THE USER
				/ BACKS UP IN AN EDITOR MATH AREA CTRL BLOCK
				/ TO THE "WPSMATH" THEN SCROLLS FORWARD THEN
				/ BACKS UP AGAIN TO THE TOP OF THE MATH AREA.
				/ THIS FIX SHOULD ALLOW THE SYSTEM TO PROCESS
				/ THE MATH AREA STARTING FROM THE "WPSMATH"
				/ INSTEAD OF HAVING TO BACK UP TO BEFORE THE
				/ START OF THE MATH AREA, THUS KEEPING IT
				/ CONSISTENT WITH THE WAY IT ACTS IF BACKUP IS
				/ DONE WHILE NOT IN A CTRL BLOCK.
	CDFMYF			/ RETURN TO THIS DATA FIELD
	AC0001			/ GET 1 IN THE AC
	DCA	INCTLB		/ SET "IN CONTROL BLOCK" FLAG = FALSE
	DCA	MTHCTL		/ SET "IN MATH CONTROL BLOCK" = FALSE....
				/ ..THIS IS DONE TO COVER ANY UNFORESEEN PROBLEMS
	JMP I	SCRINI		/ RETURN TO CALLER

/ INMATH	Moved this edit to make space for INSMCH		/a247

/ CALFXS	Moved this edit to make room for INSMCH			/a247

/ CKCTRS	Moved this edit to make room for INSMCH			/a247

/ CHAR. CHECK ROUTINE
/ READS CHARACTER IN EDIT BUFFER POINTERED TO BY LINE23 AND CHECKS FOR
/ MATCH TO CHARACTER SPECIFIED AT CALLER+2.   USED IN "CKCTRL".
/ ROUTINE WILL GO BACK TO THE EDITOR, RESTORING CURPTR ALONG THE WAY IF
/ THE CHARCTER READ MATCHES THE CHARACTER SPECIFIED AT CALLER+2 ELSE
/ IT RETURNS TO CALLER+3 IF NO MATCH.

/ CALL	: JMS CKCTR1
/ CALL+1	:     VALUE TO AND CHAR. WITH (IE. - STRIP MODE BITS)
/ CALL+2	:     -CHAR. TO MATCH

CKCTR1,	XX
	CDFEDT
	TAD I	(LINE23)	/ GET POINTER TO 1ST CHAR. IN LINE
	DCA	T1		/ SAVE IN TEMP.
	CDFBUF
	TAD I	T1		/ GET CHARACTER
	CDFMYF
	AND I	CKCTR1		/ GET VALUE TO AND FROM CALLER+1
	ISZ	CKCTR1		/ BUMP RETURN PTR. TO GET NEXT PARAM.
	TAD I	CKCTR1		/ GET NEG. VALUE OF CHAR. TO MATCH.
	SNA CLA			/ SKIP IF: NO MATCH
	JMP	BKEDI3		/ RULER LINE - SKIP MATH
	ISZ	CKCTR1		/ BUMP RETURN POINTER
	JMP I	CKCTR1		/ RTRN TO CALLER TO CONTINUE PROCESSING



/++
/		INCREMENT_DECIMAL_TAB_COUNT
/
/ FUNTIONAL DESCRIPTION:	IDTABCOUNT
/
/	THE FUNCTION OF THIS ROUTINE IS TO CHECK PREVIOUS TO INCREMENTING
/	DTABCOUNT THAT IT HAS NOT BEEN INCREMENTED ONCE ALREADY FOR THE
/	CURRENT TABPOSITION.  IF NOT YET INCREMENTED FOR THE CURRENT
/	TABPOSITION THEN INCREMENT DTABCOUNT AND SET LAST_TAB_POSITION =
/	-TABPOSITION FOR THE NEXT PASS THROUGH IDTABCOUNT.
/
/ CALLING SEQUENCE:	JMS	IDTABCOUNT
/
/ INPUT PARAMETERS:	AC = 0
/
/ IMPLICIT INPUT:	GLOBAL:	TABPOSITION, LTABPOSITION, DTABCOUNT
/
/ OUTPUT PARAMETERS:	AC = 0
/
/ IMPLICIT OUTPUT:	GLOBAL:	LTABPOSITION, DTABCOUNT
/
/ COMPLETION CODE:	NONE
/
/ SIDE EFFECTS:		1) LTABCOUNT INITS. IN EXTRACTNUMBER ROUTINE
/
/--


IDTABCOUNT,			/ INCREMENT_DECIMAL_TAB_COUNT
	XX
	TAD	TABPOSITION	/ HAS DTABCOUNT ALREADY BEEN INCREMENTED
				/  FOR THIS TAB POSITION?
	TAD	LTABPOSITION	/ ADD LAST_TAB_POSITION
	SZA CLA			/ SKIP IF: SO
	ISZ	DTABCOUNT	/ NO - INCREMENT DECIMAL TAB COUNT
	TAD	TABPOSITION	/ SET LTABPOSITION
	CIA
	DCA	LTABPOSITION
	JMP I	IDTABCOUNT	/ RETURN

/ ADJUS0	Moved this edit to make space for ADUNIT		/a247

/ BKEDI4	Moved elsewhere this edit to make space for ADUNIT	/a247


/****************************************************************************
/ ADUNIT	ADance UNIT routine is used by READNEXTCHARACTER	/a247
/		to aquire the next relevent character from the edit	/a247
/		buffer.  If not in a dead key sequence, then ADVSPC	/a247
/		is used to get the next printable character.  If a	/a247
/		dead key sequence is in progress, ADVPTR is used	/a247
/		until an End Dead is seen.  On encountering the End	/a247
/		Dead, the dead key sequence flag is reset and		/a247
/		processing returns to normal.				/a247
/****************************************************************************

ADUNIT,	XX			/ Start of routine to get next unit	/a247
	TAD	DEADKEY		/ Get the state of the dead key flag	/a247
	SZA CLA			/ Are we in a dead key sequence?	/a247
	JMP	DEAD		/ Yes, get the next non-null file char	/a247
	CIFEDT			/ No, call the ADVSPC routine to get	/a247
	JMS	CALLAR		/ the next printable character		/a247
		ESASPC		/					/a247
		CDFBUF		/ The field of the text buffer		/a247
	JMP	AUETXT		/ Jump to non-skip ETX exit		/a247
	JMP	AUOKXT		/ Jump to skip return with normal char	/a247

DEAD,	CIFEDT			/ Call a routine in the editor using	/a247
	JMS	CALLAR		/ the universal entry point		/a247
		ESAPTR		/ Call the Advance Pointer routine	/a247
		CDFBUF		/ with the datafield of the edit buffer	/a247
	JMP	AUETXT		/ ETX found return			/a247
	TAD	(-ECNDOV)	/ Test for end of dead key sequence	/a247
	SNA			/ Is this the end of the sequence?	/a247
	DCA	DEADKEY		/ Yes, reset the dead key flag		/a247
	TAD	(ECNDOV)	/ Recover the character			/a247
AUOKXT,	ISZ	ADUNIT		/ Skip return on normal character	/a247
AUETXT,	JMP I	ADUNIT		/ Return				/a247

DEADKEY,0			/ The Dead Key Sequence Flag		/a247

/****************************************************************************
/ INSMCH	INSert Multinational CHaracter.  This routine is used	/a247
/		by editor maths mainly for the task of inserting	/a247
/		multinational currency symbols.				/a247
/
/		The character to insert should be passed in the AC	/a247
/		The attributes for the character should be passed in MQ	/a247
/****************************************************************************

INSMCH,	XX			/ Start of 8 Bit insertion routine	/a247
	DCA	INCHAR		/ Save the character passed in AC	/a247
	SWP			/ Get the attribute bits		/a247
	DCA	INSATR		/ Save them for now			/a247
	TAD	INCHAR		/ Get the character back again		/a247
	AND	(200)		/ Test the eigth bit			/a247
	SNA CLA			/ Is this a multinational character?	/a247
	JMP	INMNXP		/ No, output normally			/a247

	TAD	(ISTRING)	/ Yes, get the addr of std dead key seq./a247
	DCA	X1		/ Store in index register		/a247
	ISZ	DEADKEY		/ Tickle deadkey flag so READNEXT works	/a247
	TAD	ISTRING		/ Get the First character of the seq.	/a247
	JMP	INMENT		/ Enter the output loop			/a247

INMLOOP,TAD I	X1		/ Get the next character in the sequence/a247
	SPA			/ Is this the terminating character?	/a247
	JMP	INMEXT		/ Yes, print it then exit		/a247
	AND	P177		/ No, so strip eigth bits off		/a247
	MQL			/ Save in the MQ register		/a247
	TAD	INSATR		/ Get the attribute bits		/a247
	MQA			/ Then merge with the character code	/a247
INMENT,	JMS	INSCODE		/ Insert the character in the buffer	/a247
	JMS	READNEXT	/ Move edit pointer to next position	/a247
	NOP			/ (Should not reach end of file)	/a247
	JMP	INMLOOP		/ And loop for next character		/a247

INMNXP,	TAD	INCHAR		/ For ordinary 7 bit chars, just recall	/a247
	MQA			/ the character and add the attributes	/a247
	SKP			/					/a247
INMEXT,	AND	P177		/ Strip the top bit from terminator	/a247
	JMS	INSCODE		/ Insert the character into the buffer	/a247
	DCA	DEADKEY		/ End of dead key sequence		/a247
	JMP I	INSMCH		/ Return				/a247

ISTRING,	ECSTOV		/ Start of Dead Key character		/a247
		" 		/ Space					/a247
		"2		/ Multinational character set		/a247
INCHAR,		0		/ The required character		/a247
		ECNDOV+4000	/ End Dead Key and terminator bit	/a247
INSATR,	0			/ Place to store the attribute bits	/a247

	X=.			/ INDICATE FIRST FREE LOCATION ON PAGE
/---------------
	PAGE			/

	RELOC

	CDFMYF=	CDFEDT		/ ALL EDITOR OVERLAY CODE EXECUTES IN EDITOR FIELD


/d238	NOPUNCH			/ TURN OFF THE BINARY PUNCH



