home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / euphor10.zip / INSTALL.EX < prev    next >
Text File  |  1993-07-06  |  6KB  |  199 lines

  1.     -------------------------------------
  2.     -- Program to Install Euphoria     --
  3.     -- must be run from bin directory  --
  4.     -------------------------------------
  5.  
  6. function copy_to_hard_disk(integer hard_drive)
  7. -- copy EUPHORIA directory and subdirectories from floppy
  8. -- to hard disk
  9.     sequence command, answer
  10.  
  11.     if open(hard_drive & ":\\euphoria\\bin\\ex.exe", "r") != -1 then
  12.     puts(1, "EUPHORIA is already on your hard disk\n")
  13.     puts(1, "Remove it before installing a new version\n")
  14.     return 0
  15.     end if
  16.     command = "xcopy ..\\.. " & hard_drive & ":\\ /s"
  17.     puts(1, "\nTo copy EUPHORIA from the floppy to drive " & hard_drive)
  18.     puts(1, ", the following command will be used:\n")
  19.     puts(1, '\t' & command & '\n')
  20.     puts(1, "Hit Enter to proceed with this command\n")
  21.     puts(1, "Type n to skip this command\n")
  22.     puts(1, "Type control-c to abort\n")
  23.     answer = gets(0)
  24.     if answer[1] != 'n' then
  25.     system(command, 0)
  26.     end if
  27.     return 1
  28. end function
  29.  
  30. function upper(sequence s)
  31.     for i = 1 to length(s) do
  32.     if s[i] >= 'a' and s[i] <= 'z' then
  33.         s[i] = s[i] - 'a' + 'A'
  34.     end if
  35.     end for
  36.     return s
  37. end function
  38.  
  39. function edit_auto_exec(integer hard_drive)
  40. -- edit the autoexec.bat file
  41. -- add to the PATH, set EUDIR
  42.     integer auto_exec_no, p, white, semi_pos, changed
  43.     sequence auto_exec, auto_name, base_name, answer, set_line
  44.     object line
  45.  
  46.     puts(1, "\nEditing autoexec.bat file...\n")
  47.     base_name = ":\\autoexec.bat"
  48.     auto_name = "C" & base_name  -- try C first
  49.     auto_exec_no = open(auto_name, "r")
  50.     while auto_exec_no = -1 do
  51.     puts(1, "Couldn't open " & auto_name & '\n')
  52.     puts(1, "On what drive is your autoexec.bat file?\n")
  53.     puts(1, "Type a letter: (control-c to abort)\n")
  54.     answer = gets(0)
  55.     auto_name = answer[1] & base_name
  56.     auto_exec_no = open(auto_name, "r")
  57.     end while
  58.     -- read in the entire autoexec.bat
  59.     auto_exec = {}
  60.     changed = 0
  61.     while 1 do
  62.     line = gets(auto_exec_no)
  63.     if atom(line) then
  64.         exit
  65.     end if
  66.     p = match("PATH", upper(line))
  67.     if p then
  68.         -- line contains the word "PATH" somewhere in upper or lower case
  69.         white = 1
  70.         for i = 1 to p-1 do
  71.         if not find(line[i], " \t") then
  72.             white = 0
  73.         end if
  74.         end for
  75.         if white and find(line[p+4], " \t") then
  76.         -- this is the PATH line
  77.         set_line ="SET EUDIR=" & hard_drive & ":\\EUPHORIA\n"
  78.         auto_exec = append(auto_exec, set_line)
  79.         if match("EUPHORIA\\BIN", line) then
  80.             -- its already there
  81.             puts(1, "PATH already contains EUPHORIA\\BIN\n")
  82.             close(auto_exec_no)
  83.             return 1
  84.         end if
  85.         if length(line) > 110 then
  86.             -- line is too long (MS-DOS restriction)
  87.             puts(1, "Your PATH line is too long to add EUPHORIA\\BIN\n")
  88.             puts(1, "Perhaps you can delete a directory from it\n")
  89.             close(auto_exec_no)
  90.             return 0
  91.         end if
  92.         semi_pos = find(';', line)
  93.         if semi_pos = 0 then
  94.             semi_pos = length(line)
  95.             line = line[1..length(line)-1] & ";\n"
  96.         end if
  97.         -- add EUPHORIA\BIN to path
  98.         puts(1, "Changing this line:\n")
  99.         puts(1, line)
  100.         changed = 1
  101.         line = line[1..semi_pos] &
  102.                hard_drive & ":\\EUPHORIA\\BIN;" &
  103.                line[semi_pos+1..length(line)]
  104.         puts(1, "to:\n")
  105.         puts(1, line)
  106.         puts(1, "and inserting the following line:\n")
  107.         puts(1, set_line)
  108.         end if
  109.     end if
  110.     auto_exec = append(auto_exec, line)
  111.     end while
  112.     close(auto_exec_no)
  113.     if not changed then
  114.     puts(1, "The PATH command could not be found.\n")
  115.     puts(1, "No changes were made to your autoexec.bat.\n")
  116.     puts(1, "See the manual installation procedure in install.doc.\n")
  117.     return 0
  118.     else
  119.     -- write out the new autoexec.bat
  120.     auto_exec_no = open(auto_name, "w")
  121.     if auto_exec_no = -1 then
  122.         puts(1, "Couldn't write out the new autoexec.bat!\n")
  123.         puts(1, "See the manual installation procedure in install.doc.\n")
  124.         return 0
  125.     end if
  126.     for i = 1  to length(auto_exec) do
  127.         puts(auto_exec_no, auto_exec[i])
  128.     end for
  129.     close(auto_exec_no)
  130.     end if
  131.     return 1 -- success
  132. end function
  133.  
  134. procedure install()
  135.     integer drive
  136.     sequence answer, cl
  137.  
  138.     puts(1, "\nEuphoria Installation Program\n")
  139.     puts(1, "(control-c to abort)\n\n")
  140.     cl = command_line()
  141.     drive = cl[1][1]
  142.     if drive >= 'C' then
  143.     -- we're on a hard disk
  144.     if compare(cl[1][2..length(cl[1])], ":\\EUPHORIA\\BIN\\EX.EXE") = 0 then
  145.         -- we're in the normal place, 
  146.         -- just edit autoexec
  147.         if edit_auto_exec(drive) then
  148.         puts(1, "\nAll Done.\n")
  149.         puts(1, "Type Control-Alt-Delete to reboot your machine.\n")
  150.         puts(1, "This will set your PATH and EUDIR variables.\n")
  151.         end if
  152.     else
  153.          puts(1, "You are currently running the Euphoria interpreter,\n") 
  154.          puts(1, "ex.exe, as " & cl[1] & '\n')
  155.          puts(1, "Normally it should be C:\\EUPHORIA\\BIN\\EX.EXE or\n")
  156.          puts(1, "D:\\EUPHORIA\\BIN\\EX.EXE etc. You can install here if you\n")
  157.          puts(1, "really want to, but please refer to install.doc\n")
  158.          puts(1, "and follow the manual installation instructions.\n") 
  159.          puts(1, "If your PATH and EUDIR variables are set correctly\n")
  160.          puts(1, "it will be ok.\n")
  161.     end if  
  162.     return
  163.     end if
  164.     -- we're on a floppy disk
  165.     puts(1, "On which drive do you want to put the EUPHORIA directory?\n")
  166.     puts(1, "Type the drive letter, or just hit Enter for drive C\n")
  167.     answer = gets(0)
  168.     drive = answer[1]
  169.     if drive = '\n' then
  170.     drive = 'C'
  171.     end if
  172.     if find(drive, "AaBb") then
  173.     puts(1, "you specified drive " & drive & "\n")
  174.     puts(1, "Is this a floppy drive? (y or n)\n")
  175.     answer = gets(0)
  176.     if answer[1] != 'n' then
  177.         puts(1, "Can't copy to a floppy drive\n")
  178.         return
  179.     end if
  180.     end if
  181.     if (drive >= 'A' and drive <= 'Z' ) or
  182.        (drive >= 'a' and drive <= 'z') then
  183.     if not copy_to_hard_disk(drive) then
  184.         return
  185.     end if
  186.     if edit_auto_exec(drive) then
  187.         puts(1, "\nAll Done.\n")
  188.         puts(1, "Remove the EUPHORIA disk then press\n")
  189.         puts(1, "Type Control-Alt-Delete to reboot your machine.\n")
  190.         puts(1, "This will set your PATH and EUDIR variables.\n")
  191.     end if
  192.     else
  193.     puts(1, "drive " & drive & "???\n")
  194.     end if
  195. end procedure
  196.  
  197. install()
  198.  
  199.