Google
 

Trailing-Edge - PDP-10 Archives - BB-H138E-BM - 6-1-sources/wfreainp.bli
There are 10 other files named wfreainp.bli in the archive. Click here to see a list.
 %TITLE 'WFREAINP - read a line from the input file'
MODULE WFREAINP (				! Read a line from the input file
		IDENT = '3-003'			! File: WFREAINP.BLI Edit: CJG3003
		) =
BEGIN
!
!			  COPYRIGHT (c) 1981, 1985 BY
!	      DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
!		ALL RIGHTS RESERVED.
!
! THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
! ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH  LICENSE AND WITH THE
! INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR  ANY  OTHER
! COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
! OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
! TRANSFERRED.
!
! THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE  WITHOUT  NOTICE
! AND  SHOULD  NOT  BE  CONSTRUED  AS  A COMMITMENT BY DIGITAL EQUIPMENT
! CORPORATION.
!
! DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR  RELIABILITY  OF  ITS
! SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!

!++
! FACILITY:	EDT -- The DEC Standard Editor
!
! ABSTRACT:
!
!	Read a line from the input file.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: October 16, 1978
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 23-Feb-1981.  This module was created by
!	extracting routine READ_INPUT from module EDTWF.
! 1-002	- Regularize headers.  JBS 19-Mar-1981
! 1-003	- Change EOB_LINE to EOB_LN .  JBS 31-Mar-1981
! 1-004 - Remove division from line number calculations.  SMB 14-Jan-1982
! 1-005 - Convert i/o to use edt$fileio. STS 15-Jan-1982
! 1-006 - Add capability for 15 digit line numbers. SMB 19-Jan-1982
! 1-007 - pass header info by descriptor. STS 20-Jan-1982
! 1-008 - fix bugs related to 15-digit line numbers.  SMB 22-Jan-1982
! 1-009 - check for zero length descriptor.  STS 22-Jan-1982
! 1-010 - Remove a MOVELINE for original line numbers.  SMB 26-Jan-1982
! 1-011 - Remove original line numbers.  SMB 28-Jan-1982
! 1-012 - Fix bug in line number assignment for sequenced files.  SMB 30-Jan-1982
! 1-013 - Add a range check for line number too large.  SMB 1-Feb-1982
! 1-014 - Pass address of io_rhb to file routines. STS 03-Feb-1982
! 1-015 - Close input file if line numbers get too large.  SMB 06-Feb-1982
! 1-016 - Deallocate dynamic descriptors. STS 10-Feb-1982
! 1-017 - Add literals for callable parameters. STS 08-mar-1982
! 1-018	- Remove reference to EDT$$RD_IFI.  JBS 15-Mar-1982
! 1-019 - Clear input file open flag when closing. STS 07-Apr-1982
! 1-020	- Print a message on a CLOSE error.  JBS 12-Apr-1982
! 1-021	- Check for records longer than 255 bytes.  JBS 02-Jun-1982
! 1-022	- Close the input file on EOF.  JBS 11-Jun-1982
! 1-023	- Close the input file on reaching the end of the MAIN buffer only!  JBS 14-Jun-1982
! 1-024 - Print a message on Get errors and try again. STS 21-Jul-1982
! 1-025 - Don't check RMS status on 11's since error message has already
!  	   gone out. STS 22-Jul-1982
! 1-026 - Print out the full RMS message rather than just 1 liner. STS 23-Jul-1982
! 1-027 - Set the text on screen flag for RMS errors.  SMB 28-Jul-1982
! 1-028 - Change the flags set for error messages (again).  SMB 17-Aug-1982
! 1-029 - Modify to use new 48 bit macro. STS 01-Oct-1982
! 1-030	- Don't clear EDT$$G_MSGFLG; setting EDT$$G_SCR_CHGD is sufficient.  JBS 06-Oct-1982
! 1-031 - Modify to use new compare macro. STS 20-Oct-1982
! 1-032 - Use a different scrolling routine.  SMB 21-Oct-1982
! 1-033	- Set EDT$$G_SCR_REBUILD if we insert a line in the work file.  JBS 01-Nov-1982
! 1-034	- Modify edit 1-033 so we don't disturb the screen data base but don't
!	   have to rebuild the screen.  JBS 01-Dec-1982
! 1-035	- Note new value for EDT$$G_SCR_CHGD.  JBS 02-Mar-1983
! 3-001 - Simplify for TOPS20. CJG 20-Apr-1983
! 3-002 - Fix return from EDT$$CALLFIO. CJG 8-Jun-1983
! 3-003 - Remove call to EDT$$CALLFIO. CJG 10-Jun-1983
!--

%SBTTL 'Declarations'
!
! TABLE OF CONTENTS:
!

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    EDT$$RD_ILN;

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

REQUIRE 'SYS:JSYS';

!
! MACROS:
!
!	NONE
!
! EQUATED SYMBOLS:
!

EXTERNAL LITERAL
    EDT$K_INPUT_FILE,
    EDT$K_GET,
    EDT$K_CLOSE;

!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routine
%SBTTL 'EDT$$RD_ILN  - read a line from the input file'

GLOBAL ROUTINE EDT$$RD_ILN 			! Read a line from the input file
    =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine attempts to read a new line from the input file.  If the
!	INPUT_RAB field is zero, or if the read fails return 0 to indicate that
!	there is no more input.  If the read succeeds, give the line the next
!	sequential number, and insert it at the end of the text buffer.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	SCR_LNS
!	CUR_BUF
!	WK_INSCNT
!	WK_LN
!	EOB_LN
!	LNO0 - L_LNO14
!	LNO_ZERO
!	LNO_BIG
!
! IMPLICIT OUTPUTS:
!
!	SCR_CHGD
!	CUR_BUF
!	WK_INSCNT
!	IO_VFCHD
!
! ROUTINE VALUE:
!
!	1 = a line was read
!	0 = no more input
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$FIOPN_ERR,
	EDT$$OUT_FMTBUF,
	EDT$$SC_SETSCLLREG,
	EDT$$SC_FULLSCLL,
	EDT$$STOP_WKINGMSG,
	EDT$$MSG_TOSTR,
	EDT$$TI_INPCH,
	EDT$$SC_NONREVID,
	EDT$$FMT_MSG,
	EDT$FILEIO,
	EDT$$CMP_LNO,
	EDT$$INS_LN : NOVALUE,
	EDT$$RD_PRVLN;

    EXTERNAL
	SCR_LNS,			! Number of screen lines
	CUR_BUF : REF TBCB_BLOCK,	! Current text buffer control block
	WK_INSCNT : LN_BLOCK,		! The count of inserted lines
	INPUT_OPN,			! input file open flag
	LNO_ZERO : LN_BLOCK,		! Zero in 48-bit repr.
	LNO_BIG : LN_BLOCK,		! 2814749767.00000
	WK_LN : REF LIN_BLOCK,		! Pointer to current line
	EOB_LN,
	IO_VFCHD,			! Record header buffer for fixed line nos.
	LN_PREV,			! Previous VFC line number
	LN_INCR : LN_BLOCK,		! Input line number increment
	LNO0 : LNOVECTOR [14],
	IO_FNAM,
	EDIT_MOD,
	SCR_CHGD,
	SCR_REBUILD;			! 1 = rebuild screen data base from the work file


    MESSAGES ((MAXINPLIN, PRERETCON, ERRINPFIL, INPFILCLO, RECTOOBIG));


    LOCAL
	FILE_DESC : BLOCK [1],
	MAX_LNO,
	GET,
	LINNO : LN_BLOCK,
	I,
	NEW_BUKT,
	SAVE_REBUILD;


    FILE_DESC [DSC$A_POINTER] = 0;
    FILE_DESC [DSC$W_LENGTH] = 0;
    MAX_LNO = 0;				! assume good

!+
! Try to read a record from input.
!-

    IF (.CUR_BUF [TBCB_INPUT_RAB] NEQ 0)
    THEN

	BEGIN
	GET = EDT$FILEIO (EDT$K_GET, EDT$K_INPUT_FILE, FILE_DESC);
!+
! If the get failed but it was not end of file then print out an error
! message.
!-

	IF (.GET LSS 0)
	THEN

	    IF (.EDIT_MOD EQL CHANGE_MODE)
	    THEN
		BEGIN
		EDT$$SC_FULLSCLL ();
		EDT$$STOP_WKINGMSG ();
		EDT$$FIOPN_ERR (EDT$_ERRINPFIL, .IO_FNAM);
!+
! Output the "Press return to continue"
! message and wait for ANY key to be pressed before
! refreshing the screen and returning to change mode
!-
		EDT$$MSG_TOSTR (EDT$_PRERETCON);
		EDT$$OUT_FMTBUF ();
		EDT$$TI_INPCH (I);
		EDT$$SC_NONREVID ();
		SCR_CHGD = 1;		! repaint the screen
		EDT$$SC_SETSCLLREG (0, .SCR_LNS);
		END
	    ELSE
		EDT$$FIOPN_ERR (EDT$_ERRINPFIL, .IO_FNAM);


	IF (.GET EQL 1)
	THEN
	    BEGIN
!+
! Determine the next line number
!-

	    MAX_LNO = ADDLINE (CUR_BUF [TBCB_INPUT_LINE], LNO0 [5],
		    CUR_BUF [TBCB_INPUT_LINE]);

!+
! If the next line number is greater than the maximum allowed, stop reading
! records and jump to code which displays end of buffer
!_

	    IF ((EDT$$CMP_LNO (LNO_BIG, CUR_BUF [TBCB_INPUT_LINE]) GEQ 0) AND (.MAX_LNO EQL 0))
	    THEN
		BEGIN
!+
! The read suceeded and the line number is good.  Insert the record at the end
! of the buffer.
! Do not disturb the screen data base.
!-
		SAVE_REBUILD = .SCR_REBUILD;
		SCR_REBUILD = 1;

		IF (.FILE_DESC [DSC$W_LENGTH] GTR 255) THEN
			EDT$$FMT_MSG (EDT$_RECTOOBIG);
		EDT$$INS_LN (CH$PTR (.FILE_DESC [DSC$A_POINTER]),
			MIN (.FILE_DESC [DSC$W_LENGTH], 255));

		SCR_REBUILD = .SAVE_REBUILD;
!+
! In case we are doing an insert on another buffer (as in the
! case of a CUT command), do not screw up the insert count.
!-
		SUBLINE (LNO0, WK_INSCNT, WK_INSCNT);
		EDT$$RD_PRVLN ();
		WK_LN [LIN_NUM] = .CUR_BUF [TBCB_INPUT_LINE];
		WK_LN [LIN_NUMM] = .CUR_BUF [TBCB_INPUT_LINM];
		WK_LN [LIN_NUMH] = .CUR_BUF [TBCB_INPUT_LINH];

!+
! And return success
!-
		RETURN (1);
		END
	    ELSE
		BEGIN
		EDT$$FMT_MSG (EDT$_MAXINPLIN);

		IF ( NOT EDT$FILEIO (EDT$K_CLOSE, EDT$K_INPUT_FILE, FILE_DESC))
		THEN
		    EDT$$FMT_MSG (EDT$_INPFILCLO);

		INPUT_OPN = 0;
		END

	    END;

!+
! The read failed, close the file and indicate end of buffer.
!-

	END;

    IF (.INPUT_OPN AND (.CUR_BUF [TBCB_INPUT_RAB] NEQ 0))
    THEN
	BEGIN

	IF ( NOT EDT$FILEIO (EDT$K_CLOSE, EDT$K_INPUT_FILE, FILE_DESC))
	THEN
	    EDT$$FMT_MSG (EDT$_INPFILCLO);

	INPUT_OPN = 0;
	END;

    WK_LN = EOB_LN;
    CUR_BUF [TBCB_CHAR_POS] = 0;
    CUR_BUF [TBCB_INPUT_RAB] = 0;

!+
! And return failure
!-
    RETURN (0);
    END;					! of routine EDT$$RD_ILN

END
ELUDOM