/********************************************/
/* Edit a SOURCE or NOTE file from Origins */
/********************************************/

/* NOTE:
   This file is the same as EditGen.rexx, except it specifically calls UEDIT
   as the editor of choice.

   To function correctly, this script must be renamed EditGen.rexx and copied
   to the REXX: directory.

   By changing the strings, this script could be used as a template for any
   editor that has an ARexx port.

   If your editor doesn't do a ScreenToFront() when called, you'll have to
   switch to the editor's screen to see it.
*/

/* Enable error handling routines */
Signal On Error
Signal On Syntax
Signal On Halt
Signal On IOErr

/* Change this string to the name of your editor */
/* Make sure to include the space after the name */
Editor = 'UEX '

/* Change this string to the name of your editor's ARexx port */
/*     Always remember that port names are case-sensitive     */
MyPort = 'URexx'

/* Change this string to the name of your editor's ARexx load */
/* command.  Make sure to include the space after the name.   */
Command = 'loadfile '

/* Get the name of the file to edit into this variable */
parse arg Filename

/* If the editor isn't up, start it */
If (~Show('P',MyPort)) then do
	address command 'run 'Editor Filename
	Exit
End

/* Else, set up the address */
address value MyPort

/* and tell the editor to load this file */
Command Filename

Exit

/**********************************************************************/
/*                           Error Handling                           */
/**********************************************************************/

Error:
	Parse Source Type Num MacroName Script Prog Port
	say 'ERROR: Macro "'MacroName'", Error: #'RC' ("'ErrorText(RC)'") on line 'SIGL' **'
	exit

Syntax:
	Parse Source Type Num MacroName Script Prog Port
	say 'SYNTAX: Macro "'MacroName'", Error: #'RC' ("'ErrorText(RC)'") on line 'SIGL' **'
	exit

Halt:
	Parse Source Type Num MacroName Script Prog Port
	say 'HALT: Macro "'MacroName'", Error: #'RC' on line 'SIGL' **'
	exit

IOErr:
	Parse Source Type Num MacroName Script Prog Port
	say 'IOERR: Macro "'MacroName'", Error: #'RC' on line 'SIGL' **'
	exit
