; $VER: Sample-X Install 1.0 (31-5-97)
; Script by S.Olatubosun 
;
; Copy over all needed files
; add assigns, path changes to user-startup
; copy xphantom driver, modify Music-X tooltypes


; =========WELCOME=======


(set #chosen_dir
	(askdir
		(prompt "Please specify where to install the software. A new\nsubdirectory entitled 'Sample-X' will be created.")
		(help @askdir-help)
		(default "Work:")
	)
)


(set #sxdir (tackon #chosen_dir "Sample-X"))

(makedir #sxdir
	(prompt "Creating new directory\n\n" #sxdir)
	(help @makedir-help)
	(confirm)
)

; copy the Sample-X.info file to parent of #sxdir!!!

(copyfiles
	(prompt "Copying Sample-X files...")
	(help @copyfiles-help)
	(source "" )
	(dest #sxdir)
	(pattern "~(Install#?)")
	(confirm)
)


(set #assign_sx 
	("assign Sample-X: %s\npath Sample-X:util add\n" #sxdir)
)


(set #assign_prompt 
	(cat "Do you wish to add the following commands to the file \"S:user-startup\" so that your system will be properly configured to use Sample-X?\n\n" #assign_sx)
)

(startup "Sample-X"
	(prompt #assign_prompt)
	(help "No help for this function")
	(command #assign_sx)
)


; install xphantom driver 

(set #install_mx
	(askbool
		(prompt "Do you wish to install the 'xphantom' driver?")
		(help "This driver is needed to allow Music-X to communicate with Sample-X")
		(choices "Yes" "No")
		(default 0)
	)
)


(if #install_mx
	(if (exists "DEVS:midi" (noreq) )

; in future, check for newer version of xphantom
		(run "copy drivers/xphantom DEVS:midi" )

		(abort "the DEVS:midi drawer does not exist. Music-X is not installed on this system\n")
	)
)


; change Music-X tooltype

(set #install_mx
	(askbool
		(prompt "Do you wish to change MIDIPORT tooltype for Music-X?")
		(help "Music-X needs to know the various ports to which it can send MIDI data.")
		(choices "Yes" "No")
		(default 0)
	)
)

(if #install_mx
	(
		(set #mxfile 
			(askfile
				(prompt "Please select the Music-X executable file")
				(default "Work:")
				(help "Since the installer program does not know where Music-X is kept, the user must specify it. This is required so that the MIDIPORT tooltype of Music-X can be changed")
			)
		)
	
		(tooltype 
			(prompt "Changing one Music-X tooltype to read\n\nMIDIPORTS=internal,1A|xphantom,2A\n\nIf you are using other serial ports, please see the Sample-X documentation")
			(help "No help here either")
			(dest #mxfile)
			(settooltype "MIDIPORTS" "internal,1A|xphantom,2A")
			(confirm)
		)
	)
)

(makeassign "Sample-X" #sxdir)
;(run "path Sample-X:util add")

(set @default-dest #sxdir)
