(set ProdName    "MediaPoint127")
(set ProdDirName "MediaPoint127")

; Where? *******************************************************************

(Procedure SetProdPlace
	(set @dest "")
	(set ProgDir "MediaPoint")
	(transcript "Selecting target drawer.")
	(while (= @dest (pathonly @dest))
		(set @dest
			(askdir
				(prompt "Only use this install script if an older version of MediaPoint can be found on your system.\nIn which drawer can MediaPoint be found?")
				(help @askdir-help)
				(default @default-dest)
				(newpath)
			)
		)
		(if (= @dest (pathonly @dest))
			(message "You need to select a drawer.\nIf it doesn't exist, create one.")	
		)
	)
	(if (not (exists @dest))
		(makedir @dest (infos))
		(tooltype (dest @dest) (noposition))
	)
	(set @default-dest @dest)
)

; Lha and Delete  ********************************************************

(procedure Install_Requested

	(set DestDir "ram:")
	(copyfiles
		(prompt "I will now copy the install files to ram:.")
		(help @copyfiles-help)
		(source "MediaPoint1:utils")
		(noposition) 
		(all)
		(infos)
		(dest Destdir)
	)

;*********
;* DISK1 *
;*********

; Directories setup ********************************************************

	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint1\n\nin any drive")
			(dest "MediaPoint1")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("Setting Up %s directories." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint1:Directories.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/Directories.lha ram:temp/"))
		(delete "RAM:temp/Directories.lha")

		(set DestDir @default-dest)
		(copyfiles
			(prompt ("I will now copy the %s Directories and icons." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; MediaPoint program ******************************************************

	(
		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s main program to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint1:MediaPoint.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/MediaPoint.lha ram:temp/"))
		(delete "RAM:temp/MediaPoint.lha")

		(set DestDir @default-dest)
		(copyfiles
			(prompt ("I will now copy the %s main program." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; System files ************************************************************

	(
		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s system files to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint1:system.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/system.lha ram:temp/"))
		(delete "RAM:temp/system.lha")
		(copyfiles
			(prompt ("I will now copy %s system files." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(dest (tackon @default-dest "system"))
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; System font *************************************************************

	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint1\n\nin any drive")
			(dest "MediaPoint1")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s system fonts to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint1:fonts.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/fonts.lha ram:temp/"))
		(delete "RAM:temp/fonts.lha")

		(set DestDir "Fonts:")
		(copyfiles
			(prompt ("I will now copy the %s system font." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; Assign ******************************************************************

	(if (>= osver 39)
  	    (
    	     (onerror
      	      (message
        	       "Didn't update startup sequence.  You will need to "
          	     "add the following commands manually: "
            	   "Assign MP: \"" @default-dest "\"\n"
          	  )
        	 )

         	(startup "MediaPoint"
          	  (prompt
            	   "Do you want to add an MP: assign to your startup sequence?"
            	)
            	(help @startup-help)
            	(command
             	  "Assign MP: \"" @default-dest "\"\n"
            	)
         	)
      	)
      	;else
      	(
         	(onerror
          	  (message
            	   "Didn't update startup sequence.  You will need to "
              	 "add the following command manually: "
               	 "Assign MP: \"" @default-dest "\"\n"
            	)
         	)

         	(startup "MediaPoint"
         	   (prompt "Do you want to add an MP: assign to your Startup sequence?")
         	   (help @startup-help)
         	   (command "Assign MP: \"" @default-dest "\"")
         	)
      	)
   	)

;*********
;* DISK2 *
;*********

; Xapps ******************************************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s Xapps to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:Xapps.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/Xapps.lha ram:temp/"))
		(delete "RAM:temp/Xapps.lha")

		(set DestDir (tackon @default-dest "Xapps"))

		(copyfiles
			(prompt ("Select the Xapps you wish to install"))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(confirm)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; Player device if xapps copied ********************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s LaserDisc players to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:Players.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/Players.lha ram:temp/"))
		(delete "RAM:temp/Players.lha")

		(set DestDir "Devs:")

		(copyfiles
			(prompt ("Installing the LaserDisc drivers."))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; MIDI libs **************************************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s libraries to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:libs.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/libs.lha ram:temp/"))
		(delete "RAM:temp/libs.lha")

		(set DestDir "Libs:")

		(copyfiles
			(prompt ("Installing the libraries."))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; ARexx examples *********************************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s ARexx examples to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:ARexx.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/ARexx.lha ram:temp/"))
		(delete "RAM:temp/ARexx.lha")

		(set DestDir (tackon @default-dest "ARexx"))
		(copyfiles
			(prompt ("I will now copy the %s ARexx examples." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; Scripts  **************************************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s Scripts to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:Scripts.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/Scripts.lha ram:temp/"))
		(delete "RAM:temp/Scripts.lha")

		(set DestDir (tackon @default-dest "Scripts"))
		(copyfiles
			(prompt ("I will now copy the %s Scripts." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; Pages ****************************************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s Pages to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:Pages.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/Pages.lha ram:temp/"))
		(delete "RAM:temp/Pages.lha")

		(set DestDir (tackon @default-dest "Pages"))
		(copyfiles
			(prompt ("I will now copy the %s Pages." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

; Tiles *****************************************************************

	(set DestDir @default-dest)
	(
		(askdisk 
			(prompt "\nPlease insert disk\n\nMediaPoint2\n\nin any drive")
			(dest "MediaPoint2")
			(help @askdisk-help)
		)

		(set DestDir "RAM:Temp")
		(copyfiles
			(prompt ("I will now copy the %s tiles to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:tiles.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/tiles.lha ram:temp/"))
		(delete "RAM:temp/tiles.lha")

		(set DestDir (tackon @default-dest "Graphics/tiles"))
		(copyfiles
			(prompt ("I will now copy the %s tiles." ProdName))
			(help @copyfiles-help)
			(source "Ram:Temp")
			(all)
			(infos)
			(noposition)
			(dest DestDir)
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)

)

; Remove the crap from ram: ************************************************

(procedure CleanUp
		(run ("ram:delete MP:Xapps/interlu#?"))
		(delete "RAM:Delete")
		(delete "RAM:Lha")
		(delete "RAM:Temp")
)

(onerror
	(CleanUp)
)

(SetProdPlace)		
(Makeassign "MP" @default-dest)
(Install_Requested)
(CleanUp)
