home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / tools / aurora21 / install.aml < prev    next >
Text File  |  1995-08-10  |  9KB  |  384 lines

  1.  
  2. // -------------------------------------------------------------------
  3. // The Aurora Editor v2.1
  4. // Copyright 1993-1995 nuText Systems. All Rights Reserved Worldwide.
  5. //
  6. // Installation macro
  7. //
  8. // This macro installs all Aurora files to a user-specified path, and
  9. // also prompts the user for an editor style and color palette to use.
  10. // -------------------------------------------------------------------
  11.  
  12.   // compile time macros and function definitions
  13.   include  bootpath "define.aml"
  14.  
  15.   var compdisplay
  16.   var lastfile
  17.  
  18.   // message strings
  19.   title     = "Installation"
  20.   cancelmsg = "Installation canceled"
  21.   failmsg   = "Installation failed"
  22.   source_path = getpath (getbootpath)
  23.  
  24.   // create installation progress window
  25.   createwindow
  26.   setwinobj
  27.   setframe ">b"
  28.   setcolor  border_color   color white on gray
  29.   setcolor  text_color     color black on gray
  30.   settitle "Aurora v" + getversion + ' ' + title
  31.   setwinctrl '≡'
  32.   sizewindow 1 1  -1 -1 "rd"
  33.   setborder "1i"
  34.   display
  35.  
  36.   // get the install path
  37.   install_path = upcase (ask "Enter installation path:" ''
  38.                          source_path title 'd')
  39.   if not install_path then
  40.     msgbox cancelmsg title
  41.     destroywindow
  42.     return
  43.   end
  44.  
  45.   // add backslash if not present
  46.   if install_path [0] <> "\\" then
  47.     install_path = install_path + "\\"
  48.   end
  49.  
  50.   writestr "Installation path is " + install_path
  51.  
  52.   // check if the install path exists
  53.   if locatefile install_path '' 'd' then
  54.     if (okbox  "Path " + install_path +
  55.                " already exists, install over it?" title) <> "Ok" then
  56.       msgbox cancelmsg title
  57.       destroywindow
  58.       return
  59.     end
  60.  
  61.   // ..if not, then create it
  62.   else
  63.     if (okbox  "Path " + install_path +
  64.                 " is not found, create it?" title) <> "Ok" then
  65.       msgbox cancelmsg title
  66.       destroywindow
  67.       return
  68.     else
  69.       if not createdir install_path then
  70.         msgbox "Can't create path " + install_path + " - " + failmsg  title
  71.         destroywindow
  72.         return
  73.       end
  74.     end
  75.     install_path = getpath (qualify install_path)
  76.   end
  77.  
  78.  
  79.   // create the style menu
  80.   menu "mstyle"
  81.     item " &Aurora"                 "AU"
  82.     item " Aurora/&CUA/Windows"     "CU"
  83.     item " &Brief"                  "BR"
  84.     item " &MultiEdit"              "ME"
  85.     item " &QEdit/TSE"              "QE"
  86.     item " Word&Perfect"            "WP"
  87.     item " &WordStar/Borland IDE"   "WS"
  88.   end
  89.  
  90.   // get the editor style
  91.   style = popup "mstyle" "Which editor style would you like to use?"
  92.   destroybuf "mstyle"
  93.   if not style then
  94.     msgbox cancelmsg title
  95.     destroywindow
  96.     return
  97.   end
  98.  
  99.   writeline
  100.   writestr "Editor style is: " + style
  101.   display
  102.  
  103.   // create the color palette menu
  104.   menu "colors"
  105.     item " &Blue and green"   "blugreen"
  106.     item " &Fluorescent"      "fluoresc"
  107.     item " &Green charcoal"   "greench"
  108.     item " &Red and blue"     "redblue"
  109.     item " &Wimbledon"        "wimbledn"
  110.   end
  111.  
  112.   // get the color palette to use
  113.   palette = popup "colors" "Select a color palette to install" 37
  114.   destroybuf "colors"
  115.   if not palette then
  116.     msgbox cancelmsg title
  117.     destroywindow
  118.     return
  119.   end
  120.  
  121.   writeline
  122.   writestr "Editor color palette is: " + palette
  123.   display
  124.  
  125.   // define all installation directories and files
  126.   databuf "allfiles"
  127.  
  128.     // main files
  129.     "\\"
  130.     "a.exe"
  131.     "a.x"
  132.     "lib.x"
  133.     "install.x"
  134.     "install.aml"
  135.     "color.aml"
  136.     "config.aml"
  137.     "define.aml"
  138.     "ext.aml"
  139.     "file_id.diz"
  140.     "license.doc"
  141.     "main.aml"
  142.     "mouse.aml"
  143.     "orderfrm.doc"
  144.     "read.me"
  145.     "syntax.aml"
  146.     "syntax2.aml"
  147.     "system.aml"
  148.     "tran.aml"
  149.     "vendor.doc"
  150.     "whatsnew.doc"
  151.  
  152.     // cfg files
  153.     "cfg\\"
  154.     "cfgcolor.x"
  155.     "cfgconf.aml"
  156.     "cfgdesk.aml"
  157.     "cfgedit1.aml"
  158.     "cfgedit2.aml"
  159.     "cfgfind.aml"
  160.     "cfgfmgr.aml"
  161.     "cfgform.aml"
  162.     "cfgldlm.aml"
  163.     "cfgmain.aml"
  164.     "cfgmarg.aml"
  165.     "cfgmisc.aml"
  166.     "cfgmouse.aml"
  167.     "cfgopen.aml"
  168.     "cfgprint.aml"
  169.     "cfgprom.aml"
  170.     "cfgsave.aml"
  171.     "cfgsort.aml"
  172.     "cfgstyl2.x"
  173.     "cfgstyle.x"
  174.     "cfgupd.aml"
  175.     "cfgvideo.aml"
  176.  
  177.     // doc files
  178.     "doc\\"
  179.     "function.dox"
  180.     "language.dox"
  181.     "quickfun.dox"
  182.     "regexp.dox"
  183.     "tips.dox"
  184.     "user.dox"
  185.  
  186.     // macro files
  187.     "macro\\"
  188.     "ascii2.aml"
  189.     "booklist.aml"
  190.     "calcpad.aml"
  191.     "calen4.aml"
  192.     "calendar.aml"
  193.     "clrchart.aml"
  194.     "compare.aml"
  195.     "compress.aml"
  196.     "countchr.aml"
  197.     "countlin.aml"
  198.     "countwrd.aml"
  199.     "delblank.aml"
  200.     "deldup.aml"
  201.     "dlgdemo.aml"
  202.     "drawbox.aml"
  203.     "example.aml"
  204.     "fulldate.aml"
  205.     "helplang.aml"
  206.     "helpuser.aml"
  207.     "keycodes.aml"
  208.     "keydef.aml"
  209.     "longline.aml"
  210.     "maclist.aml"
  211.     "palette.aml"
  212.     "scan2.aml"
  213.     "scrsaver.aml"
  214.     "style.aml"
  215.     "sumblock.aml"
  216.     "tabs.aml"
  217.     "template.aml"
  218.     "template.dat"
  219.     "where.aml"
  220.  
  221.     // palette files
  222.     "palette\\"
  223.     "blugreen.aml"
  224.     "fluoresc.aml"
  225.     "greench.aml"
  226.     "redblue.aml"
  227.     "wimbledn.aml"
  228.  
  229.     // style files
  230.     "style\\"
  231.     "aukbd.aml"
  232.     "aumenu.aml"
  233.     "brkbd.aml"
  234.     "brmenu.aml"
  235.     "cukbd.aml"
  236.     "cumenu.aml"
  237.     "mekbd.aml"
  238.     "memenu.aml"
  239.     "qekbd.aml"
  240.     "qemenu.aml"
  241.     "wpkbd.aml"
  242.     "wpmenu.aml"
  243.     "wskbd.aml"
  244.     "wsmenu.aml"
  245.   end
  246.  
  247.   // display compiling message only for a.x compilation
  248.   function oncompiling (filename line)
  249.     if compdisplay and filename <> lastfile then
  250.       writeline
  251.       writestr "Compiling " + filename + "..."
  252.       display
  253.       lastfile = filename
  254.     end
  255.   end
  256.  
  257.   // check for same-path installation
  258.   same_path = source_path == install_path
  259.  
  260.   // copy files
  261.   repeat
  262.     file = gettext
  263.     if file [0] == '\\' then
  264.       if file == '\\' then
  265.         path = if? same_path '' install_path
  266.       else
  267.         path = file
  268.         createdir install_path + path
  269.       end
  270.     elseif path then
  271.       source = qualify file source_path
  272.       if path == install_path then
  273.         dest = qualify file install_path
  274.       else
  275.         if not locatefile source then
  276.           source = qualify file source_path + path
  277.         end
  278.         dest = qualify file install_path + path
  279.       end
  280.  
  281.       writeline
  282.       writestr "Copying " + source + " to " + dest + "..."
  283.       display
  284.  
  285.       if source <> dest then
  286.         if copyfile source dest then
  287.           if same_path then
  288.             deletefile source
  289.           end
  290.         else
  291.           // error copying files
  292.           msgbox "Failed copying " + dest + ", " + failmsg  title
  293.           destroybuf "allfiles"
  294.           destroywindow
  295.           return
  296.         end
  297.       end
  298.  
  299.       // compile external macro source
  300.       if path == "cfg\\" or path == "macro\\" then
  301.         // compile each macro (skip examples and executables)
  302.         if file <> "example.aml" and (getext file) == ".aml" then
  303.           writeline
  304.           writestr "Compiling " + dest + "..."
  305.           display
  306.           error = compilemacro dest dest [1 : (sizeof dest) - 3] + 'X'
  307.           if error then
  308.             msgbox "Error (" + error + ") compiling macro " + dest
  309.           end
  310.         end
  311.       end
  312.     end
  313.   until not down
  314.  
  315.   // destroy the file-list buffer
  316.   destroybuf "allfiles"
  317.  
  318.   // routine to copy style/palette files to the main install path
  319.   function  copys (src_path sfile dfile)
  320.     source = qualify sfile + ".AML" src_path
  321.     dest = qualify dfile + ".AML" install_path
  322.     writeline
  323.     writestr "Copying " + source + " to " + dest
  324.     display
  325.     // make a backup copy
  326.     copyfile dest (qualify dfile + ".OLD" install_path)
  327.     if not copyfile source dest then
  328.       // error copying files
  329.       msgbox "Failed copying " + dest + ", " + failmsg  title
  330.       destroywindow
  331.       return 1
  332.     end
  333.     return
  334.   end
  335.  
  336.   style_path = install_path + "STYLE\\"
  337.  
  338.   // copy keyboard style file
  339.   if copys style_path style + "KBD" "KBD" then
  340.     return
  341.   end
  342.  
  343.   // copy menu style file
  344.   if copys style_path style + "MENU" "MENU" then
  345.     return
  346.   end
  347.  
  348.   // copy color palette file
  349.   if copys install_path + "PALETTE\\"  palette "COLOR" then
  350.     return
  351.   end
  352.  
  353.   writeline
  354.   writestr "Recompiling the Editor..."
  355.   display
  356.  
  357.   compdisplay = TRUE
  358.  
  359.   // recompile the editor
  360.   save_boot = getbootpath
  361.   setbootpath install_path
  362.   error = regen
  363.   setbootpath save_boot
  364.  
  365.   if error then
  366.     msgbox "Compilation failed, " + failmsg  title
  367.     destroywindow
  368.     return
  369.   else
  370.     writeline
  371.     writestr "*** End of Installation *** "
  372.     display
  373.     msgbox "Installation is complete!  Add " + install_path + " to your PATH."  title
  374.     msgbox "To run Aurora, execute " +
  375.            (qualify "A.EXE" install_path) + " from the DOS command line."
  376.   end
  377.  
  378.   // destroy the installation progress window
  379.   destroywindow
  380.  
  381.   // return the install path if successful
  382.   return install_path
  383.  
  384.