1	EXTERNAL INTEGER FUNCTION CLI$PRESENT,CLI$GET_VALUE
	EXTERNAL INTEGER CONSTANT CLI$_PRESENT,CLI$_DEFAULTED
	EXTERNAL INTEGER CONSTANT CLI$_NEGATED,CLI$_ABSENT
	EXTERNAL INTEGER CONSTANT EDT$M_RECOVER,EDT$M_NOCOMMAND
	EXTERNAL INTEGER CONSTANT EDT$M_NOJOURNAL,EDT$M_NOOUTPUT
	EXTERNAL INTEGER CONSTANT EDT$M_NOCREATE
	EXTERNAL INTEGER EDT$FILEIO
	EXTERNAL INTEGER EDT$WORKIO
	EXTERNAL INTEGER AXLATE
	EXTERNAL INTEGER FUNCTION EDT$EDIT
	DECLARE INTEGER RESULT
	DIM INTEGER PASSFILE(1%)
	DIM INTEGER PASSWORK(1%)
	DIM INTEGER PASSXLATE(1%)
	PASSFILE(0%)=LOC(EDT$FILEIO)
	PASSWORK(0%)=LOC(EDT$WORKIO)
	PASSXLATE(0%)=LOC(AXLATE)
	DECLARE LONG Ret_Status,Options
	
	Input_File$=""
	Output_File$=""
	Journal_File$=""
	Command_File$=""
	ON ERROR GOTO 1000

10	IF CLI$PRESENT('INPUT') AND 1% THEN
   	    CALL CLI$GET_VALUE('INPUT',Input_File$)
	END IF

20	IF CLI$PRESENT('RECOVER') and 1% THEN
	   OPTIONS=OPTIONS+EDT$M_RECOVER
	END IF

30	IF CLI$PRESENT('READ_ONLY') AND 1% THEN
	    OPTIONS=OPTIONS+EDT$M_NOOUTPUT
	END IF


50	Ret_Status=CLI$PRESENT('COMMAND')
	IF (Ret_Status = CLI$_Present) THEN
   	    CALL CLI$GET_VALUE('COMMAND',Command_file$)
	ELSE IF (Ret_Status = CLI$_DEFAULTED) THEN
	    REM PRINT 'Use default command file'
	ELSE IF (Ret_Status = CLI$_NEGATED) THEN
	    Command_File$=""
	    OPTIONS=OPTIONS+EDT$M_NOCOMMAND
	END IF

60	IF CLI$PRESENT('OUTPUT') AND 1% THEN
   	    CALL CLI$GET_VALUE('OUTPUT',Output_File$)
	ELSE
	    REM PRINT 'Default to output=input'
	END IF

70	Ret_Status=CLI$PRESENT('JOURNAL')
	IF Ret_Status = CLI$_Present THEN
   	    CALL CLI$GET_VALUE('JOURNAL',Journal_File$)
	    REM PRINT 'Explicit Journal file present = ';Journal_File$
	ELSE IF Ret_Status = CLI$_DEFAULTED THEN
	    REM Print 'Use default journal file'
	ELSE 
	    OPTIONS=OPTIONS+EDT$M_NOJOURNAL
	END IF

80	Ret_Status=CLI$PRESENT('CREATE')
	IF Ret_Status = CLI$_Negated THEN
	    OPTIONS=OPTIONS+EDT$M_NOCREATE
	END IF
	    
	    


90	RESULT=EDT$EDIT(Input_File$,Output_File$,&
		Command_File$,Journal_File$,Options,&
		PASSFILE(0%)BY REF,PASSWORK(0%)BY REF,&
		PASSXLATE(0%)BY REF)
100	IF (RESULT AND 1%) =0%  THEN
		PRINT "VPWEDIT -- Call to EDT$EDIT failed, GET HELP"
		CALL LIB$STOP(RESULT BY VALUE)
	END IF
	GOTO 32000
1000	RESUME 1000
32000	END

