;
; Install For ARArchive ©1995 Robert Reiswig
; $Id: ARArchive  1.5 
;
(set osver (/ (getversion "LIBS:version.library") 65536))
( if (= osver 37) ( (set workbench "2.0")) ( if (= osver 38) ( (set workbench "2.1"))
( if (= osver 39) ( (set workbench "3.0")) ( if (= osver 40) ( (set workbench "3.1"))
( if (= osver 41) ( (set workbench "4.0")) )))))

( if (= osver 37) ( (set DefCpu 0)) ( if (= osver 38) ( (set DefCpu 1))
( if (= osver 39) ( (set DefCpu 2)) ( if (= osver 40) ( (set DefCpu 3))
( if (= osver 41) ( (set DefCpu 4)) )))))


(if (< osver 37)  (abort "Sorry You need 2.0 or higher to run ARArchiver!") )

(message "ARArchive V1.3.03\n\nBy: Robert Reiswig\nrcr@netcom.com\n\n"
         "This Installer will do a few things:\n\nCopy ARArchive to where you tell it."
         "\nAdd an AR: assign to your User-Startup.\n "
         "Create a few scripts for ARArchive-LHA (If selected)"
) 




(set How  (askchoice (choices "In LHA format (ie: ar301.lha)" "In Uncompressed format (ie: ar301.guide)")
                     (prompt "How do you store your Amiga Reports?")
	             (help   "How do you store your Amiga Reports?")
                     (default 0)
	  )
)


(if (= How 0) (set HowText "ARArchive-LHA") )
(if (= How 1) (set HowText "ARArchive") )




(set ARA_dest
        
           (askdir
                   (prompt (cat "Where do you wish to install:\n" HowText))
                   (help @askdir-help)
                   (default @default-dest)
                   
           )
                
        
)


(set @default-dest ARA_dest) 


(if (= How 0) (set HowCompress "LHA'ed") )
(if (= How 1) (set HowCompress "Uncompressed (AmigaGuide)") )

(set AR_dest
     
                (askdir
                        (prompt (cat "In which drawer are the\n*" HowCompress "* Amiga Reports\nstored?"))
                        (help @askdir-help)
                        (default @default-dest)
                )
                
)


(set DoThis (cat "ASSIGN AR: " AR_dest))
(run (DoThis))



(if (= How 0)
  (
     (message "\n\n\n\nNOTE\n~~~~~~~~~~~~~\nYou must be running AREXX and have LHA in the command path "
              "to use ARArchive!")
   
     (copyfiles (source "ARArchive-LHA.info") (dest ARA_dest) )
     (copyfiles (source "ARArchive-LHA.guide") (dest "AR:") ) 


     (set osverS (askchoice (choices "2.0" "2.1" "3.0" "3.1")
                     (prompt "Please Select the OS Version you are running. "
                             "This will be the Machine you will install ARArchive on. "
                             "This is needed to tell the ARexx script to use AmigaGuide or Multiview. "
                             "The Installer has found\n" workbench " version of the OS." )
	             (help   "Select OS Ver")
                     (default DefCpu)
	         )
     )
     

     (if (< osver 39) (set AGViewer "AmigaGuide") )
     (if (> osver 38) (set AGViewer "Multiview") )
 
     
     (textfile (dest (tackon ARA_dest "ARArchive-LHA"))
               (append (cat AGViewer " AR:ARArchive-LHA.guide"))
     )

     (textfile (dest (tackon "c:" "ARA"))
               (append "/* ARA-Unlha Robert Reiswig V1.0   rcr@netcom.com */\n")
               (append "ADDRESS COMMAND\n")
               (append "parse arg ARfilePath ARfile\n")
               (append " \n")    
               (append "/* Set UnLha command , AmigaGuide Viewer, where to Uncompress */\n")
               (append "Where = \"T:\"\n")
               (append "UnLhaCommand = \"lha -q x\"\n") 
               (append (cat "GuideViewer = \"" AGViewer "\"\n"))
               (append " \n")
               (append "/* Build Rexx Script */\n")
               (append "cmd1 =  '\"' || UnLhaCommand || \" \" || ARfilePath || \" \" || Where || '\"'\n")
               (append "ARFileZ = right(ARFile,(LENGTH(ARFile))-1)\n")
               (append "cmd2 =  GuideViewer || \" \" || '\"' || Where || ARFileZ || '\"'\n")
               (append "cmd3 = '\"' || 'delete >nil:' || \" \" || Where || \"AR#?\" || '\"'\n")
               (append " \n")
               (append "/* Execute - Unpack , display , delete */\n")
               (append "interpret cmd1\n")
               (append "interpret cmd2\n")
               (append "say \"Thanks for using ARArchive-LHA\"\n")
               (append "interpret cmd3\n")
               (append " \n")

     )

  )
)


(if (= How 1)
  (
     (copyfiles (source "ARArchive")
                (dest ARA_dest)
                (infos)
     )
  )
)



(startup "ARArchive"
          (prompt "Adding an ASSIGN to your S:User-startup.")
          (command (DoThis))
          (help
                  "\nIn order for ARArchive to find the Amiga Reports"
                  "an assign must be made for AR:"
          )
)






