(set ProdName    "MediaPoint128")
(set ProdDirName "MediaPoint128")

; 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 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"))
	)

; 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"))
	)

; 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"))
	)

; DemoFiles  **************************************************************

	(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 Demos to RAM:." ProdName))
			(help @copyfiles-help)
			(source "MediaPoint2:Demos.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/Demos.lha ram:temp/"))
		(delete "RAM:temp/Demos.lha")

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

; Copy new Cutmenu page ****************************************************

	(
		(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 some updated files." )
			(help @copyfiles-help)
			(source "MediaPoint2:updated.lha")
			(dest DestDir)
		)
		(working "Now decrunching files to ram:")
		(run ("ram:lha e ram:temp/updated.lha ram:temp/"))
		(delete "RAM:temp/updated.lha")
		(copyfiles
			(source "Ram:Temp/BallsInBox")
			(dest (tackon @default-dest "Scripts"))
		)
		(copyfiles
			(source "Ram:Temp/CutMenu")
			(dest (tackon @default-dest "Pages"))
		)
		(run ("ram:delete ram:temp/#? ALL"))
	)
)

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

(procedure CleanUp
		(run ("ram:delete MP:Xapps/interlu#?"))
		(run ("ram:delete MP:Xapps/genlock#?"))
		(run ("ram:delete MP:Xapps/studio16#?"))
		(run ("ram:delete MP:Xapps/toccata#?"))
		(run ("ram:delete MP:System/mail#?"))
		(run ("ram:delete MP:System/data#?"))

		(run ("ram:delete ram:temp/#? ALL"))
		(delete "RAM:Temp")
		(delete "RAM:Delete")
		(delete "RAM:Lha")
)

(onerror
	(CleanUp)
)

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