chgpgm

	chgpgm(task.g.v, slot.i1.r, error.i2.r [,command_buffr.i1a.r]
	       [,sa_r50_task.i4.r] [,script_flag.i4.v]
	       [,command_buffer_length.i4.v])

	This routine causes a new application task to be loaded on the
	console system.  The task currently occupying the execution slot
	(if any) will be terminated (issued a termination request).

	task		PAGE_NAME_LEN ASCII characters describing the index
			page number of a primary application, or a longword
			containing the Rad50 description of a primary or secondary
			application.  For example, "M007" or RAD50("PA4232") or RAD50("SA0020")
			for a primary and secondary request respectively.
	slot		slot to be run in.  Postive and negative slot values are
                       used for this argument.  The negative slot value behavior
                       and the warping of +PA_SLOT, was introduced in the conversion
                       off of the PDP-11s to VAX/VMS.  PDP-11s only had a PA slot,
                       so the use of PA_SLOT on a PDP-11 was a request to start a new
                       app in the then only application slot.  This kludge allowed such
                       PDP-11 programs to work on VAX/VMS without changing
                       chgpgm(task,PA_SLOT,error) into chgpgm(task,my_slot(),error).
                       Since we are now moving to Linux it is really unfortunate that
                       we are still carrying around baggage from the migration to
                       VAX/VMS.  The gory details follow:
                       (-PA_SLOT -> primary application PA (absolutely positively),
                        +PA_SLOT -> primary application either PA, PB, or PC.
                                    The determination of which primary app slot is used
                                    depends on the whether or not the caller is is
                                    running in a primary application slot, i.e, PA, PB,
                                    or PC.
                                    - caller is not running in PA, PB, or PC:
                                      PA will be used (absolutely positively)
                                    - caller is running in PA, PB, or PC:
                                      if caller is running in PA, PA will be used
                                      if caller is running in PB, PB will be used
                                      if caller is running in PC, PC will be used,
                        +/-PB_SLOT -> primary application PB,
                        +/-PC_SLOT -> primary application PC
                        +/-PD_SLOT -> primary application PD
                        +/-PE_SLOT -> primary application PE
                        +/-SA_SLOT -> secondary application SA,
                        +/-SB_SLOT -> secondary application SB,
                        +/-SC_SLOT -> secondary application SC,
                        +/-SD_SLOT -> secondary application SD,
                        +/-SE_SLOT -> secondary application SE,
                        +/-ALARM_SLOT -> reserved for alarm system,
                        +/-UTIL_SLOT -> utility window,
                        +/-NONUSER_SLOT -> background user process,
                        0 -> "Available" secondary application slot
			      (SA, SB, SC, SD, or SE) or
                             SB_SLOT if all slots are in use.)
                       (A task may terminate itself and pass control to
                        another task by specifying its own slot ('myslot').
                        The calling task will still receive a termination
                        request via 'intype'.)
	error		error return:
			(CLIB_OK -> success - request transmitted,
			 CLIB_CHGPGM_BADASLOT -> invalid slot number,
			 CLIB_CHGPGM_ENQLOCK -> sytem error, notify system 
						programmer (should never
						occur - error communicating
						with PLD),
			 CLIB_CHGPGM_BUFLOCK -> command line buffer is locked 
						by another user, try later)
	[command_buffr]	optional "command_buffer_length" byte buffer of data to
			be delivered to target program (it receives with a call
			to 'getcmd') (default is NULL which results in no
			command buffer being passed)  The caller may leave
			portions of this buffer unused/ uninitialized so long as
			the target program treats the buffer it receives in the
			same fashion.
	[sa_r50_task]	returned ACNET Rad50 taskname of connected
			secondary application.  Since multiple copies of a
			secondary application may be running and each must
			have a unique network taskname, the ACNET taskname
			is modified depending on what slot the application
			is run in.  Returns nothing for primary applications.
			(Note: This cannot be the same address as "task"!!!)
			(default is NULL)
	[script_flag]	flag that specifies that the command line buffer
			argument contains a SCRIPT when TRUE.  The SCRIPT
			will be played by 'intype'.  When this argument has
			a value of TRUE and the command line buffer is
			provided, 'getcmd' always returns FALSE.
			(default is FALSE)
	[command_buffer_length] command buffer length in bytes
			(default is CMD_LIN_SIZ)

	This function requires the following include files:

	cnsparam_h, clib_h, acnet_errors_h

	Related functions:

	acnet_chgpgm, getcmd, putcmd, get_chgpgm_script, remote_program_check,
	remote_program_get_script, remote_program_get_method, intype, task_slot,
	who_started_me

	C/C++ usage:

	char		command_buffer[CMD_LIN_SIZ];
	unsigned char	slot = PA_SLOT;
	short		error;
	int		task;
	int		sa_rad50_task;
	int		script_flag = FALSE;

	chgpgm((void *) "D133",&slot,&error,command_buffer,
	       &sa_rad50_task,script_flag);

	task = rad50("SA1082");
	slot = SA_SLOT;

	chgpgm((void *) &task,&slot,&error,command_buffer,
	       &sa_rad50_task,script_flag);