*******************************************************************************
*
*	Change spooler options
*
*	Module	%M%	Version	%I% 	Date	%H%
*
*	(c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
*	This is unpublished proprietary source code of Ardent Software Inc.
*	The copyright notice above does not evidence any actual or intended
*	publication of such source code.
*
*******************************************************************************
*
*	Maintenence log - insert most recent change descriptions at top
*
*	Date.... GTAR# WHO Description.........................................
*	10/14/98 23801 SAP Change copyrights. 
*	08/29/96 19148 SAP Port Release 8.3.3 to ICL
*	08/18/96 18335 MAA Add new code to port 9 to Siemens Nixdorf.
*	08/27/92 8943  PVW Allow MD format of SP-ASSIGN =formname {options}
*	04/24/91 8257  JWT Ignore option M
*	05/07/90 7065  JWT added D option to fill in defaults
*	07/25/88   -    -  Maintenence log purged at 5.2.1, see release 5.1.10.
*
*******************************************************************************

$OPTIONS DEFAULT
INCLUDE UNIVERSE.INCLUDE MACHINE.NAME

	command.line = trim(@sentence)
	assign.command = field(command.line," ",1)
	options = field(command.line," ",2,999)

	H.flag=0
	S.flag=0
	O.flag=0
	D.flag=0
	copies=0
	form = ""
	unit  =0
	display= 0
	mode  =1
	if UV.MACHINE = "RM600" then optionnum=0 else optionnum=1
*
*	check for MD format
*
	test = field(options," ",1)
	if test[1,1] = "="
	then
		* setptr only accepts a form of upto six characters
		* but take 999 so that wrong for name is not assigned
		form = test[2,999]
		options = field(options," ",2,999)
	end

	ol=len(options)
	for i=1 to ol
		c=options[i,1]
		begin case
		case num(c)
			copies=c
			loop
				c=options[i+1,1]
			while c#"" and num(c)
				copies:=c
				i+=1
			repeat
		case c="?"
			display=if ol=1 then 1 else 2
		case c=" " or c="," or c="(" or c=")" or c="C" or c="I"
			NULL
		case c="D"
			D.flag=1
		case c="F" or c="Q"
			* option Fn or Qn which is set equal to FORM #
			form=""
			loop
				c=options[i+1,1]
			while c#"" and num(c)
				form:=c
				i+=1
			repeat
		case c="R"
			* this option set unit number
			unit=""
			loop
				c=options[i+1,1]
			while c#"" and num(c)
				unit:=c
				i+=1
			repeat
		case c="H"
			H.flag=1
		case c="S"
			S.flag=1
		case c="I"
			print "The 'I' option is not supported."
		case c="O"
			O.flag=1
		case c="T"
			form="TAPE"
		case c="M"
			* Ignore this option for IN2 compatability
			if UV.MACHINE = "RM600" then optionnum=1
		case 1
			print "Illegal option ":quote(c)
		end case
	next i

	if display # 1 then

		if form = "TAPE" then S.flag = 0
		opt=""
		begin case
		case S.flag and H.flag
			opt := ",RETAIN,HOLD"
		case H.flag
			opt := ",RETAIN,NOHOLD"
		case S.flag
			mode="NULL"
			opt := ",NORETAIN,NOHOLD"
		case 1
			opt := ",NORETAIN,NOHOLD"
		end case

		if O.flag      then opt:=",KEEP"           else opt:=",NOKEEP"
		if copies > 0  then opt:=",COPIES ":copies else opt:=",COPIES 0"
		if form   # "" then opt:=",FORM ":form     else opt:=",FORM"

		if D.flag
		   then opt := ",INFORM,BRIEF"
		else
			if optionnum
				then opt := ",NODEFAULT,INFORM,BRIEF"
		   	else opt := ",NODEFAULT,BRIEF"
		end
		execute "SETPTR ":unit:",,,,,":mode:opt

	end

	if display then execute "SETPTR ":unit

end