/*
** ExecuteFile.ced
**
** $VER: ExecuteFile.ced 1.0.1 (3.6.93)
**
** This script executes the current file as a batch procedure or as a Rexx program
** if first argument is R.
**
** This script requires CygnusEd Professional v3.5 (or later) to run.
**
** Copyright © 1990-1993 ASDG, Incorporated  All Rights Reserved
*/


TempBlock = "T:TempBlockFile"


OPTIONS RESULTS					/* Tell CygnusEd to return results. */


STATUS LINENUMBER				/* Ask CygnusEd for the current line number. */
CurrLine = 1 + RESULT
STATUS DESIREDCOLUMN				/* Ask CygnusEd for the current column number. */
CurrCol = 1 + RESULT
BEG OF FILE					/* Jump to the beginning of the current file. */
MARK						/* Mark a block. */
'END OF FILE'					/* Jump to the end of the current file. */
COPY						/* Copy the block (the entire file in this case) to the block buffer. */
SAVE CLIP AS TempBlock				/* Save the block to a temporary file. */
MARK						/* Now mark another block, */
LEFT						/* move left one and then */
COPY						/* do a copy block to purge the file from the block buffer. */
						/* This is not necessary but avoids wasting a large chunk of */
						/* memory to hold the entire file. */
JUMPTO CurrLine CurrCol				/* Jump to the old cursor position. */
ARG Mode
IF (Mode = 'R') THEN
	ADDRESS COMMAND 'Rx' TempBlock		/* Send the file to ARexx. */
IF (Mode ~= 'R') THEN
	ADDRESS COMMAND 'Execute' TempBlock	/* Send the file to DOS. */
ADDRESS COMMAND 'Delete >NIL:' TempBlock	/* Now delete the temporary file. */

EXIT 0
