home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
progmisc
/
euphor10.zip
/
INSTALL.EX
< prev
next >
Wrap
Text File
|
1993-07-06
|
6KB
|
199 lines
-------------------------------------
-- Program to Install Euphoria --
-- must be run from bin directory --
-------------------------------------
function copy_to_hard_disk(integer hard_drive)
-- copy EUPHORIA directory and subdirectories from floppy
-- to hard disk
sequence command, answer
if open(hard_drive & ":\\euphoria\\bin\\ex.exe", "r") != -1 then
puts(1, "EUPHORIA is already on your hard disk\n")
puts(1, "Remove it before installing a new version\n")
return 0
end if
command = "xcopy ..\\.. " & hard_drive & ":\\ /s"
puts(1, "\nTo copy EUPHORIA from the floppy to drive " & hard_drive)
puts(1, ", the following command will be used:\n")
puts(1, '\t' & command & '\n')
puts(1, "Hit Enter to proceed with this command\n")
puts(1, "Type n to skip this command\n")
puts(1, "Type control-c to abort\n")
answer = gets(0)
if answer[1] != 'n' then
system(command, 0)
end if
return 1
end function
function upper(sequence s)
for i = 1 to length(s) do
if s[i] >= 'a' and s[i] <= 'z' then
s[i] = s[i] - 'a' + 'A'
end if
end for
return s
end function
function edit_auto_exec(integer hard_drive)
-- edit the autoexec.bat file
-- add to the PATH, set EUDIR
integer auto_exec_no, p, white, semi_pos, changed
sequence auto_exec, auto_name, base_name, answer, set_line
object line
puts(1, "\nEditing autoexec.bat file...\n")
base_name = ":\\autoexec.bat"
auto_name = "C" & base_name -- try C first
auto_exec_no = open(auto_name, "r")
while auto_exec_no = -1 do
puts(1, "Couldn't open " & auto_name & '\n')
puts(1, "On what drive is your autoexec.bat file?\n")
puts(1, "Type a letter: (control-c to abort)\n")
answer = gets(0)
auto_name = answer[1] & base_name
auto_exec_no = open(auto_name, "r")
end while
-- read in the entire autoexec.bat
auto_exec = {}
changed = 0
while 1 do
line = gets(auto_exec_no)
if atom(line) then
exit
end if
p = match("PATH", upper(line))
if p then
-- line contains the word "PATH" somewhere in upper or lower case
white = 1
for i = 1 to p-1 do
if not find(line[i], " \t") then
white = 0
end if
end for
if white and find(line[p+4], " \t") then
-- this is the PATH line
set_line ="SET EUDIR=" & hard_drive & ":\\EUPHORIA\n"
auto_exec = append(auto_exec, set_line)
if match("EUPHORIA\\BIN", line) then
-- its already there
puts(1, "PATH already contains EUPHORIA\\BIN\n")
close(auto_exec_no)
return 1
end if
if length(line) > 110 then
-- line is too long (MS-DOS restriction)
puts(1, "Your PATH line is too long to add EUPHORIA\\BIN\n")
puts(1, "Perhaps you can delete a directory from it\n")
close(auto_exec_no)
return 0
end if
semi_pos = find(';', line)
if semi_pos = 0 then
semi_pos = length(line)
line = line[1..length(line)-1] & ";\n"
end if
-- add EUPHORIA\BIN to path
puts(1, "Changing this line:\n")
puts(1, line)
changed = 1
line = line[1..semi_pos] &
hard_drive & ":\\EUPHORIA\\BIN;" &
line[semi_pos+1..length(line)]
puts(1, "to:\n")
puts(1, line)
puts(1, "and inserting the following line:\n")
puts(1, set_line)
end if
end if
auto_exec = append(auto_exec, line)
end while
close(auto_exec_no)
if not changed then
puts(1, "The PATH command could not be found.\n")
puts(1, "No changes were made to your autoexec.bat.\n")
puts(1, "See the manual installation procedure in install.doc.\n")
return 0
else
-- write out the new autoexec.bat
auto_exec_no = open(auto_name, "w")
if auto_exec_no = -1 then
puts(1, "Couldn't write out the new autoexec.bat!\n")
puts(1, "See the manual installation procedure in install.doc.\n")
return 0
end if
for i = 1 to length(auto_exec) do
puts(auto_exec_no, auto_exec[i])
end for
close(auto_exec_no)
end if
return 1 -- success
end function
procedure install()
integer drive
sequence answer, cl
puts(1, "\nEuphoria Installation Program\n")
puts(1, "(control-c to abort)\n\n")
cl = command_line()
drive = cl[1][1]
if drive >= 'C' then
-- we're on a hard disk
if compare(cl[1][2..length(cl[1])], ":\\EUPHORIA\\BIN\\EX.EXE") = 0 then
-- we're in the normal place,
-- just edit autoexec
if edit_auto_exec(drive) then
puts(1, "\nAll Done.\n")
puts(1, "Type Control-Alt-Delete to reboot your machine.\n")
puts(1, "This will set your PATH and EUDIR variables.\n")
end if
else
puts(1, "You are currently running the Euphoria interpreter,\n")
puts(1, "ex.exe, as " & cl[1] & '\n')
puts(1, "Normally it should be C:\\EUPHORIA\\BIN\\EX.EXE or\n")
puts(1, "D:\\EUPHORIA\\BIN\\EX.EXE etc. You can install here if you\n")
puts(1, "really want to, but please refer to install.doc\n")
puts(1, "and follow the manual installation instructions.\n")
puts(1, "If your PATH and EUDIR variables are set correctly\n")
puts(1, "it will be ok.\n")
end if
return
end if
-- we're on a floppy disk
puts(1, "On which drive do you want to put the EUPHORIA directory?\n")
puts(1, "Type the drive letter, or just hit Enter for drive C\n")
answer = gets(0)
drive = answer[1]
if drive = '\n' then
drive = 'C'
end if
if find(drive, "AaBb") then
puts(1, "you specified drive " & drive & "\n")
puts(1, "Is this a floppy drive? (y or n)\n")
answer = gets(0)
if answer[1] != 'n' then
puts(1, "Can't copy to a floppy drive\n")
return
end if
end if
if (drive >= 'A' and drive <= 'Z' ) or
(drive >= 'a' and drive <= 'z') then
if not copy_to_hard_disk(drive) then
return
end if
if edit_auto_exec(drive) then
puts(1, "\nAll Done.\n")
puts(1, "Remove the EUPHORIA disk then press\n")
puts(1, "Type Control-Alt-Delete to reboot your machine.\n")
puts(1, "This will set your PATH and EUDIR variables.\n")
end if
else
puts(1, "drive " & drive & "???\n")
end if
end procedure
install()