(if (< (/ (getversion) 65536) 37)
 	(abort "You need at least OS 2.0 to use this program.")
)

(set #ver "$VER: Messie Installation Script 1.0 (10.08.96)")
;----------------------------------------------------------------------------
; let's go! 
;----------------------------------------------------------------------------

(welcome "You wish to install Messie? Fine, but please answer a few questions first...")

(complete 0)

(set @app-name "Messie")

(if (= 0 (exists "ENV:MagicWB"))
 	(
 		(
 		 message "\n\n\nYou don't seem to have MagicWB, so the icons may look quite strange.\n\n"
 		         "See the manual (section ) for more information about MagicWB."
 		)
 		
 	)
)

(working "I am so curious...")

(set @default-dest 
	(askdir
		(prompt "Please select a drawer where Messie can create its subdirectory")
		(help @askdir-help)
		(default @default-dest)
	)
)

(complete 10)

(copyfiles
	(confirm "expert")
	(prompt "Copying the icon of Messie's directory")
	(source "/Messie.info")
	(nogauge)
	(dest @default-dest)
	(help @copylib-help)
)

(set @default-dest (tackon @default-dest "Messie"))

(copylib
	(confirm "expert")
	(nogauge)
	(prompt "Copying the executable")
	(source "Messie")
	(dest @default-dest)
	(infos)
	(help @copylib-help) 
)

(complete 20)

(if (>= (/ (getversion "locale.library" (resident)) 65536) 37)
	(set locale 1)

	(if (>= (/ (getversion "LIBS:locale.library") 65536) 37)
		(set locale 1)
		(set locale 0)
	)
)

(if (= locale 0)
        (set locale 
		(askbool
			(prompt "Could not find locale.library. Do you want to install the catalog file?")
			(help "If you ask me, it would not make much sense...")
			(default 0)
		)
	)
)

(if (= locale 1)
	(
		(copyfiles
		        (confirm "average")
 			(prompt "Copying the catalog file(s)")
	 		(help "If you can't find your language here, just skip this part.\n\n" @copyfiles-help)
 			(source "catalogs")
 			(dest (tackon @default-dest "catalogs"))
 			(all)
		)
	)
)

(complete 40)

(set #datadir 
	(askdir
		(prompt "Please select a directory where the recorded data will be stored. Messie will create one subdirectory per day there.")
		(help @askdir-help)
		(default @default-dest)
	)
)

(tooltype
	(prompt "Setting the tooltype WORKDIR to " #datadir)
	(help "The tooltype WORKDIR allows Messie to know where to write the data.\n\n" @tooltype-help)
	(dest (tackon @default-dest "Messie"))
	(settooltype "WORKDIR" #datadir)
	(confirm "expert")
)

(complete 50)

(copyfiles
	(prompt "Copying the doc.")
	(nogauge)
	(help "Don't want it? Then skip this part.\n\n" @copyfiles-help)
	(source "Messie.guide")
	(dest @default-dest)
	(confirm "average")
	(infos)
)

(complete 60)

(copyfiles
	(prompt "Copying the source directory.")
	(help "Don't want them? Well, then skip this part.\n\n" @copyfiles-help)
	(source "")
	(pattern "Source")
	(dest @default-dest)
	(infos)	
	(confirm "average")
)

(complete 90)

(set #location
	(askstring
		(prompt "Please enter your sitename.")
		(help "This will appear in every datafile, just for documentation.")
		(default "-nowhere-")
	)
)

(tooltype
	(prompt "Setting the tooltype LOCATION to " #location)
	(help "This has no special meaning, just for documentation in the data files.")
	(dest (tackon @default-dest "Messie"))
	(settooltype "LOCATION" #location)
	(confirm "expert")
)

(complete 100)

(exit "Wish you fun with Messie.\n\n"
      "You find it in \"" @default-dest "\"\n\n"
      "Write me if you have problems with the sources or just remarks.\n"
      "Even bug reports are welcome. See the doc for my address."
      (quiet)
)

