;$VER: SoundProbe-Install 1.50 (20.7.97)
;Installation sript - Richard
;*catch any errors and pass dos errors to a message screen
;*if a dos problem occured

;(set @default-dest "Work:")

(complete 0)

(Working "Starting up...")
(run "SoundProbe_Disk_1:unlzx -m e SoundProbe_Disk_1:stuff.lzx T: *")

(complete 1)

(onerror
(USER 2)

(IF (> @ioerr 0)
	(Message ("\n\nA Dos Error %ld has occured" @ioerr)
	"\n\n\n\nPlease consult your Workbench manual"
	(" for further details, or type Fault %ld from a shell." @ioerr))
)
)

(set default-dest @default-dest)

(SET default-user @user-level)

(user 2)

;*set version - true if greater than version 37
(SET WBVer (< 2424832 (getversion "exec.library" (resident))))

(user @user-level)

(SET App_Dest
(askdir
(prompt "Select the location for the SoundProbe drawer")
(help @askdir-help)
(default @default-dest))
)

(MAKEASSIGN "SoundProbe" App_Dest)

(IF (<> (exists "SoundProbe:SoundProbeTEMP_TEMP") 2)
	(MAKEDIR "SoundProbe:SoundProbeTEMP_TEMP")
)

(IF (= (exists "SoundProbe:SoundProbe") 2)
	(

	(Message "\nA previous installation of SoundProbe has been found.\nIt will be renamed SoundProbe_Old")

	(run "echo \"F/;BEGIN SoundProbe/*nD*nDF/;END SoundProbe/*nD*nQ*n\" >RAM:PatchUser-Startup")

	(run "T:rename SYS:S/user-startup SYS:S/user-startup.bak") 

	(run "T:Edit from SYS:S/user-startup.bak with RAM:PatchUser-Startup to SYS:S/user-startup")

	(if (= (exists "SoundProbe:SoundProbe_Old") 2)
	(run "delete SoundProbe:SoundProbe_Old all")
	)
	(run "rename SoundProbe:SoundProbe SoundProbe:SoundProbe_Old")
	(run "rename SoundProbe:SoundProbe.info SoundProbe:SoundProbe_Old.info")

	)

)

(SET n 1)

(while (< n 3)
	(

	(SET DISKNAME ("SoundProbe_Disk_%ld" n))

	(askdisk
	(Prompt ("\n\nPlease insert SoundProbe installation disk %ld in any drive" n))
	(help @askdisk-help)
	(DEST DISKNAME)
	)

	(copyfiles
	(source ("%s:" DISKNAME))
	(dest "SoundProbe:SoundProbeTEMP_TEMP")
	(all)
	)

	(SET n (+ n 1))

	)
)

(COMPLETE 5)

(Working "Joining archive chunks...")
(Run "T:Join SoundProbe:SoundProbeTEMP_TEMP/ArchiveChunkaa SoundProbe:SoundProbeTEMP_TEMP/ArchiveChunkab AS SoundProbe:SoundProbeTEMP_TEMP/Archive.lzx")

(COMPLETE 10)

(run "T:delete SoundProbe:SoundProbeTEMP_TEMP/ArchiveChunk#?")

(DELETE "T:Join")
(DELETE "SoundProbe:SoundProbeTEMP_TEMP/installer")
(DELETE "SoundProbe:SoundProbeTEMP_TEMP/Install-SoundProbe" (infos))

(SET EXTRACTSTRING "Extracting archive file...\n\n.")
(Working EXTRACTSTRING)

(SET COMPLETE_VALUE 10)

(COMPLETE COMPLETE_VALUE)

(Run "run SoundProbe:SoundProbeTEMP_TEMP/unlzx x SoundProbe:SoundProbeTEMP_TEMP/Archive.lzx SoundProbe:")

(set n 0)
(SET WORKING_STRING ".")

(While (SET FILETOTEST (select n "SoundPlayer.info" "Samples/8Bit.info" "Effects/Clap.spfxlibrary" "Settings/SPAura.settings" "Audio/NoOutput.spadlibrary" "Audio/AHI.spadlibrary" "Samples/8Bit/Crazy.IFF" "Effects/Delay/Echo.fxpreset" "Effects/WahWah.spfxlibrary" "Effects/Flange.spfxlibrary" "Display/Monitors/BWLogMeter.spimlibrary" "Buttons/SPBackdrop.ilbm" ""))

	(
	(until (= (exists ("SoundProbe:SoundProbe/%s" FILETOTEST)) 1)
	(
	(debug FILETOTEST)
	(run "SoundProbe:SoundProbeTEMP_TEMP/wait 3")
	)
	)

	(set n (+ n 1))
	(SET COMPLETE_VALUE (+ COMPLETE_VALUE 7))
	(COMPLETE COMPLETE_VALUE)
	(SET EXTRACTSTRING ("%s.." EXTRACTSTRING))
	(Working EXTRACTSTRING)
	)

)

;delete used archives

(set n 0)

(while (set LIB (select n
	"progresshandler.library"
	"playhandler.library"
	"guimaker.library"
	"fxhandler.library"
	"elibraryhandler.library"
	"audiohandler.library"
	 ""))
	(
	(set n (+ n 1))

	(copylib
	(source ("SoundProbe:SoundProbe/Libs/%s" LIB))
	(dest "LIBS:")
	(optional "force")
	)

	)
)

(run "T:delete SoundProbe:SoundProbeTEMP_TEMP all")

(SET App_Dest (expandpath App_Dest))

(IF (OR (= (substr App_Dest (- (strlen App_Dest) 1) ) ":")
      (= (substr App_Dest (- (strlen App_Dest) 1) ) "/"))
	(set App_Dest ("%sSoundProbe" App_Dest))
	(set App_Dest ("%s/SoundProbe" App_Dest))
)

(MAKEASSIGN "SP16" App_Dest)

(user 0)

(startup "SoundProbe"
(Prompt "Place SoundProbe assigns in the user-startup?")
(help @startup-help)
(Command
("IF Exists \"%s\"\n" App_Dest)
("Assign SP16: \"%s\"\n" App_Dest)
"EndIf\n"
)
)

(DELETE "T:delete")

(COMPLETE 100)

(exit)

