; This is the Install script for Rexecute.

(welcome "Welcome to the Rexecute installer.  This installer uses "
		"the Commodore Amiga Installer®. \n\n")
;(set @default-dest "SD0:")	;I use a virtual disk as default whilst debugging!

     ; install on hard disk
     (set dest2 (askdir  (prompt "Select the location to install the Rexecute directory")
                          (default @default-dest)
                          (help "Choose a destination partition or directory "
                                "to contain the Rexecute compiler.  The install "
                                "program will create a directory called 'Rexecute' "
                                "in the location you choose and copy the "
                                "compiler files to it."
                          )
                )
     )
     (set dest1 (tackon dest2 "Rexecute"))
     (set @default-dest dest1)
     (message "\n\nCompiler will be installed in "
               dest1
     )

     (makedir dest2 (safe) (infos))
     (makedir dest1 (safe) (infos))
     (makedir ("%s/Functions" dest1) (safe) (infos))
     (makedir ("%s/Lib" dest1) (safe) (infos))
     (makedir ("%s/ObjectFiles" dest1) (safe) (infos))
     (makedir ("%s/Support" dest1) (safe) (infos))

(copyfiles
	(prompt "Copying Rexecute files.")
	(help @copyfiles-help)
	(source "Rexecute:")
	(dest dest1)
	(pattern "Rexecute#?")
	(files)
	(infos)
	(confirm)
)

(copyfiles
	(prompt "Copying Librarian")
	(help @copyfiles-help)
	(source "Rexecute:")
	(dest dest1)
	(pattern "Librar#?")
	(files)
	(infos)
	(confirm)
)

(copyfiles
	(prompt "Copying Disassembler.")
	(help @copyfiles-help)
	(source "Rexecute:")
	(dest dest1)
	(pattern "DISEx#?")
	(files)
	(infos)
	(confirm)
)

(set temp ("%s/Support" dest1))
(copyfiles
	(prompt "Copying support files.")
	(help @copyfiles-help)
	(source "Rexecute:Support")
	(dest temp)
	(all)
	(files)
	(infos)
	(confirm)
)

(set temp ("%s/Functions" dest1))
(copyfiles
	(prompt "Copying Function files.")
	(help @copyfiles-help)
	(source "Rexecute:Functions")
	(dest temp)
	(all)
	(files)
	(infos)
	(confirm)
)

(set temp1 ("%s/Rexecute_Manual.guide" dest1))
(delete temp1 (safe))

(set temp1 ("%s/Rexecute_Install" dest1))
(delete temp1 (safe))

(set temp1 ("%s/Rexecute_Install.info" dest1))
(delete temp1 (safe))

(copyfiles
	(prompt "Copying Documentation.")
	(help @copyfiles-help)
	(source "Rexecute:Read_Me.info")
	(dest dest1)
	(newname "Rexecute_Manual.guide.info")
	(files)
	(confirm)
)

(copyfiles
	(prompt "Copying Documentation.")
	(help @copyfiles-help)
	(source "Rexecute:Rexecute_DOC")
	(dest dest1)
	(newname "Rexecute_Manual.guide")
	(files)
)
(set temp1("%s/Rexecute_Manual.guide" dest1))
(tooltype
	(dest temp1)
	(setdefaulttool "SYS:Utilities/Amigaguide")
	(safe)
)

(set action
	(askbool
		(prompt "\n\nDo you wish to install the Examples?")
		(help "\nThis will install all example scripts\nEssential if you wish to run the demo!")
	)
)

(if(< @user_level 1)
	(set action 1)
)
(if ( > action 0 )
	(makedir ("%s/Examples" dest1) (safe) (infos))
)
(set temp ("%s/Examples" dest1))
(if ( > action 0 )
	(copyfiles
		(prompt "Copying Examples...")
		(help @copyfiles-help)
		(source "Rexecute:Examples")
		(dest temp)
		(all)
		(files)
		(infos)
		(confirm)
	)
)

(set action
	(askbool
		(prompt "\n\nDo you wish to install the Demo?")
		(help "\nThis provides a guided tour of Rexecute\nplus a quick tutorial")
	)
)

(if(< @user_level 1)
	(set action 1)
)
(if ( > action 0 )
	(makedir ("%s/Demo" dest1) (safe) (infos))
)
(set temp ("%s/Demo" dest1))
(if ( > action 0 )
	(copyfiles
		(prompt "Copying Demo...")
		(help @copyfiles-help)
		(source "Rexecute:Demo")
		(dest temp)
		(all)
		(files)
		(infos)
		(confirm)
	)
)

(set action
	(askbool
		(prompt "\n\nDo you wish to install the\n`C' programmers stuff?")
		(help "\nOnly useful if you are going to include Rexecute\ngenerated Object Files in your own programs.")
	)
)

(if(< @user_level 1)
	(set action 1)
)
(if ( > action 0 )
	(makedir ("%s/PROGRAMMERS" dest1) (safe) (infos))
)
(set temp ("%s/PROGRAMMERS" dest1))
(if ( > action 0 )
	(copyfiles
		(prompt "Copying files...")
		(help @copyfiles-help)
		(source "Rexecute:PROGRAMMERS")
		(dest temp)
		(all)
		(files)
		(infos)
		(confirm)
	)
)

(set action
	(askbool
		(prompt "\n\nDo you wish to install the Public Domain stuff?")
		(help "\nThis contains some useful libraries and other stuff,\nIts archived with Lha.")
	)
)

(if(< @user_level 1)
	(set action 1)
)
(if ( > action 0 )
	(makedir ("%s/Public_Domain" dest1) (safe) (infos))
)
(set temp ("%s/Public_Domain" dest1))
(if ( > action 0 )
	(copyfiles
		(prompt "Copying Lha file...")
		(help @copyfiles-help)
		(source "Rexecute:Public_Domain")
		(dest temp)
		(all)
		(files)
		(infos)
		(confirm)
	)
)

(if (NOT (exists "LIBS:Amigaguide.library"))
	(copylib
		(prompt "Copying/Updating AmigaGUIDE.Library")
		(help @copylib-help)
		(source "Rexecute:LIBS/amigaguide.library")
		(dest "Libs:")
		(confirm)
	)
)

(if (NOT (exists "LIBS:horizon.library"))
	(copylib
		(prompt "Copying/Updating horizon.Library")
		(help @copylib-help)
		(source "Rexecute:LIBS/horizon.library")
		(dest "Libs:")
	)
)

(if (NOT (exists "SYS:Utilities/Amigaguide"))
	(copyfiles
		(prompt "Copying AmigaGUIDE.")
		(help @copyfiles-help)
		(source "Rexecute:AmigaGuide")
		(dest "SYS:Utilities")
		(pattern "AmigaGUIDE#?")
		(files)
		(infos)
		(confirm)
	)
)

(copylib
	(prompt "Copying/Updating Other Libraries")
	(help @copylib-help)
	(source "Rexecute:LIBS/rexxapp.library")
	(dest "Libs:")
	(confirm)
)

(copylib
	(prompt "Copying/Updating Other Libraries")
	(help @copylib-help)
	(source "Rexecute:LIBS/rexxarplib.library")
	(dest "Libs:")
	(confirm)
)

(copylib
	(prompt "Copying/Updating Other Libraries")
	(help @copylib-help)
	(source "Rexecute:LIBS/rexxmathlib.library")
	(dest "Libs:")
	(confirm)
)

(copylib
	(prompt "Copying/Updating Other Libraries")
	(help @copylib-help)
	(source "Rexecute:LIBS/rx_intui.library")
	(dest "Libs:")
	(confirm)
)

(copylib
	(prompt "Copying/Updating Other Libraries")
	(help @copylib-help)
	(source "Rexecute:LIBS/screenshare.library")
	(dest "Libs:")
	(confirm)
)


(set temp(  "assign Rexecute: %s\n" dest1))
(set error 0)
(set error
	(trap 4
		(startup "Rexecute"
			(prompt "Adding Rexecute assignment to \"S:user-startup\".")
			(help @startup-help)
			(command (temp))
		)
	)
)

(if (> error 0)
	(if (or (= @ioerr 222) (or (= @ioerr 223) (= @ioerr 224)))
		(message "Startup file is write protected. Use protect " "to write enable the file, and select Proceed" )
	( ;else
		(message "Non-Standard startup sequence detected. You must add " "the following line by hand.\n\n" "    assign Rexecute: " dest1 "\n")
		(set error 0)
	)
	)
)

(makeassign "Rexecute" dest1 )
(set temp
	(askstring
		(prompt "\nPlease enter your name\nDo NOT use any punctuation marks!")
		(help "\nThis string will be written into your AUTHOR\ntooltype found within the Rexecute icon.")
	)
)
(set temp1("%s/Rexecute" dest1))
(tooltype
	(dest temp1)
	(settooltype "AUTHOR" temp)
)

(set temp("run sys:utilities/amigaguide %s/Rexecute_Manual.guide" dest1))
(run (temp))


(set end_text "\n\nAll installed,\n\nHave fun!")
(exit end_text)

