;---------------------------------------------------------------------
;Install-pi script - version 1.00
;--------------------------------
;Written by Ben Williams - January 23rd, 1992
;Last updated - January 24th, 1992
;
;This exec file installs the Public Interface Executive for
;Black Belt Systems' image processing tools.
;
;Pre-existing Requirements:
;--------------------------
;1 - ARexx must be installed;
;2 - There must be room to hold the new commands (1 meg or so)
;3 - The rename, delete, cd and copy commands must be in the user's PATH
;4 - There must be sufficient ram available (also about 1 meg)
;5 - REXX: and C: must be assigned to somewhere on a hard disk
;
;The archive contains:
;---------------------
; - A number of PI .rexx scripts
; - A number of PI command components
; - The list.list text file
; - The picmdpath text file
; - The Launch.rexx script
; - The Default.ipmcr macro startup file
; - The Default.immcr macro startup file
; - The Default.iimcr macro startup file
;
;Operations Performed by this script:
;------------------------------------
; - A temporary directory called "ram:pitdir" is created
; - The permanent directories c:cmpi and rexx:rxpi are created
; - Volatile assignments CMPI: and RXPI: are made to these directories
; - The launch.rexx script and the text file "picmdpath" are copied to REXX:
; - The small textfile "list.list" is copied to CMPI:
; - A number of ARexx scripts are copied to RXPI:
; - A number of command components are copied to CMPI:
; - New default files for the image processors are copied to s:
; - The temporary directory in ram is removed
;
;Remaining jobs for the user to do:
;----------------------------------
;add these two lines to their s:user-startup file:
;
;   assign RXPI: rexx:rxpi
;   assign CMPI: c:cmpi
;---------------------------------------------------------------------

;-----------------------------------------
;Check that everything we need is in place
;-----------------------------------------
assign >nil: exists REXX:
If WARN
  Echo "ARexx REXX: assignment not found - Cannot install!"
  Quit
  endif

assign >nil: exists c:
If WARN
  Echo "System C: assignment not found - Cannot install!"
  Quit
  Endif

assign >nil: exists s:
If WARN
  Echo "System S: assignment not found - Cannot install!"
  Quit
  Endif

If NOT EXISTS ram:piarc.lzh
  Echo "RAM:PIARC.LZH file not found - Cannot install!"
  Quit
  Endif

If NOT EXISTS ram:extract
  Echo "RAM:extract file not found - Cannot install!"
  Quit
  Endif

;-------------------------------------------------
;Create the temporary directory from which to copy
;-------------------------------------------------
If NOT EXISTS ram:pitdir
  makedir ram:pitdir
Else
  delete ram:pitdir/#? all quiet
  Endif

;------------------------------------------
;Attempt to make the directories we'll need
;unless user has already specified these
;somehow (a techie might do this to us)
;------------------------------------------
assign >nil: exists CMPI:
If WARN
  If NOT EXISTS c:cmpi
    makedir c:cmpi
    Endif
  assign CMPI: c:cmpi
  Endif

assign >nil: exists RXPI:
If WARN
  If NOT EXISTS rexx:rxpi
    makedir rexx:rxpi
    Endif
  assign RXPI: rexx:rxpi
  Endif

;----------------------------
;Recover the files we'll need
;----------------------------
cd ram:pitdir
copy c:delete to ram:pitdir
copy c:copy to ram:pitdir
copy c:rename to ram:pitdir
ram:extract e ram:piarc

;---------------------------------------------
;Save the user's old macro files if they exist
;---------------------------------------------
If EXISTS s:Default.immcr.old
  ram:pitdir/Delete s:Default.immcr.old
  endif
If EXISTS s:Default.immcr
  ram:pitdir/rename s:Default.immcr s:Default.immcr.old
  endif

If EXISTS s:Default.iimcr.old
  ram:pitdir/Delete s:Default.iimcr.old
  endif
If EXISTS s:Default.iimcr
  ram:pitdir/rename s:Default.iimcr s:Default.iimcr.old
  endif

If EXISTS s:Default.ipmcr.old
  ram:pitdir/Delete s:Default.ipmcr.old
  endif
If EXISTS s:Default.ipmcr
  ram:pitdir/rename s:Default.ipmcr s:Default.ipmcr.old
  endif

;-----------------------------
;Copy the special files first:
;-----------------------------
ram:pitdir/copy list.list to CMPI:
ram:pitdir/copy picmdpath to REXX:
ram:pitdir/copy launch.rexx to REXX:
ram:pitdir/copy Default.ipmcr to s:
ram:pitdir/copy Default.iimcr to s:
ram:pitdir/copy Default.immcr to s:
ram:pitdir/Delete launch.rexx list.list picmdpath quiet Default.#?mcr QUIET

;-------------------------------------
;Copy the PI Module ARexx scripts next
;-------------------------------------
ram:pitdir/copy #?.rexx to RXPI:
ram:pitdir/Delete #?.rexx QUIET

;---------------------------------
;Copy all the command modules next
;---------------------------------
ram:pitdir/copy #? to CMPI:
ram:pitdir/Delete CMPI:Delete CMPI:Copy CMPI:Rename QUIET

;----------------------------------------------------
;Find out if the user has a 68020 or better processor
;----------------------------------------------------
ask "Do you have a 68020, 68030 or 68040 (Y/N)?"
if WARN
  echo "Installing specially compiled commands for fast CPUs"
  ram:pitdir/rename CMPI:x_JPR030 CMPI:rdjpg
  ram:pitdir/rename CMPI:x_JPW030 CMPI:wrjpg
else
  echo "Installing standard commands"
  ram:pitdir/rename CMPI:x_JPR000 CMPI:rdjpg
  ram:pitdir/rename CMPI:x_JPW000 CMPI:wrjpg
endif

;------------------------------------------------------------------
;Remove all potential commands, we've already picked what we needed
;------------------------------------------------------------------
ram:pitdir/Delete CMPI:x_#? QUIET

;-----------------
;Finally, Clean up
;-----------------
cd ram:
ram:pitdir/Delete ram:extract QUIET
ram:pitdir/Delete ram:piarc.lzh QUIET
Delete ram:pitdir ALL QUIET

;All Done!
;---------
echo "Installation completed. Have fun!"
