;$VER: SoundProbe-Install 2.0 (17.06.98)
;Installation sript - Richard/Dave
;*catch any errors and pass dos errors to a message screen
;*if a dos problem occured
;
;CHANGES:
;
; 14/11/97 - Fixed so now deletes files it creates as TEMP
;          - Also now asks if you want to add assigns to user-startup
;          - Removed putting libraries in LIBS:
;
; 20/11/97 - Fixed to work with new archive, also fixed bug that wasn't
;            removing the c,s drawers from the TEMP drawer.
;
;

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

(complete 0)

(Working "Starting up...")

(MAKEDIR "T:SP_TEMP")
(run "Soundprobe_Disk_1:Files/unlzx -m e Soundprobe_Disk_1:stuff.lzx T:SP_TEMP/")

(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:SP_TEMP/rename SYS:S/user-startup SYS:S/user-startup.bak") 

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

    (DELETE "RAM:PatchUser-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:Files/" DISKNAME))
    (dest "Soundprobe:SoundprobeTEMP_TEMP")
    (all)
    )

    (SET n (+ n 1))

    )
)

(COMPLETE 5)

(Working "Joining archive chunks...")
(Run "T:SP_TEMP/Join Soundprobe:SoundprobeTEMP_TEMP/ArchiveChunkaa Soundprobe:SoundprobeTEMP_TEMP/ArchiveChunkab TO Soundprobe:SoundprobeTEMP_TEMP/Archive.lzx")

(COMPLETE 10)

(DELETE "Soundprobe:SoundprobeTEMP_TEMP/ArchiveChunk#?")

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

(SET COMPLETE_VALUE 10)

(COMPLETE COMPLETE_VALUE)

(MAKEDIR "Soundprobe:Soundprobe" (infos))
(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" "Soundplayer" "DosIO/RAW.spiolibrary" "DosIO/MPEG.spiolibrary" "Storage/16Bit_Memory.spstlibrary" "Effects/Echo.spfxlibrary" "Effects/Smooth.spfxlibrary" "Display/Monitors/Monoscope.spimlibrary" "Buttons/TextStyle/Tool_Play.bru" "Samples/16Bit/Tennis.AIFF" ""))

    (
    (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)
    )

)

(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)

(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 files used

(DELETE "Soundprobe:SoundprobeTEMP_TEMP/#?")
(DELETE "Soundprobe:SoundprobeTEMP_TEMP")
(DELETE "T:SP_TEMP/#?")
(DELETE "T:SP_TEMP")

(SET @default-dest App_Dest)

(COMPLETE 100)

(exit)

