RE: How to get start up path?

new topic     » topic index » view thread      » older message » newer message

really good, why not supply it in the library routines in Eu2.4.

Greg Haberek wrote:
> 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!
> 
> 



Euphoria is one of my favorite languages!

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu