Google
 

Trailing-Edge - PDP-10 Archives - BB-H138E-BM - 6-1-sources/lwrite.bli
There are 10 other files named lwrite.bli in the archive. Click here to see a list.
 %TITLE 'LWRITE - write to a file'
MODULE LWRITE (				! Write to a file
		IDENT = '3-009'			! File: LWRITE.BLI Edit: CJG3009
		) =
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:
!
!	This module executes the line mode EXIT and WRITE commands.
!
! ENVIRONMENT:	Runs at any access mode - AST reentrant
!
! AUTHOR: Bob Kushlis, CREATION DATE: February 3, 1978
!
! MODIFIED BY:
!
! 1-001	- Original.  DJS 30-JAN-1981.  This module was created by
!	extracting the routines WRITE_FILE, EDT$$EXI_CMD , and EDT$$WR_CMD
!	from the module EXEC.BLI.
! 1-002	- Regularize headers.  JBS 23-Mar-1981
! 1-003	- Change WRITE_COM to EDT$$WR_CMD .  JBS 30-Mar-1981
! 1-004	- Use the new message codes.  JBS 04-Aug-1981
! 1-005 - Don't write out summary when flag clear. STS 05-Oct-1981
! 1-006 - Convert open output file to use EDT$FILEIO. STS 13-Jan-1982
! 1-007 - Remove division from line number calculatons.  SMB 15-Jan-1982
! 1-008 - Convert reads and writes to use EDT$FILEIO. STS 15-Jan-1982
! 1-009 - Add capability for 15 digit line numbers.  SMB 19-Jan-1982
! 1-010 - pass sequence numbers by descriptors. STS 20-Jan-1981
! 1-011 - Change the checking of sequence/nosequence. STS 21-Jan-1982
! 1-012 - Fix size bugs related to 15 digit sequences & increments.  SMB 26-Jan-1982
! 1-013 - Remove original line numbers.  SMB 28-Jan-1982
! 1-014 - Fix bug in writing with /SEQ.  SMB 30-Jan-1982
! 1-015 - Add range checking on seq.# and incr.  SMB 5-Feb-1982
! 1-016 - Take out call to edt$$get_fnam. STS 10-Feb-1982
! 1-017 - Change line number division to a routine call.  SMB 11-Feb-1982
! 1-018 - Format filename for output. STS 12-Feb-1982
! 1-019 - Pass filename to edt$$fiopn_err. STS 26-Feb-1982
! 1-020 - Add literals for callable EDT. STS 08-Mar-1982
! 1-021	- Use the input file name as the output name, if permitted and
!	   there is no output file name.  JBS 25-Mar-1982
! 1-022	- The file I/O routines return a status.  JBS 26-Mar-1982
! 1-023	- Correct a typo in edit 1-022.  JBS 27-Mar-1982
! 1-024 - Minor edits, plus remove code that doesn't seem to be executed.  SMB 30-Mar-1982
! 1-025 - Rearrange where file name is stored so we get "real" name instead
!	  of "temp" filename.  SMB 31-Mar-1982
! 1-026 - Add code for CONTROL_C check during record writing.  SMB 08-Apr-1982
! 1-027	- Print messages on CLOSE errors.  JBS 12-Apr-1982
! 1-028 - Convert PDP-11 command file names to uppercase.  SMB 13-Apr-1982
! 1-029	- Clear PREV_RANGE when creating a range block for EXIT.  JBS 15-Apr-1982
! 1-030 - Don't set up any message for nosummary. STS 16-Apr-1982
! 1-031 - Change NO FILE error message and processing for WRITE.  SMB 21-Apr-1982
! 1-032 - Save original buffer address. STS 10-May-1982
! 1-033 - Make minor modifications based on code review input.  SMB 24-May-1982
! 1-034	- Set a flag if control C actually aborts something.  JBS 24-May-1982
! 1-035 - Fix bug with explicit file names.  SMB 25-May-1982
! 1-036	- Pass default file name using RHB parameter.  JBS 15-Jun-1982
! 1-037 - Stop working message before printing messages to screen.  SMB 22-Jun-1982
! 1-038 - Stop processing if bad select range.  SMB 01-Jul-1982
! 1-039	- Use EDT$$FMT_CRLF instead of EDT$$OUT_FMTBUF.  JBS 05-Jul-1982
! 1-040 - Change write file messages.  SMB 13-Jul-1982
! 1-041 - Give message for write errors. STS 21-Jul-1982
! 1-042 - Don't put out error messages on 11's STS 22-Jul-1982
! 1-043 - Restore screen width before displaying file name on EXIT.  SMB 29-Jul-1982
! 1-044 - Check the abort write flag after reads. STS 05-Aug-1982
! 1-045 - Make use of the bit masks for the options word. STS 17-Aug-1982
! 1-046	- Fix up the references to the EDT$M_ symbols.  JBS 23-Aug-1982
! 1-047 - Put EDT$$TST_EOB in line. STS 22-Sep-1982
! 1-048 - Change to use new addline/subline macro. STS 1-Oct-1982
! 1-049 - Put code for edt$$rng_posfrst in line. STS 11-Oct-1982
! 1-050 - Modify to use new compare macro. STS 10-Oct-1982
! 1-051 - Avoid str$copy where possible to increase efficiency. STS 10-Nov-1982
! 1-052	- Add conditional for WPS support.  JBS 10-Feb-1983
! 1-053 - Only set screen width if it has changed from original.  SMB 17-Feb-1983
! 3-001 - Start of modifications for Tops10/20.  GB December 1982
! 3-002 - Add conditionals for Tops10/20.  GB 21-Jan-1983
! 3-003 - Fix EDT$$FMT_STR and EDT$$FMT_STRCNT. CJG 22-Mar-1983
! 3-004 - Fix arguments to FND_BUF - it takes a byte pointer. CJG 24-Mar-1983
! 3-005 - Remove RHB code. CJG 19-Apr-1983
! 3-006 - Add updates from V3 sources.  GB 29-Apr-1983
! 3-007 - Fix call to EDT$$FMT_STRCNT. CJG 6-Jun-1983
! 3-008 - Remove call to EDT$$CALLFIO. CJG 10-Jun-1983
! 3-009 - Change the way that filespecs are handled. CJG 23-Jun-1983
!--

!<BLF/PAGE>

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

REQUIRE 'EDTSRC:TRAROUNAM';

FORWARD ROUTINE
    WRITE_FILE,					! Write an output file
    EDT$$EXI_CMD : NOVALUE,			! Process the EXIT command
    EDT$$WR_CMD : NOVALUE;			! Process the WRITE command

!
! INCLUDE FILES:
!

REQUIRE 'EDTSRC:EDTREQ';

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

EXTERNAL LITERAL
    EDT$M_NOOUTPUT,
    EDT$K_WRITE_FILE,
    EDT$K_OUTPUT_FILE,
    EDT$K_OPEN_OUTPUT_SEQ,
    EDT$K_OPEN_OUTPUT_NOSEQ,
    EDT$K_PUT,
    EDT$K_CLOSE,
    EDT$K_CLOSE_DEL;

!
! OWN STORAGE:
!
!	NONE
!
! EXTERNAL REFERENCES:
!
!	In the routines
!<BLF/PAGE>

%SBTTL 'WRITE_FILE - write on a file'
ROUTINE WRITE_FILE (				! Write on a file
    RANGE, 					! Range to write
    CHECK,					! Do consistency checking
    FILE_DESC					! File descriptor to use
    ) =

!++
! FUNCTIONAL DESCRIPTION:
!
!	This routine is used by the WRITE and EXIT commands to write
!	an output file.  The /SEQ switch determines whether sequence
!	numbers should be written.
!
! FORMAL PARAMETERS:
!
!  RANGE 		the range block for the range to be written.
!
!  CHECK 		a flag indicating that the consistency check should be done
!			(set if we are exiting, clear otherwise).  Also permits defaulting
!			of the file name to the output or input file name.
!
!  FILE_DESC		File descriptor to be used by FILEIO
!
! IMPLICIT INPUTS:
!
!	EXITD
!	OUT_NAM
!	WRT_NAM
!	INP_NAM
!	OPTIONS
!	CUR_BUF
!	IO_VFCHD
!	LNO_ZERO
!	LNO0
!	LNO_VFCMAX
!	WK_LN
!	SUMRY
!	EXE_CURCMD
!	EXE_SBITS
!	EXE_SBLK
!
! IMPLICIT OUTPUTS:
!
!	EXE_SBITS
!	CC_DONE
!
! ROUTINE VALUE:
!
!	0 = no write took place
!	1 = file written successfully
!
! SIDE EFFECTS:
!
!	Types an error message if the file is not properly written.
!	If the consistency check fails, arranges to save the journal file.
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$FILEIO,				! Calls general file routine
	EDT$$SC_SETWID,				! Reset terminal width
	EDT$$SC_POSCSIF,			! Absolute cursor positioninn
	EDT$$STOP_WKINGMSG,			! Stop working message
	EDT$$CHK_CC,				! check for CONTROL/C typed
	EDT$$LDIV,
	EDT$$FMT_CH,
	EDT$$FMT_STRCNT : NOVALUE,
	EDT$$FMT_CRLF,				! Terminate an output line
	EDT$$FMT_MSG,
	EDT$$NXT_LNRNG,
	EDT$$RNG_REPOS,
	EDT$$CMP_LNO,
	EDT$$FIOPN_ERR,
	EDT$$FMT_STR;


    EXTERNAL
	TI_WID,
	ABT_WRITE,
	SAV_TIWID,
	MESSAGE_LINE,
	IO_FNAM,
	EXT_MOD,
	EXITD,
	INP_NAM,
	RNG_FRSTLN,
	RNG_ORIGPOS : POS_BLOCK,
	OPTIONS : BITVECTOR [36],		! bit 3 = /NOOUTPUT
	CUR_BUF : REF TBCB_BLOCK,
	IO_VFCHD,
	LNO_ZERO : LN_BLOCK,
	LNO_VFCMAX : LN_BLOCK,			! Value 6.5535 * (10**9)
	LNO0 : LNOVECTOR [14],			! powers of ten
	SUMRY,					! flag indicating whether to type out summary
	EOB_LN,
	WK_LN : REF LIN_BLOCK,
	EXE_CURCMD : REF NODE_BLOCK,		! Pointer to the current command.
	EXE_SBITS,				! The options switches.
	EXE_SBLK : REF NODE_BLOCK,		! The option switch value block.
	CC_DONE;				! Set to 1 if control C actually aborts something

    MESSAGES ((NOFILSPC, NOFILWRT, CONCHKFLD, ERROUTFIL, WRIFILCRE, OUTFILCRE, SEQNUMOV, SEQINCROV, OUTFILCLO,
	WRIFILCLO));

    LOCAL
	CLOSEMSG,				! File close message
	OUTPUTMSG,				! Output error message
	OPNMSG,					! File open message
	FILECODE,				! code for what kind of open
	FILESTRM,				! code for which kind of file
	REC_DESC : BLOCK [1],			! Descriptor for record
	STAT_DESC : BLOCK [8],			! descriptor for puts
	STATUS,					! Status of open or close attempt
	L_COUNT : LN_BLOCK,			! Number of lines written.
	C_COUNT,				! Number of characters written
	REC_ADDR,
	REC_LEN,
	DIGIT,					! Holds integer result from division
	LINNO : LN_BLOCK,			! 48-bit line number
	SEQ,					! Flag indicating sequenced
	SEQ_NUM,				! Current sequence number
	SEQ_INCR;				! Sequence number increment

    MAP
	FILE_DESC : REF BLOCK;

!+
! Position to the front of the range.
!-

    RNG_FRSTLN = 1;
    EDT$$CPY_MEM (POS_SIZE, .CUR_BUF, RNG_ORIGPOS);

    IF ( NOT EDT$$RNG_REPOS (.RANGE)) THEN RETURN (0);

!+
! If this is a WRITE command, then the filespec must be with the command.
!
! If this is an EXIT command, then the filespec may be with the command, or
! it may have been provided in the /OUTPUT switch, or it may be defaulted
! from the input file spec.
!
! If a filespec is provided with the EXIT command, then this will be used
! with any defaults coming from the input or /OUTPUT filespecs.
!
! If /READONLY was given in the original command line, and there is no filespec
! with the EXIT command, then there is nothing to do.

    IF (.EXE_CURCMD [FSPCLEN] EQL 0)
    THEN

	IF ((.CHECK EQL 0) OR ((.OPTIONS AND EDT$M_NOOUTPUT) NEQ 0))
	THEN
	    BEGIN
	    EDT$$FMT_MSG (EDT$_NOFILSPC);
	    RETURN (0);
	    END;

!+
! Check for the /SEQ option.
!-

    IF (SEQ = .EXE_SBITS<OPB_SEQ>)
    THEN
	BEGIN
!+
! Determine the actual sequence start and increment by reducing them by 10**5
!-
	SEQ_NUM = 0;
	SEQ_INCR = 0;
	MOVELINE (EXE_SBLK [SW_VAL1], LINNO);	! Starting Value
!+
! Error checks for sequence number and increment (must be less than 65536)
!-

	IF (EDT$$CMP_LNO (LINNO, LNO_VFCMAX) GTR 0)
	THEN
	    BEGIN
	    EDT$$FMT_MSG (EDT$_SEQNUMOV);
	    RETURN (0)
	    END;

	DECR I FROM 9 TO 5 DO

	    BEGIN
	    SEQ_NUM = .SEQ_NUM*10;
	    EDT$$LDIV (LINNO, DIGIT, .I);
	    SEQ_NUM = .SEQ_NUM + .DIGIT;
	    END;

	MOVELINE (EXE_SBLK [SW_VAL2], LINNO);	! Increment

	IF (EDT$$CMP_LNO (LINNO, LNO_VFCMAX) GTR 0)
	THEN
	    BEGIN
	    EDT$$FMT_MSG (EDT$_SEQINCROV);
	    RETURN (0)
	    END;

	DECR I FROM 9 TO 5 DO
	    BEGIN
	    SEQ_INCR = .SEQ_INCR*10;
	    EDT$$LDIV (LINNO, DIGIT, .I);
	    SEQ_INCR = .SEQ_INCR + .DIGIT;
	    END

	END;

!+
! Try to open the file and set up file specific messages
!-

    IF (.CHECK EQL 0) 
    THEN 
	BEGIN
	FILESTRM = EDT$K_WRITE_FILE;
	CLOSEMSG = EDT$_WRIFILCLO;
	OPNMSG = EDT$_WRIFILCRE;
	END
    ELSE 
	BEGIN
	FILESTRM = EDT$K_OUTPUT_FILE;
	OUTPUTMSG = EDT$_ERROUTFIL;
	CLOSEMSG = EDT$_OUTFILCLO;
	OPNMSG = EDT$_OUTFILCRE;
	END;

    IF (.SEQ NEQ 0) THEN
	FILECODE = EDT$K_OPEN_OUTPUT_SEQ
    ELSE
	FILECODE = EDT$K_OPEN_OUTPUT_NOSEQ;

    STATUS = EDT$FILEIO (.FILECODE, .FILESTRM, 0);

    IF .STATUS
    THEN
	BEGIN
	MOVELINE (LNO_ZERO, L_COUNT);
	C_COUNT = 0;
	ABT_WRITE = 0;

	WHILE (EDT$$NXT_LNRNG (0) AND (.WK_LN NEQA EOB_LN)) DO
	    BEGIN
!+
! Check for a CONTROL/C.If one has been typed exit and delete the
! temporary file.
!-

	    IF (EDT$$CHK_CC ())
	    THEN
		BEGIN
		STATUS = EDT$FILEIO (EDT$K_CLOSE_DEL, .FILESTRM, 0);

		IF ( NOT .STATUS) THEN EDT$$FIOPN_ERR (.CLOSEMSG, FILE_DESC);

		RETURN (0);
		END;

!+
! Set up the RHB if /SEQ was used.
!-

	    IF (.SEQ NEQ 0)
	    THEN

		IF (.EXE_SBLK [SEQ_VAL] EQL 0)	!
		THEN
!+
! If no sequence start was given, then use the buffer's current line
! numbers in the VFC field (/SEQ )
!-
		    BEGIN
		    MOVELINE (WK_LN [LIN_NUM], LINNO);

		    DECR I FROM 14 TO 10 DO

			WHILE (EDT$$CMP_LNO (LINNO, LNO0 [.I]) GEQ 0) DO
			    SUBLINE (LNO0 [.I], LINNO, LINNO);

		    IF (EDT$$CMP_LNO (LINNO, LNO_VFCMAX) GEQ 0)
		    THEN
			IO_VFCHD = 65535
		    ELSE
			BEGIN
!+
! Set up sequence numbers, but first divide by 10**5
!-
			IO_VFCHD = 0;

			DECR I FROM 9 TO 5 DO
			    BEGIN
			    IO_VFCHD = .IO_VFCHD*10;
			    EDT$$LDIV (LINNO, DIGIT, .I);
			    IO_VFCHD = .IO_VFCHD + .DIGIT;
			    END

			END

		    END
		ELSE
!+
! Otherwise, use the given sequence start and increment (/SEQ:st:inc)
!-
		    BEGIN
		    IO_VFCHD = .SEQ_NUM;
		    SEQ_NUM = .SEQ_NUM + .SEQ_INCR;

		    IF (.SEQ_NUM EQL 65535) THEN SEQ_INCR = 0;

		    END;

!+
! Write a line to the file.
!-
	    REC_ADDR = WK_LN [LIN_TEXT];
	    REC_LEN = .WK_LN [LIN_LENGTH];
	    STRING_DESC (REC_DESC, REC_LEN, .REC_ADDR);

	    IF ( NOT EDT$FILEIO (EDT$K_PUT, .FILESTRM, REC_DESC))
	    THEN
		BEGIN
		EDT$$FIOPN_ERR (.OUTPUTMSG, .FILE_DESC);
		STATUS = EDT$FILEIO (EDT$K_CLOSE, .FILESTRM, 0);

		IF ( NOT .STATUS) THEN EDT$$FIOPN_ERR (.CLOSEMSG, FILE_DESC);

		RETURN (0);
		END;

!+
! Count lines and characters for consistency check.
!-
	    ADDLINE (LNO0 [0], L_COUNT, L_COUNT);
	    C_COUNT = .C_COUNT + .WK_LN [LIN_LENGTH];
	    END;

!+
! Do the consistency check.
!-

	IF .ABT_WRITE
	THEN
	    BEGIN
	    STATUS = EDT$FILEIO (EDT$K_CLOSE_DEL, .FILESTRM, 0);

	    IF ( NOT .STATUS) THEN EDT$$FIOPN_ERR (.CLOSEMSG, FILE_DESC);

	    EDT$$FMT_MSG (EDT$_NOFILWRT);
	    EXITD = 0;
	    RETURN (0);
	    END;

	IF (.CHECK NEQ 0)
	THEN

	    IF ((EDT$$CMP_LNO (L_COUNT, CUR_BUF [TBCB_LINE_COUNT]) NEQ 0) OR 	!
		(.C_COUNT NEQ .CUR_BUF [TBCB_CHAR_COUNT]))
	    THEN
		BEGIN
		EDT$$FMT_MSG (EDT$_CONCHKFLD);
		EXE_SBITS = (.EXE_SBITS OR OPT_SAVE);
		END;

!+
! Close the output file and print a message giving number of lines written
! to the file.
!-

	IF (.EXT_MOD) THEN EDT$$STOP_WKINGMSG ();

	STATUS = EDT$FILEIO (EDT$K_CLOSE, .FILESTRM, 0);

	IF .STATUS
	THEN
	    BEGIN
!+
! Reset the scrren width on exit if necessary. If the screen was reset, then
! reposition the cursor at the bottom of the screen.
!-

	    IF (.CHECK NEQ 0)
	    THEN
		IF (.TI_WID NEQ .SAV_TIWID)
		THEN
		    BEGIN
		    EDT$$SC_SETWID (.SAV_TIWID);
		    EDT$$SC_POSCSIF (.MESSAGE_LINE, 0);
		    END;

	    IF (.SUMRY EQL 1)
	    THEN
		BEGIN
!+
! Extract the resultant filename of the opened file and format
! it to write out if the summary flag is set.
!-

		EDT$$FMT_STR (CH$PTR (.FILE_DESC [DSC$A_POINTER]),
			.FILE_DESC [DSC$W_LENGTH]);

		EDT$$FMT_CH (%C' ');
		EDT$$FMT_STRCNT (L_COUNT, CH$PTR (UPLIT (' line')), 5);
		EDT$$FMT_CRLF ()
		END;

	    RETURN (1);
	    END
	ELSE
	    BEGIN
!+
! File was not closed, output error message.
!-
	    EDT$$FIOPN_ERR (.CLOSEMSG, FILE_DESC);
	    RETURN (0);
	    END;

	END
    ELSE
	BEGIN
!+
! File was not created, output error message.
!-
	EDT$$FIOPN_ERR (.OPNMSG, FILE_DESC);
	RETURN (0);
	END

    END;					! of routine WRITE_FILE
!<BLF/PAGE>

%SBTTL 'EDT$$EXI_CMD  - EXIT line-mode command'

GLOBAL ROUTINE EDT$$EXI_CMD 			! EXIT line-mode command
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Command processing routine for exit.  Switch to the main buffer,
!	write the output file and set the EXITD  flag
!	if it succeeded.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	RCOV_MOD
!
! IMPLICIT OUTPUTS:
!
!	EXITD
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$FND_BUF;

    EXTERNAL
	OUT_NAM : BLOCK,
	EXITD,
	RCOV_MOD;

    LOCAL
	RANGE : NODE_BLOCK;

!+
! Ignore the EXIT command encountered during recovery.
!-

    IF .RCOV_MOD THEN RETURN;

!+
! Setup the range as WHOLE.
!-
    RANGE [NODE_TYPE] = RANGE_NODE;
    RANGE [RAN_TYPE] = RAN_WHOLE;
    RANGE [PREV_RANGE] = 0;
!+
! Position into the MAIN buffer.
!-
    EDT$$FND_BUF (CH$PTR (UPLIT ('MAIN')), 4);
!+
! Attempt to write the file, and set the EXITED flag if it succeeds.
!-
    EXITD = WRITE_FILE (RANGE, 1, OUT_NAM);
    END;					! of routine EDT$$EXI_CMD
!<BLF/PAGE>

%SBTTL 'EDT$$WR_CMD  - WRITE line-mode command'

GLOBAL ROUTINE EDT$$WR_CMD 			! WRITE line-mode command
    : NOVALUE =

!++
! FUNCTIONAL DESCRIPTION:
!
!	Command processing routine for the write command.  Look at the current range;
!	if it is null, use the whole buffer.  Then write the file.
!
! FORMAL PARAMETERS:
!
!	NONE
!
! IMPLICIT INPUTS:
!
!	RNG_ORIGPOS
!	EXE_CURCMD
!
! IMPLICIT OUTPUTS:
!
!	CUR_BUF
!
! ROUTINE VALUE:
!
!	NONE
!
! SIDE EFFECTS:
!
!	NONE
!
!--

    BEGIN

    EXTERNAL ROUTINE
	EDT$$RD_CURLN;

    EXTERNAL
	WRT_NAM : BLOCK,
	CUR_BUF : REF TBCB_BLOCK,
	RNG_ORIGPOS : POS_BLOCK,
	EXE_CURCMD : REF NODE_BLOCK;	! Pointer to the current command.

    LOCAL
	SAV_BUF,				! address of original buffer
	RANGE : REF NODE_BLOCK;


!+
! Save the original position and default to whole range is not specified.
!-

    SAV_BUF = .CUR_BUF;				! save original address
    RANGE = .EXE_CURCMD [RANGE1];

    IF (.RANGE [RAN_TYPE] EQL RAN_NULL) THEN RANGE [RAN_TYPE] = RAN_WHOLE;

    WRITE_FILE (.RANGE, 0, WRT_NAM);

!+
! Reposition to the original line.
!-

    CUR_BUF = .SAV_BUF;				! first get the buffer address
    EDT$$CPY_MEM (POS_SIZE, RNG_ORIGPOS, .CUR_BUF);
    EDT$$RD_CURLN ();				! do the positioning
    END;					! of routine EDT$$WR_CMD
END						! of module EDT$LWRITE

ELUDOM