1. How to get start up path?
When an application start up, how to get the path where it locates?
current_dir() return the name of the current working directory, if the
applicate was started by another application,( for example Medit)
current_dir() returns something not desired.
Euphoria is one of my favorite languages!
2. Re: How to get start up path?
On Tue, 25 Feb 2003 06:36:58 +0000, Liu Junfeng <rufi at 163.com> wrote:
>
> When an application start up, how to get the path where it locates?
>
> current_dir() return the name of the current working directory, if the
> applicate was started by another application,( for example Medit)
> current_dir() returns something not desired.
>
>
The way I do it, is I look at the second parameter returned by
command_line(). If that does not start with a drive letter, I prepend the
current_dir() to it. This means that if I run ...
ex demo\prog.ex
I get "demo\prog.ex" from command_line(), and as there is no drive letter,
I just add the current dir to it.
This is not perfect as the current_dir() function only returns the current
directory of the current drive. This means that if my current drive is "D:"
and its current directory is "\DEMOS\" and I run this ...
ex c:prog.ex
I cannot find out what the current directory for the C: drive is from
within the program I'm running. Well I can, but I have to resort to DOS
interrupt calls.
--
cheers,
Derek Parnell
3. Re: How to get start up path?
here is what I use:
-- begin code --
include misc.e
include file.e
function command_dir(integer x)
sequence cmd
integer s
atom slash
cmd = command_line() -- get the command line
cmd = reverse(cmd[x]) -- reverse it, so the file name is first
if platform() = LINUX then -- works on any platform!
slash = '/'
else
slash = '\\'
end if
s = find(slash, cmd) -- find the slash
if s > 0 then
cmd = cmd[s..length(cmd)]
else
cmd = reverse( current_dir() )
if cmd[1] != slash then
cmd = slash & cmd
end if
end if
return reverse(cmd) -- return the path
end function
-- when translated/compiled, startup_dir() and bin_dir() will be the same
global function startup_dir()
-- directory of the file run by ex(u)(w)
return command_dir(2)
end function
global function bin_dir()
-- directory of the interpreter
return command_dir(1)
end function
puts(1, startup_dir() & '\n')
puts(1, bin_dir() & '\n')
-- end code --
~Greg
g,haberek at comcast.net
----- Original Message -----
From: Liu Junfeng <rufi at 163.com>
To: EUforum <EUforum at topica.com>
Sent: Tuesday, February 25, 2003 1:36 AM
Subject: How to get start up path?
When an application start up, how to get the path where it locates?
current_dir() return the name of the current working directory, if the
applicate was started by another application,( for example Medit)
current_dir() returns something not desired.
Euphoria is one of my favorite languages!
TOPICA - Start your own email discussion group. FREE!