; Installation script for Music-X 2.0
; $VER: Install-MusicX 2.0 (10th May 1994)

; a subroutine for later

(procedure askmidi
  (
	(set whichmidi
	  (askoptions
        (prompt "Which serial outputs do you want to support?")
		(help @askoptions-help)
        (choices "Internal Serial Port" "Checkpoint Serial Card" "One-Stop Music Shop")
        (default 1)
      )
    )

	(set count 1)
	(set midiports "")

	(if (bitand whichmidi 1)
      (
        (set midiports "internal,1A")
        (set count 2)
      )
    )
	(if (bitand whichmidi 2)
      (
		(if (<> midiports "") (set midiports (cat midiports "|")))
        (set midiports (cat midiports "checkpoint," count "A," (+ count 1) "B"))
        (set count (+ count 2))
      )
    )
	(if (bitand whichmidi 4)
      (
		(if (<> midiports "") (set midiports (cat midiports "|")))
        (set midiports (cat midiports "OneStopMusicShop," count "A," (+ count 1) "B"))
      )
    )

	(if (<> midiports "")
		(tooltype 
	      (dest (tackon app_locate "Music-X"))
		  (settooltype "MIDIPORTS" midiports)
        )
    )
  )
)

; some 'constants'

(set app_volume_name_1 "Music-X2.0")
(set app_volume_name_2 "Music-Xtras")
(set app_volume_1 "Music-X2.0:")
(set app_volume_2 "Music-Xtras:")
(set orig_user_level @user-level)

(set libdir "Music-Xtras:Libraries")
(set perfdir "Music-Xtras:Performances")
(set filtdir "Music-Xtras:KMaps")

; ask user if this is a new install
; switch user level to EXPERT do this

(user 2)

(set update
	(askbool
		(prompt "Is there a version of Music-X already installed on your system?")
		(help "Select 'Yes' is you already have either version 1.0 or 1.1 of "
			  "Music-X installed on your system. If you are a newcomer, select "
			  "'No'.")
		(default 0)
	)
)

(complete 5)

; first, handle the case of an update

(if update
	(
	  (set app_locate
		(askdir
		  (prompt "Please indicate where your current copy of Music-X is located.")
		  (help @askdir-help)
		  (default @default-dest)
		)
	  )

	  (set @default-dest app_locate)

	  ; switch user level back

	  (user orig_user_level)

      (complete 10)

	  ; copy files on disk 2 to drawer (assume in drive)

	  (set xtras
		(askoptions
		  (prompt "Which (if any) of these sets of files do you want installed along "
			"with the Music-X program files?")
		  (help @askoptions-help)
		  (choices "Librarian Support" "Keymaps" "Example Performances"
			"Samples" "Utilities" "ARexx Scripts")
		  (default 63)
        )
	  )

      (complete 15)

	  (if (bitand xtras 1)
	    (
          (copyfiles
            (source app_volume_2)
            (dest app_locate)
            (choices "Editors" "Editors.Doc" "Libraries" "Protocols.Doc" "Copy_From_NX.Doc" "Late Notes.Doc")
            (infos)
          )
          (copyfiles
            (source (tackon app_volume_2 "icons/libr"))
            (dest app_locate)
			(all)
          )
		  (set libdir "Libraries")
		)
	  )

      (complete 25)

	  (if (bitand xtras 2)
	    (
		  (copyfiles
            (source app_volume_2)
            (dest app_locate)
            (choices "Kmaps")
            (infos)
          )
          (copyfiles
            (source (tackon app_volume_2 "icons/kmap"))
            (dest app_locate)
			(all)
          )
		  (set filtdir "KMaps")
        )
	  )

      (complete 35)

	  (if (bitand xtras 4)
	    (
	      (copyfiles
            (source app_volume_2)
            (dest app_locate)
            (choices "Performances")
            (infos)
          )
          (copyfiles
            (source (tackon app_volume_2 "icons/perf"))
            (dest app_locate)
			(all)
          )
		  (set perfdir "Performances")
        )
	  )

      (complete 45)

	  (if (bitand xtras 8)
	    (
          (copyfiles
            (source app_volume_2)
            (dest app_locate)
            (choices "Samples")
            (infos)
          )
          (copyfiles
            (source (tackon app_volume_2 "icons/samp"))
            (dest app_locate)
			(all)
          )
        )
	  )

      (complete 55)

	  (if (bitand xtras 16)
	    (
		  (copyfiles
            (source app_volume_2)
            (dest app_locate)
            (choices "Lookout" "LookOut.doc" "MusicX-to-MIDI" "MusicX-to-SMUS")
            (infos)
          )
          (copyfiles
            (source (tackon app_volume_2 "icons/util"))
            (dest app_locate)
			(all)
          )
        )
	  )

      (complete 65)

	  ; copy files on disk 1 to drawer

	  (askdisk
	    (prompt "Please insert the disk labeled \"Music-X Program Disk\".")
	    (help @askdisk-help)
	    (dest app_volume_name_1)
	  )

      (copyfiles
        (source app_volume_1)
        (dest app_locate)
        (choices "Music-X" "TitlePage" "MusicX-Modules" "Default.Perf"
			"Install Modules" "Modules" "Protocols")
        (infos)
      )

      (complete 85)

      (tooltype 
        (dest (tackon app_locate "Music-X"))
        (settooltype "PROTODIR" "Protocols")
        (settooltype "PERFTOOL" (tackon app_locate "Music-X"))
        (settooltype "LIBDIR" libdir)
        (settooltype "PERFDIR" perfdir)
        (settooltype "FILTDIR" filtdir)
      )

      (complete 90)

	  (if (bitand xtras 32)
	    (copyfiles
          (source app_volume_1)
          (dest app_locate)
	      (choices "rexx")
        )
	  )

      (complete 93)

      (copyfiles
        (source (tackon app_volume_1 "devs/midi"))
        (dest "devs:midi")
        (choices "internal" "checkpoint" "OneStopMusicShop")
        (infos)
      )

      (complete 95)

	  (if (exists "devs:midi.device")
        (delete "devs:midi.device"
          (prompt "The file 'midi.device' is no longer needed by Music-X. Should "
            "it be deleted?")
          (help "The file 'midi.device' was included in Music-X 1.0. It is no "
            "longer needed.")
		  (confirm)
        )
      )

      (delete (tackon app_locate "MXAssign") (infos))

	  (askmidi)

	  (exit)
	)
)

; switch user level back

(user orig_user_level)

; tell average/expert user what we'll be doing

(message
   "\nYour copy of Music-X 2.0 will be installed in a new drawer named "
   "\"Music-X Drawer\". You will be asked where on your hard drive "
    "(or other storage device) you want this drawer created. In addition, "
   "some fonts and midi drivers will be installed in your system area."
)

; ask user where to put the drawer

(set app_locate
   (askdir
      (prompt "Please indicate where you want the Music-X Drawer "
            "to be located.")
      (help @askdir-help)
      (default @default-dest)
   )
)

; make the main drawer

(set app_locate (tackon app_locate "Music-X Drawer"))

(makedir app_locate (infos))

(set @default-dest app_locate)

(complete 10)

; copy files on disk 2 to drawer (assume in drive)

(set xtras
  (askoptions
    (prompt "Which (if any) of these sets of files do you want installed along "
	  "with the Music-X program files?")
    (help @askoptions-help)
    (choices "Librarian Support" "Keymaps" "Example Performances"
	  "Samples" "Utilities" "ARexx Scripts")
    (default 63)
  )
)

(complete 15)

(if (bitand xtras 1)
  (
    (copyfiles
      (source app_volume_2)
      (dest app_locate)
      (choices "Editors" "Editors.Doc" "Libraries" "Protocols.Doc" "Copy_From_NX.Doc" "Late Notes.Doc")
      (infos)
    )
    (copyfiles
      (source (tackon app_volume_2 "icons/libr"))
      (dest app_locate)
	  (all)
    )
    (set libdir "Libraries")
  )
)

(complete 25)

(if (bitand xtras 2)
  (
    (copyfiles
      (source app_volume_2)
      (dest app_locate)
      (choices "Kmaps")
      (infos)
    )
    (copyfiles
      (source (tackon app_volume_2 "icons/kmap"))
      (dest app_locate)
	  (all)
    )
    (set filtdir "KMaps")
 )
)

(complete 35)

(if (bitand xtras 4)
  (
    (copyfiles
      (source app_volume_2)
      (dest app_locate)
      (choices "Performances")
      (infos)
    )
    (copyfiles
      (source (tackon app_volume_2 "icons/perf"))
      (dest app_locate)
	  (all)
    )
    (set perfdir "Performances")
  )
)

(complete 45)

(if (bitand xtras 8)
  (
    (copyfiles
      (source app_volume_2)
      (dest app_locate)
      (choices "Samples")
      (infos)
    )
    (copyfiles
      (source (tackon app_volume_2 "icons/samp"))
      (dest app_locate)
	  (all)
    )
  )
)

(complete 55)

(if (bitand xtras 16)
  (
  (copyfiles
      (source app_volume_2)
      (dest app_locate)
      (choices "Lookout" "LookOut.doc" "MusicX-to-MIDI" "MusicX-to-SMUS")
      (infos)
    )
    (copyfiles
      (source (tackon app_volume_2 "icons/util"))
      (dest app_locate)
	  (all)
    )
  )
)

(complete 65)

; copy files on disk 1 to drawer

(askdisk
  (prompt "Please insert the disk labeled \"Music-X Program Disk\".")
  (help @askdisk-help)
  (dest app_volume_name_1)
)

(copyfiles
  (source app_volume_1)
  (dest app_locate)
  (choices "Music-X" "TitlePage" "MusicX-Modules" "Default.Perf"
	"Install Modules" "Modules" "Protocols")
  (infos)
)

(complete 85)

(tooltype 
  (dest (tackon app_locate "Music-X"))
  (settooltype "PROTODIR" "Protocols")
  (settooltype "PERFTOOL" (tackon app_locate "Music-X"))
  (settooltype "LIBDIR" libdir)
  (settooltype "PERFDIR" perfdir)
  (settooltype "FILTDIR" filtdir)
)

(complete 90)

(copyfiles
  (source (tackon app_volume_1 "fonts"))
  (dest "FONTS:")
  (choices "Peridot" "MXsymbols")
  (fonts)
)

(complete 93)

(if (bitand xtras 32)
  (copyfiles
    (source app_volume_1)
    (dest app_locate)
    (choices "rexx")
  )
)

(complete 95)

(copyfiles
  (source (tackon app_volume_1 "devs/midi"))
  (dest "devs:midi")
  (choices "internal" "checkpoint" "OneStopMusicShop")
  (infos)
)

(askmidi)

(exit)
