; script to install EasyLedgersDemo

	; set up a error cleanup routine

(onerror
	(makeassign "EasyLedgers2_Disk" (safe))	
)

(complete 0)

	; just in case the installation was restarted

(makeassign "EasyLedgers2_Disk" (safe))		; start fresh

	; see if this is really an update




(set is_update 0)
(set EasyLedgers2_dest (getassign "ELS2" "a"))


	; if update, be sure they want program in same place

(if EasyLedgers2_dest
	(if (askbool
			(prompt "Your current copy of EasyLedgers2 appears to be located in the drawer named \""
					EasyLedgers2_dest
					"\". Do you want the DEMO installed in that drawer?"
			)
			(help
				"The installer has determined that you may already have a "
				"copy of EasyLedgers2 installed on your system. If this is wrong or "
				"you want the update installed elsewhere, select NO as an "
				"answer. Otherwise, select YES."
			)
			(default 1)
		)

		(set is_update 1)		; if user wants in same place

		(set EasyLedgers2_dest			; if user wants in different place
			(tackon
				(askdir
					(prompt "A In which disk or drawer should EasyLedgers2 be installed?")
					(help @askdir-help)
					(default @default-dest)
				)
				"EasyLedgers"
			)
		)
	)


; else if not an update, get a location for program
; 
	(set EasyLedgers2_dest
		(tackon
			(askdir
				(prompt "B In which disk or drawer should the EasyLedgers2 DEMO be installed?")
				(help @askdir-help)
				(default @default-dest)
			)
			"EasyLedgers"
		)
	)
)


	; now lock on to install disk

(askdisk
	(prompt "Please insert \n the master program disk \n labeled \"EasyLedgers_Demo\".")
	(help	"The EasyLedgers2 DEMO program and other options will be copied "
			"from the \"EasyLedgers2\" into your system.")
	(dest  "EasyLedgers2_DEMO")
	(newname "EasyLedgers2_Disk")
)

	; make EasyLedgers2 drawer & icon if not there

(if (not is_update)
	(makedir EasyLedgers2_dest (infos))
)

	; at this point we have a valid destination, so we tell installer where
	; the application will end up so the exit page will be correct -- also,
	; the installation log file (if any) will be copied to the destination
(set @default-dest EasyLedgers2_dest)


(set whichfiles 
	(askoptions
		(prompt "Please select the files to be copied")
		(help	"This allows you to select only certain parts of the EasyLedgers2 "
			"system to be installed on your hard drive. For normal installation "
			"select all the items")
		(choices "EasyLedgers2DEMO program"
			 "Sample Accounts"
			 "Special HPLaserJet Driver")
			
	)
)

(set screen
	(askchoice
	(prompt "Please select the initial Screen type for EasyLedgers")
	(choices "WorkBench" "Custom Screen" )
	(help "\nEasyLedgers can run on the Workbench Screen or on its own Custom Screen. This is controlled by the toolttype SCREEN= in the Easyledgers 2 icon.\n")
	(default screen)
	)
)

(set country 2)
(set country
	(askchoice
	(prompt "EasyLedgers can operate in the following versions to suit specific taxation and other requirements for these countries\n\nPlease Select the desired country version.")
	(choices "Australia" "USA" "UK" "NewZealand")
	(help "\nSelect the country required.\n")
	(default country)
	)
	
)

(makedir (tackon EasyLedgers2_dest "Sample_Accounts")	(infos))
(makedir (tackon EasyLedgers2_dest "Accounts")	(infos))
(makedir (tackon EasyLedgers2_dest "Resources")	(infos))

(if	(in whichfiles 0)
	(
		(copyfiles
			(source "EasyLedgers2_Disk:els/EasyLedgers2DEMO")
			(dest EasyLedgers2_dest)
			(infos)
		)

		(tooltype
			(dest (tackon EasyLedgers2_dest "EasyLedgers2DEMO"))
			(settooltype "COUNTRY" (select country "AUS" "USA" "UK" "NZ" ))
			(settooltype "SCREEN" (select screen "WORKBENCH" "CUSTOMSCREEN"))
		)

		(copyfiles
			(source "EasyLedgers2_Disk:els/Resources")
			(dest (tackon EasyLedgers2_dest "Resources"))
			(all)
			(infos)
		)
	)
)

(if	(= country 2 )
	(set demo_name "EasyLedgers2_Disk:els/Sample_AccountsUK")
	(
	(set demo_name "EasyLedgers2_Disk:els/Sample_Accounts")
	)
)



(complete 50)

(if	(in whichfiles 1)
	(copyfiles
		(source demo_name)
		(dest (tackon EasyLedgers2_dest "Sample_Accounts"))
		(all)
		(infos)
	)


)

(complete 75)

(if	(in whichfiles 2)
	(copyfiles
		(source "EasyLedgers2_Disk:devs/printers/ELSHP_LaserJet")
		(dest "DEVS:printers")
	)
)

(complete 80)


(tooltype
	(dest EasyLedgers2_dest)
	(noposition)
)



(complete 95)

	; modify S:User-Startup

(startup "EasyLedgers2 Accounting"
	(prompt
		"Some instructions need to be added to the \"S:user-startup\" "
		"so that your system will be properly configured to use EasyLedgers2.")
	(help "Do this or EasyLedgers2 won't work!!")
	(command
		"ASSIGN ELS2: \"" EasyLedgers2_dest "\"\n"
	)
)

	; reinitialize assigns

(if (not @pretend)
	(makeassign "ELS2" EasyLedgers2_dest)
	
)


(complete 100)

	; cleanup

(makeassign "EasyLedgers2_Disk" (safe))

	; this is not strictly necessary, but doesn't hurt -- there is always
	; a default (exit) at the end of any script

(exit)

