; $VER: Scala MPeg Encoder/Decoder Install Program Version 1.0 (02aug94)

;----------------------------- Text Strings -------------------------------

(set msg_NoSelect	"You did not select anything. Please try again.")
(set msg_NoDrawer	("You must select a drawer to install %s. Please try again." @app-name))
(set msg_ChooseWhat	("Please select which parts of %s you would like to install:" @app-name))
(set msg_ChooseDest	"Please select the drawer where Scala Multimedia or InfoChannel is installed.")
(set msg_NoScala	"Scala Multimedia or InfoChannel was not found in this drawer. Please try again. If you have not installed Scala Multimedia or InfoChannel yet, please select \"Abort Install\" and install Scala Multimedia or InfoChannel first.")
(set msg_OldWorkbench	("You need at least Worbench 2.04 to install %s" @app-name))
(set msg_Installing	"Installing %s...")
(set msg_MPEG		"MPEG EX")
(set msg_MP100	"MPEG Encoder Utility")
(set msg_SelectDrawer	"In which drawer would you like to install the EXes? (Press \"Help\" for more information)\n")
(set msg_DrawerHelp	"If you choose \"Startup\", the EXes will be used the next time you start Scala Multimedia or InfoChannel.  If you choose \"EX\", you will have to move the EXes to the Startup drawer manually to activate them.")
(set msg_StartupDrawer	"Startup drawer  (use EXes immediately)")
(set msg_EXDrawer	"EX drawer (don't use EXes immediately)")

;------------------------------ Constants ---------------------------------

(set opt_MPEG		%000000001)
(set opt_MP100		%000000010)



;-------------------------- Utility procedures ----------------------------

(Procedure CheckConfig
    (set OS_Version (/ (getversion) 65536))
    (if (< OS_Version 37)
	(abort msg_OldWorkbench)
    )
)



;-------------------------- Menu procedures -------------------------------

(Procedure InstallMenu
    (until (<> Selection 0)
    	(
	    (set Selection
	        (askoptions
	            (prompt msg_ChooseWhat)
	            (help @askoptions-help)
                    (choices
                         msg_MPEG
                         msg_MP100
                    )
		)
	    )
	)
        (if (= Selection 0)
            (message msg_NoSelect)
        )
    )
)


(Procedure DestMenu
    (set @dest "")
    (while (or 	(= @dest (pathonly @dest))
    		(not (exists (tackon @dest "Startup")))
    		(not (exists (tackon @dest "EX")))
    		(not (exists (tackon @dest "Utilities")))
    	   )
        (set tmp
            (askdir
                (prompt msg_ChooseDest)
                (help @askdir-help)
                (newpath)
                (default @default-dest)
	    )
        )
        (set @dest tmp)
        (if (= @dest (pathonly @dest))
	    (message msg_NoDrawer)
	    (if	(or (not (exists (tackon @dest "Startup")))
    		    (not (exists (tackon @dest "EX")))
    		    (not (exists (tackon @dest "Utilities")))
		)
		(message msg_NoScala)
	    )
	)
    )
    (if (or (bitand Selection opt_MPEG)
    	)
        (set Drawer
    	    (select
    	        (askchoice 
	            (prompt msg_SelectDrawer)
	            (choices msg_StartupDrawer msg_EXDrawer)
                    (help msg_DrawerHelp)
	        )
	        "Startup"
	        "EX"
	    )
        )
    )
    (set @default-dest @dest)
)



;------------------------- Installation procedures ------------------------
(Procedure InstallFiles
    (if (bitand Selection opt_MPEG)
    	(
	    (working (msg_Installing msg_MPEG))
	    (copyfiles	(source "MD100_Install:EX/MPEG")
    			(dest (tackon @dest drawer))
	    		(infos)
	    )
	)
    )
	(copylib
		(prompt "Copying peggympeg.device to DEVS:...")
		(confirm "expert")
		(source "MD100_Install:devs/peggympeg.device")
		(dest "DEVS:")
		(help @copylib-help)
	)

    (if (bitand Selection opt_MP100)
    	(
	    (working (msg_Installing msg_MP100))
	    (copyfiles	(source "MD100_Install:Utilities/MPEGEncoder")
    			(dest (tackon @dest "Utilities"))
	    		(infos)
	    )
	)
    )
	(copylib
		(prompt "Copying mpeg.library to LIBS:...")
		(confirm "expert")
		(source "MD100_Install:libs/mpeg.library")
		(dest "LIBS:")
		(help @copylib-help)
	)
)
;------------------------------- Main program -----------------------------

(CheckConfig)
(InstallMenu)
(DestMenu)
(InstallFiles)
(if (< OSVersion 37)
		(run ("c:run SYS:Utilities/More :ReadMe"))
	)

(exit)
