$Job DDInstall

;	The installation of 3.1 OFIS Document Designer can be done from Floppy
;   or Server.

$PauseOff

; Nationalizable Strings.

ClearMsg	= 'pf'
Msg0		= 'pfAF                                                               '
Msg00		= '                                                               AA'

ConvMsg1	= '   NOTE: Customized format sets should be converted to         '
ConvMsg2	= '   documents prior to installation of OFIS Document Designer.  '
ConvMsg3	= '   Procedures for doing so are described in the release        '
ConvMsg4	= '   notice.                                                     '

FloppyMsg1  = '   When prompted to mount AE[f0]<Unisys>OFDD.02AF, please mount    '
FloppyMsg2  = '   the next distribution diskette in the floppy drive and      '
FloppyMsg3  = '   AEpress GOAF.                                                   '

FloppyMsg11  = '   Please mount the distribution diskette 4 of 4               '
FloppyMsg12  = '   if not already in the floppy drive.                         '
FloppyMsg13  = '   AEpress GOAF.                                                   '

DelMsg1     = '   By default, the installation of OFIS Document Designer will '
DelMsg2		= '   delete the commands and the run files associated  with an   '
DelMsg3		= '   earlier version  of Document Designer or OFIS Designer. If  '
DelMsg4		= '   you wish to avoid this, AEanswer NOAF at the next prompt.       '

DelCmMsg1   = '   By default, the deleted applications will be removed from   '
DelCmMsg2	= '   the Context Manager configuration file. If you do not want  '
DelCmMsg3	= '   that,  AEanswer NOAF at the following prompt.                   '

CmMsg1		= '   OFISDocument Designer commands will be removed from the    '
CmMsg2		= '   default CM configuration file that appears at the prompt    '
CmMsg3		= '   below. If you wish to specify a different configuration     '
CmMsg4		= '   file, do that now.                                          '

StyleMsg1	= '   By default, this installation will attempt to copy style    '
StyleMsg2	= '   libraries from AE[sys]<StyleBooks>AF. If they have been        '
StyleMsg3	= '   installed elsewhere, enter that path in response to the     '
StyleMsg4	= '   next prompt.                                                '


ServerMsg   = 'Copying files from the server ... '
CopyMsg		= 'Copying New Files...'
CommandMsg  = 'Creating commands ... '
DEFUtlMsg	= 'Installing DEF Utility...'
OpStatMsg	= 'Installing Operator Statistics...'
UpdateCMMsg = 'Updating CM Config file ... '
CmPrompt    = 'Enter CM Config file to be updated'
DoneMsg     = 'Installation completed'
AbortMsg	= 'Aborting Installation...'
DelSmpMsg	= 'Deleting Old Sample and Format files...'
DelRunMsg	= 'Deleting Old Commands and Run Files...'

CmdPrompt	= 'Enter Command File to be updated.'
StFrPrompt 	= 'Enter Style directory on the server:'
StylePrompt	= 'Enter Stylebook directory:'
WantInstall = 'Continue With The Installation ?'
WantLib     = 'Copy Style Books to disk ?'
WantDel     = 'Remove Old Files and Commands?'
WantEdit    = 'Install OFIS Document Editor ?'
WantSoftMsg = 'Install Softkey Interface ?'
WantSysOp	= 'Install Operator Statistics ?'
WantDEFUtl  = 'Install DEF Utility ?'
WantCm      = 'Add OFIS DD command to Context Manager configuration file ?'
WantCmDel   = 'Delete applications from CM ?'
CmDelPrompt	= 'Enter CM config file name: '
NoSuchFile  = 'No Such File.'
NoSuchCmdMsg = 'No Such Command.'

;	Initialize the variables.

YES		 = 255
NO		 = 0
floppy   = 0
server   = 2


$If (InstallType = floppy)
	OldFileList  = ConcatStrings(DeviceFrom, '<Unisys>OFDOldSample.files')
	OldRunList   = ConcatStrings(DeviceFrom, '<Unisys>OFDOldDD.files')
$Else
	OldFileList  = ConcatStrings(DeviceFrom, '<Wp>OFDOldSample.files')
	OldRunList   = ConcatStrings(DeviceFrom, '<Wp>OFDOldDD.files')
$EndIf

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

$DisplayLine(Msg0)
$DisplayLine(ConvMsg1)
$DisplayLine(ConvMsg2)
$DisplayLine(ConvMsg3)
$DisplayLine(ConvMsg4)
$DisplayLine(Msg00)

$Deassign(ConvMsg1)
$Deassign(ConvMsg2)
$Deassign(ConvMsg3)
$Deassign(ConvMsg4)

$If Public
	DestTo = '[Sys]<sys>'
	DefVol = '[Sys]'
	DefCmdFile = '[Sys]<sys>cluster.cmds'
	DefCfgFile = '[Sys]<sys>CmConfig.sys'
$Else
	DestTo = '[Sys]<sys>'
	DefVol = '[Sys]'
	DefCmdFile = CmdFileTo
	DefCfgFile = CmConfigFile
$EndIf

$If (InstallType = Server)
	VolFrom = '[Sys]'
$Else
	VolFrom = DeviceFrom
$EndIf

;******************** GET USER CHOICES ******************

NotAbort = UserSelectYesNo(WantInstall, 'Yes')
$DisplayLine(ClearMsg)

$If (NotAbort = NO)
	$DisplayLine(AbortMsg)
	$Cancel
	$GoTo EndOfScript
$Endif
$Deassign(NotAbort)

; Display Message and ask user if old files are to be deleted.

$DisplayLine(Msg0) 
$DisplayLine(DelMsg1) 
$DisplayLine(DelMsg2) 
$DisplayLine(DelMsg3) 
$DisplayLine(DelMsg4) 
$DisplayLine(Msg00) 

$Deassign(DelMsg1)
$Deassign(DelMsg2)
$Deassign(DelMsg3)
$Deassign(DelMsg4)

RemOldRun = UserSelectYesNo(WantDel, 'Yes')
$If (RemOldRun = YES)
	$DisplayLine(Msg0) 
	$DisplayLine(DelCmMsg1) 
	$DisplayLine(DelCmMsg2) 
	$DisplayLine(DelCmMsg3) 
	$DisplayLine(Msg00) 
	DelCmApp = UserSelectYesNo(WantCmDel, 'Yes')
	$If (DelCmApp = YES)
		$DisplayLine(Msg0) 
		$DisplayLine(CmMsg1) 
		$DisplayLine(CmMsg2) 
		$DisplayLine(CmMsg3) 
		$DisplayLine(CmMsg4) 
		$DisplayLine(Msg00) 
		CmDelFile = UserEnterValue(CmDelPrompt, DefCfgFile)
	$Endif
$Endif
$Deassign(DelCmMsg1)
$Deassign(DelCmMsg2)
$Deassign(DelCmMsg3)
$Deassign(CmMsg1)
$Deassign(CmMsg2)
$Deassign(CmMsg3)
$Deassign(CmMsg4)

$DisplayLine(ClearMsg)

; Get Product Info from User

DefStyleDir = ConcatStrings(Defvol, '<StyleBooks>')	
$If (InstallType = floppy)
	DefStylFrom = ConcatStrings(DeviceFrom, '<Unisys>')
$Else
	DefStylFrom = ConcatStrings(DeviceFrom, '<StyleBooks>')
$Endif
StyleFromDir = DefStylFrom
StyleDir = DefStyleDir

CopyStyle = UserSelectYesNo(WantLib, 'Yes')
$If (CopyStyle = YES)
	StyleDir = UserEnterValue(StylePrompt, DefStyleDir)
	$If (InstallType = Server)
		$DisplayLine(Msg0)
		$DisplayLine(StyleMsg1)
		$DisplayLine(StyleMsg2)
		$DisplayLine(StyleMsg3)
		$DisplayLine(StyleMsg4)
		$DisplayLine(Msg00)
		$Deassign(StyleMsg1)
		$Deassign(StyleMsg2)
		$Deassign(StyleMsg3)
		$Deassign(StyleMsg4)
		StyleFromDir = UserEnterValue(StFrPrompt, DefStylFrom)
		$DisplayLine(ClearMsg)
	$Endif
$Endif
$Deassign(DefStylFrom)
$Deassign(DefStyleDir)


CopyEdit  = UserSelectYesNo(WantEdit, 'Yes')
CopyDEF = UserSelectYesNo(WantDEFUtl, 'No')
WantSoft  = UserSelectYesNo(WantSoftMsg, 'Yes')
CopySysOp = UserSelectYesNo(WantSysOp, 'No')
CopyCmApp = UserSelectYesNo(WantCm, 'Yes')
CmdFileUse = UserEnterValue(CmdPrompt, DefCmdFile)
$If (CopyCmApp = YES)
	CmFile = UserEnterValue(CmPrompt, DefCfgFile)
$Endif
$Deassign(WantEdit)
$Deassign(WantSoftMsg)
$Deassign(WantSysOp)
$Deassign(WantCm)
$Deassign(CmdPrompt)
$Deassign(DefCmdFile)
$Deassign(DefCfgFile)

;******************** END of USER CHOICES *******************

WpDir    = ConcatStrings(DefVol, '<WP>')
Runfile	  = ConcatStrings(DestTo, 'OFISDocumentDesigner.run')

$Path,DefVol, sys

$RestartLabel
$ContinueOnError
$If (RemOldRun = YES)
;
;	Delete old Sample files
;	Delete old commands and remove from the CM config file.
;
	$DisplayLine(DelSmpMsg)
	$Deassign(DelSmpMsg)
	$DisplayLine
	$Command DELETE, @OldFileList
	$DisplayLine(DelRunMsg)
	$DisplayLine
	$Command DELETE, @OldRunList
	$If (DelCmApp = YES)
		$EchoOn
		$Command 'Remove Command', 'Document Designer', CmdFileUse
		$EchoOff
		$if (Erc = 12004 or Erc = 203) 
			$if (Erc = 12004)
				$DisplayLine(NoSuchCmdMsg)
			$Else
				$DisplayLine(NoSuchFile)
			$Endif
		$Else
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$EchoOn
			$Command 'Remove Command', 'OFIS Designer', CmdFileUse
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$EchoOn
			$Command 'Remove Command', 'Document Editor', CmdFileUse
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$EchoOn
			$Command 'Remove Command', 'Resume Document Designer', CmdFileUse
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$EchoOn
			$Command 'Remove Command', 'Resume OFIS Designer', CmdFileUse
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$EchoOn
			$Command 'Remove Command', 'OFIS Editor', CmdFileUse
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
		$Endif
		$EchoOn
		$Command 'CM Remove Application', 'Document Designer', CmDelFile
		$EchoOff
		$if (Erc = 12004 or Erc = 203) 
			$if (Erc = 12004)
				$DisplayLine(NoSuchCmdMsg)
			$Else
				$DisplayLine(NoSuchFile)
			$Endif
		$Else
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
			$EchoOn
			$Command 'CM Remove Application', 'OFIS Designer', CmDelFile
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
			$EchoOn
			$Command 'CM Remove Application', 'Document Editor', CmDelFile
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
			$EchoOn
			$Command 'CM Remove Application', 'Resume Document Designer', 
					CmDelFile
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
			$EchoOn
			$Command 'CM Remove Application', 'Resume OFIS Designer', CmDelFile
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
			$EchoOn
			$Command 'CM Remove Application', 'OFIS Editor', CmDelFile
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
		$Endif
	$Endif
$Endif

$Path, VolFrom, sys

$If (InstallType = server)
	PicFrom = ConcatStrings(DeviceFrom, '<WP>Cow.pic')
	$Display (ServerMsg)
	$DisplayLine(CopyMsg)
	$Command LCOPY, <sys>OFISDocumentDesigner.run,,DestTo,,y
	$Command LCOPY, <sys>OFDD.styles,,DestTo,,y
	$Command LCOPY, <sys>OfdMsg.bin,, DestTo,,y
$Else
	PicFrom = ConcatStrings(DeviceFrom, '<Unisys>Cow.pic')
	$DisplayLine(CopyMsg)
	StdStyle = ConcatStrings(DestTo, 'OFDD.styles')
	StdStyleFrom = ConcatStrings(StyleFromDir, 'Standard')
	StdBinFrom = ConcatStrings(StyleFromDir, 'OFdMsg.bin')
	$Command COPY, StdStyleFrom, StdStyle,y
	$Command LCOPY, StdBinFrom,, DestTo,,y
	$Deassign(StdStyle)
	$Deassign(StdStyleFrom)
	$Deassign(StdBinFrom)
$EndIf
$DisplayLine

$ContinueOnError
$Command CREATE DIRECTORY, WpDir
$CancelOnError
$Command LCOPY, PicFrom,, WpDir,,y
$ContinueOnError
$If (InstallType = floppy)
	$Command LCOPY, OldFileList,, WpDir,,y
	$Command LCOPY, OldRunList,, WpDir,,y
$EndIf
$Deassign(WpDir)
$Deassign(PicFrom)


$ContinueOnError
$Command CREATE DIRECTORY, StyleDir
$CancelOnError
$If (CopyStyle = YES)
	StlFileList = ConcatStrings(StyleFromDir, 'Style.files')
	$Command LCOPY, StlFileList,StyleFromDir,StyleDir,,y
	$Command LCOPY, @StlFileList,StyleFromDir,StyleDir,,y
	$Deassign(StlFileList)
$Endif

$If (InstallType = floppy)
	$DisplayLine(Msg0)
	$DisplayLine(FloppyMsg1)
	$DisplayLine(FloppyMsg2)
	$DisplayLine(FloppyMsg3)
	$DisplayLine(Msg00)
	$Deassign(FloppyMsg1)
	$Deassign(FloppyMsg2)
	$Deassign(FloppyMsg3)
	$DisplayLine
	$DisplayLine
	$DisplayLine
	$DisplayLine
	$DisplayLine
	$DisplayLine
	$DisplayLine
	$DisplayLine

	$Path,DefVol, sys
	ArchiveFrom = ConcatStrings(DeviceFrom, '<Unisys>OFDD')
	$EchoSome
	$Command RESTORE,ArchiveFrom,'<*>OFISDocumentDesigner.run', 
		'<sys>OFISDocumentDesigner.run',y
	$EchoOff
	$DisplayLine(ClearMsg)
	$DisplayLine
	$Path, DeviceFrom, sys
$Endif

$RestartLabel

InstallNew:

; Install New Commands

$If (WantSoft = YES)
	CommandCase = '03'
	EditCase = '04'
$Else
	CommandCase = '00'
	EditCase = '02'
$Endif

$DisplayLine(CommandMsg)
$Command 'New Command', 'OFIS Document Designer', Runfile, 
	('[Document(s)]'),'Invokes OFIS Document Designer',
	y, CommandCase, CmdFileUse


$Command 'New Command', 'Resume OFIS Document Designer', Runfile, 
	('[Document(s)]'),'Resumes OFIS Document Designer',
	y, '01', CmdFileUse

$If (CopyEdit = YES)
	$Command 'New Command', 'OFIS Document Editor', Runfile, 
		('[Document(s)]'),'Invokes OFIS Document Editor',
		y, EditCase, CmdFileUse
$Endif

$If (InstallType = floppy)
	DiskType = FileVersion('[DD3.13]<Unisys>OFDD.03')
	$IF DiskType <> '0'
		$DisplayLine(Msg0)
		$DisplayLine(FloppyMsg11)
		$DisplayLine(FloppyMsg12)
		$DisplayLine(FloppyMsg13)
		$DisplayLine(Msg00)
		$Deassign(FloppyMsg11)
		$Deassign(FloppyMsg12)
		$Deassign(FloppyMsg13)
		$DisplayAndWait
	$Endif
$Endif

$RestartLabel

; If installing Operator Statistics, copy that run file now

$If (CopySysOp = YES)
	$Command LCOPY,'<sys>OpStatsOFd.run',,DestTo,,y
	OpStatRun = ConcatStrings(DestTo, 'OpStatsOFd.run')
	$DisplayLine(OpStatMsg)
	$Command 'New Command', 'Operator Statistics OFd' , OpStatRun, 
		('Input Stats File','[Output Stats File]',
			'[Delete Stats file (Default = No) ?]'), 
		'Invoke OFIS Designer Operator Statistics.', y, '00', CmdFileUse
$Endif

; If installing DEF Utility , copy that run file now

$If (CopyDEF = YES)
	$Command LCOPY,'<sys>DEF.run',,DestTo,,y
	$Command LCOPY,'<sys>DEFMsg.bin',,DestTo,,y
	$Command LCOPY,'<sys>DEFUtil.info',,DestTo,,y
	DEFUtlRun = ConcatStrings(DestTo, 'DEF.run')
	$DisplayLine(DEFUtlMsg)
	$Command 'New Command', 'Document Exchange To DEF' , DEFUtlRun,
		('From document(s)','[To DEF files(s)]',
		'[Target (O, 2, 1 or w)]', '[Output (s, a, or b)]',
		'[Overwrite OK?]', '[Confirm each?]', '[Continue on error?]'),
		'Convert document(s) named to Document Exchange Format.', y,
		'00', CmdFileUse
	$Command 'New Command', 'Document Exchange From DEF' , DEFUtlRun,
		('From DEF files(s)', '[To document(s)]',
		'[Pass through unrecognized DEF codes?]',
		'[Overwrite OK?]', '[Confirm each?]', '[Continue on error?]'),
		'Convert DEF documents to OFIS Document Designer 3.0 format.', y,
		'01', CmdFileUse
$Endif

; Add CM Application if specified by the user.

$RestartLabel
$ContinueOnError
$If (CopyCMApp = YES)
	$DisplayLine(UpdateCMMsg)
	$EchoOn
	$Command 'CM ADD APPLICATION', CmFile, 'OFIS Document Designer', 
			RunFile, 900, 'O D D',, CommandCase,,,,,,,,y
	$EchoOff
	$if (Erc = 12004 or Erc = 203) 
		$if (Erc = 12004)
			$DisplayLine(NoSuchCmdMsg)
		$Else
			$DisplayLine(NoSuchFile)
		$Endif
	$Else
		$if (Erc <> 0) 
			DisplayErrorMessage(Erc)
		$Endif
		$DisplayLine
		$EchoOn
		$Command 'CM ADD APPLICATION', CmFile, 
	'Resume OFIS Document Designer', RunFile, 900, 'R O D D',, '01',,,,,,,,y
		$EchoOff
		$if (Erc <> 0) 
			DisplayErrorMessage(Erc)
		$Endif
		$DisplayLine
		$If (CopyEdit = YES)
			$EchoOn
			$Command 'CM ADD APPLICATION', CmFile, 'OFIS Document Editor', 
				RunFile, 900, 'O D E',, EditCase,,,,,,,,y
			$EchoOff
			$if (Erc <> 0) 
				DisplayErrorMessage(Erc)
			$Endif
			$DisplayLine
		$Endif
	$Endif
$EndIf

$DisplayLine (DoneMsg)

; Wrap up the installation

EndOfScript:

$Path, Sys, Sys
$PauseOn

$End

