-- Make exwc.exe, a console version of exw.exe

function seek(integer fn, integer pos)
    return machine_func(19, {fn, pos})
end function

sequence cl
cl = command_line()

if length(cl) < 3 then
    abort(0)
end if

sequence eudir
eudir = cl[3]

system("copy \"" & eudir & "\\bin\\" & "exw.exe\" " &
	    "\"" & eudir & "\\bin\\" & "exwc.exe\" > nul", 2)

integer fn

fn = open(eudir & "\\bin\\" & "exwc.exe", "ub")
if fn = -1 then
    puts(1, "run this from euphoria\\bin\n")
    if getc(0) then
    end if
    abort(1)
end if

if seek(fn, #DC) != 0 then
    puts(2, "1st seek failed\n")
    if getc(0) then
    end if
end if

if seek(fn, #DC) != 0 then
    puts(2, "2nd seek failed\n")
    if getc(0) then
    end if
end if
 
puts(fn, 3) -- magic byte
close(fn)


