(complete 0)

(set @default-dest "Work:rashumon")
(if (= (getassign "Rashumon") "")
  (makeassign "Rashumon" "Ram:")
)
(set @default-dest (getassign "Rashumon"))

(set version (/ (getversion) 65536))
(set version2 36)

(execute "dir")

     ; install on hard disk
(set dest2 
	(askdir
		(prompt "Select the location to install Rashumon and sample files")
		(default @default-dest)
		(newpath)
		(help "Choose a destination partition or directory " 
                      "to contain Rashumon. ")
	)
)     
(complete 10)
(set dest1 dest2)
(set @default-dest dest1)
(message "Rashumon will be installed in " 
               dest1
)
(makedir dest1
	(infos)
)

(run ("copy Rashumon_Installer:Rashumon %s dates" (tackon dest1 "Rashumon")))

(makedir "Sys:psfonts"
	(infos)
)
(complete 20)
(set dest2 (tackon dest1 "setup.pref"))
(delete dest2)

(if (> error 0) (message ("Error installing Rashumon #%ld." @ioerr)))


(complete 30)
(copyfiles
	(prompt "Copying files...")
	(help @copyfiles-help)
	(source "Rashumon_Installer:Rashumon_Drawer")
	(dest dest1)
	(all)
	(files)
)
(copyfiles
	(prompt "Copying Postscript fonts...")
	(help @copyfiles-help)
	(source "Rashumon_Installer:psfonts")
	(dest "sys:psfonts")
	(all)
	(files)
)
(complete 40)
(copyfiles
	(prompt "Installing fonts...")
	(help @copyfiles-help)
	(source "Rashumon_Installer:fonts")
	(dest "fonts:")
	(all)
	(fonts)
	(confirm "avarage")
)
(complete 50)
(set opt
(askchoice
	    (prompt "Select secondary language...")
	    (choices "Hebrew" "Arabic" "Farsi")
	    (default "Hebrew")
		(help @askchoice-help)
)
)
(complete 60)
(if (=  opt 0) 
(copyfiles
	(prompt "Installing Hebrew font")
	(help @copyfiles-help)
	(source "fonts:rashebrew")
	(dest "fonts:rashumon")
	(all)
	(files)
)
)
(complete 70)
(if (=  opt 1) 
(copyfiles
	(prompt "Installing Arabic font")
	(help @copyfiles-help)
	(source "fonts:rasharab")
	(dest "fonts:rashumon")
	(all)
	(files)
)
)
(complete 80)
(if (=  opt 2) 
(copyfiles
	(prompt "Installing Farsi font")
	(help @copyfiles-help)
	(source "fonts:rashfarsi")
	(dest "fonts:rashumon")
	(all)
	(files)
)
)
(message "Please run 'Intellifont' or 'Fountain' to install scalable fonts" 
)
(complete 90)
(if 
	(askbool 
		(prompt "Should I install the Scala Lingua sample files?\nYou need to have Scala software in order to run them") 
		(help @askbool-help)
	)
	(
	(set scala
		(askdir
			(prompt "Select the location to install Scala sample files")
			(help @askfile-help)
			(default "work:Scala")
		)
	)
	(if(exists (tackon scala "Scripts"))
	(copyfiles
		(prompt "Installing Scala sample script...")
		(help @copyfiles-help)
		(source "Rashumon_Installer:misc")
		(infos)
		(dest (tackon scala "Scripts"))
		(pattern "#?")
	)
	)
	(if(exists (tackon scala "Scripts"))
	(copyfiles
		(prompt "Installing Scala sample script...")
		(help @copyfiles-help)
		(infos)
		(source "Rashumon_Installer:pics")
		(dest (tackon scala "Backgrounds"))
		(pattern "#?")
	)
	)
	)
)
(set string1 ("assign Rashumon: %s" dest1))
      (makeassign "Rashumon" dest1)
      (set error 1)
      (until (= error 0)
        (
           (set error (trap 4
              (startup "Rashumon"
                 (prompt ("%s\n%s\n\n%s\n%s\n%s\n%s%s\n\n%s"
                          "The following assigns have been created."
                          "Do you want the them and the path statement added to your startup?"
                           string1
                          "path Rashumon: add"
                          "NOTE: The path will not be updated until you reboot."
                          )
                 )
                 (command 
                         ("assign Rashumon: %s\n" dest1)
                         ("assign psfonts: %s\n" "sys:psfonts")
                         "path Rashumon: add\n"
                 )
                 (help "Install_HD will add the necessary assigns to your user-startup "
                       "script, which is run when your machine boots.  If you decide not "
                       "to allow the installer to make these changes, you will need to "
                       "make them yourself."
                 )
              )
           ))
           (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 other type of error
                 (
                   (message "Non-Standard startup sequence detected. You must add "
                          "the following lines by hand.\n\n"
                          "assign Rashumon: " dest1 "\n"
                          "assign psfonts: Sys:psfonts\n"
                          "path Rashumon: add"
                   )
                   (set error 0)
                 )                
              )         
           )   
         )
      )
(complete 100)
