; $VER: Newlist 8 (19-Jun-93) Installer Script for Newlist
;
; As you should know...Installer requires a stack of at least 10000.
; If it is less, it may crash (which it has done for me a few times.)

(set @user-level 1)

(if (exists "c:nl")                     ;Remove old newlist from resident list
    (run "resident c:nl remove" )
)

(if (exists "ENV:NEWLIST_LANG")         ;Remove old language file from memory
    (run "newlist8 -K >nil:")
)

(message "Installation of \"Newlist8\"\n\nThis install script will not only install\n Newlist8 but also languages,\nENV: variables, scripts, and other goodies.\n"
(confirm)
)

(set name
   (askchoice
      (prompt "Which Newlist8 version should I install?")
      (help "Newlist8 - requires Motorola 68000 CPU (default).\nNewlist8.030 - requires Motorola 68030 or 68040!\n")
      (choices "Newlist8" "Newlist8.030")
      (default 0)
   )
)

(if (= name 0)
   (set name "Newlist8")
   (set name "NewList8.030")
)

(copyfiles
   (prompt "Copying " name " to your disk as 'nl'...")
   (help @copyfiles-help)
   (source name )
   (dest "c:")
   (newname "nl")
   (infos)
   (confirm)
   (optional)
)

(complete 20)

(message "\nYou must now install a language file.")

(if (exists "ENV:NEWLIST_LANG")
   (message "\n\nENV:NEWLIST_LANG found!!\n\nIt is HIGHLY adviseable that you replace old languages for old newlist's with the new version.  If you do not then Newlist8 will not run properly.")
)

(set name
   (askfile
      (prompt "Please select a language file.")
      (help "\nNewlist8 requires a language file!")
      (default "languages/NEWLIST_LANG.english")
   )
)
   

(if 
   (copyfiles
      (prompt "Copying " name " to destination as 'NEWLIST_LANG'...")
      (help "\nNewlist8 requires the language to be saved in\n either ENV:, ENVARC:, or locale:  The file will also be renamed to NEWLIST_LANG.")
      (source name)
      (newname "NEWLIST_LANG")
      (dest "ENV:")
      (confirm)
      (optional)
   )
   (run "copy env:NEWLIST_LANG ENVARC:")
   (message "\n Language installation skipped!\n\nNewlist REQUIRES a language file if you\nalready didn't know.")
)

(complete 40)

(if 
   (copyfiles
      (prompt "Copying Newlist variables to ENV: and ENVARC:")
      (help "\n These 4 variables allow a user to store his personal preferences.")
      (source "env")
      (dest "ENV:")
      (pattern "~(#?.info)")
      (confirm)
      (optional)
   )
   (run "copy env/~(#?.info) ENVARC:")
)

(complete 60)

(message "\n\nMiscellaneous things to add....\n\n'Aliases' - a bunch of useful aliases that use newlist's features\n'NewSpat' 'NewDpat' - a replacement for Commodore's s:spat and s:dpat that use nl")

(set name
   (askoptions
      (prompt "\n\nShall I install any of the following Extras (that take advantage of Newlist's power)??")
      (help "'Aliases' - a bunch of useful aliases that use newlist's features (copied to s:shell-startup)\n\n'NewSpat' 'NewDpat' - a replacement for Commodore's s:spat and s:dpat that uses nl\n")
      (choices "Aliases - Appended to S:Shell-startup" "NewSpat - Placed in S:" "NewDpat - Placed in S:")
      (default 7)
   )
)


(if (bitand 1 name)
   (
   (run "copy scripts/aliases s:Newlist_Aliases")
   (run "echo \"execute s:Newlist_Aliases\" >> s:shell-startup")
   )
)
(if (bitand 2 name)
   (run "copy scripts/newspat#? s:")
)
(if (bitand 4 name)
   (run "copy scripts/newdpat#? s:")
)

(complete 80)

(set name
   (askbool
      (prompt "\n\nShall I append 'RESIDENT c:nl ADD' to your S:User-StartUp?")
      (help  "Making newlist RESIDENT drastically speeds up loading and execution time at the expense of a few extra K of memory.")
      (choices "Yes" "No")
      (default 1)
   )
)

(if (= name 1)
   (startup "Newlist8"
      (prompt "\nAdding 'RESIDENT c:nl ADD' to s:User-StartUp")
      (help "None available.")
      (command "RESIDENT c:nl ADD")
   )
)

(complete 100)

(message "\n\nInstallation Complete!!\n\nTry out the following commands: \nnl -?\nnl -q\nnl -qs\nnl -qt\nnl -T3\nnl -z\nnl -UV\nfor further information please consult the doc 'Newlist.doc'." )
(exit)
