1. current_dir()

isn't giving me the current dir at all. In win XP I'm getting "C:\Documents and
Settings.." and in Linux (when running the program from
"/home/jules/euphoria/code") it returns only "/home/jules"
Has anyone else had this problem?

new topic     » topic index » view message » categorize

2. Re: current_dir()

Jules wrote:

> isn't giving me the current dir at all. In win XP I'm getting "C:\Documents
> and Settings.." and in Linux (when running the program from
> "/home/jules/euphoria/code")
> it returns only "/home/jules" 
> Has anyone else had this problem?

On my system (Windows XP, EXW.EXE 3.0.2) current_dir() works as expected
(regardless whether or not the directory names contain spaces).

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

3. Re: current_dir()

Juergen Luethje wrote:
> 
> Jules wrote:
> 
> > isn't giving me the current dir at all. In win XP I'm getting "C:\Documents
> > and Settings.." and in Linux (when running the program from
> > "/home/jules/euphoria/code")
> > it returns only "/home/jules" 
> > Has anyone else had this problem?
> 
> On my system (Windows XP, EXW.EXE 3.0.2) current_dir() works as expected
> (regardless whether or not the directory names contain spaces).
> 
> Regards,
>    Juergen

I'm using 3.1 in XP (exw.exe) and 3.02 in Ubuntu Feisty.

new topic     » goto parent     » topic index » view message » categorize

4. Re: current_dir()

Jules wrote:
> 
> Juergen Luethje wrote:
> > 
> > Jules wrote:
> > 
> > > isn't giving me the current dir at all. In win XP I'm getting
> > > "C:\Documents
> > > and Settings.." and in Linux (when running the program from
> > > "/home/jules/euphoria/code")
> > > it returns only "/home/jules" 
> > > Has anyone else had this problem?
> > 
> > On my system (Windows XP, EXW.EXE 3.0.2) current_dir() works as expected
> > (regardless whether or not the directory names contain spaces).
> > 
> > Regards,
> >    Juergen
> 
> I'm using 3.1 in XP (exw.exe) and 3.02 in Ubuntu Feisty.

Hello Jules,

Check the windows compatibility setting in exw.exe by clicking
  properties\compatibility tab in exw.exe.
  I'm using XP and exw.exe 2.5 with no problems with current_dir().
  
Giants ,Trade Barry and win some games.

Don Cole

new topic     » goto parent     » topic index » view message » categorize

5. Re: current_dir()

don cole wrote:
> 
> Jules wrote:
> > 
> > Juergen Luethje wrote:
> > > 
> > > Jules wrote:
> > > 
> > > > isn't giving me the current dir at all. In win XP I'm getting
> > > > "C:\Documents
> > > > and Settings.." and in Linux (when running the program from
> > > > "/home/jules/euphoria/code")
> > > > it returns only "/home/jules" 
> > > > Has anyone else had this problem?
> > > 
> > > On my system (Windows XP, EXW.EXE 3.0.2) current_dir() works as expected
> > > (regardless whether or not the directory names contain spaces).
> > > 
> > > Regards,
> > >    Juergen
> > 
> > I'm using 3.1 in XP (exw.exe) and 3.02 in Ubuntu Feisty.
> 
> Hello Jules,
> 
>   Check the windows compatibility setting in exw.exe by clicking
>   properties\compatibility
> tab in exw.exe.  
>   I'm using XP and exw.exe 2.5 with no problems with current_dir().
>   
> Giants ,Trade Barry and win some games.
> 
> Don Cole

Thanks Don, but it didn't make any difference. Actually, I'm a little confused
about what current_dir() refers to, because you can have more than one "current
directory". On XP and Linux you could have any number of shells open, each one
running from a different directory. I thought that current_dir() gives you the
dir which the Eu program is running from.

Please could someone set me straight on this?

new topic     » goto parent     » topic index » view message » categorize

6. Re: current_dir()

Jules wrote:

<snip>

> Thanks Don, but it didn't make any difference. Actually, I'm a little confused
> about what current_dir() refers to, because you can have more than one
> "current
> directory". On XP and Linux you could have any number of shells open, each one
> running from a different directory. I thought that current_dir() gives you the
> dir which the Eu program is running from. 
> 
> Please could someone set me straight on this?

When you open a command window (console) on Windows, and it shows say
   C:\Programs>
then "C:\Programs" is the current directory. The definition of the
current directory has nothing got to do with the question where your
Eu program is located. I think it's the same on Linux.

When your program "my.exw" is located in the current directory, then
the command-line for starting it can be as simple as:
   exw my.exw
When your program is _not_ located in the current directory, then
you have to pass its full pathname (surrounded by quotes if it contains
spaces) to the Eu interpreter, e.g.
   exw "D:\my files\test\my.exw"

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

7. Re: current_dir()

Juergen Luethje wrote:
> 
> Jules wrote:
> 
> <snip>
> 
> > Thanks Don, but it didn't make any difference. Actually, I'm a little
> > confused
> > about what current_dir() refers to, because you can have more than one
> > "current
> > directory". On XP and Linux you could have any number of shells open, each
> > one
> > running from a different directory. I thought that current_dir() gives you
> > the
> > dir which the Eu program is running from. 
> > 
> > Please could someone set me straight on this?
> 
> When you open a command window (console) on Windows, and it shows say
>    C:\Programs>
> then "C:\Programs" is the current directory. The definition of the
> current directory has nothing got to do with the question where your
> Eu program is located. I think it's the same on Linux.
> 
> When your program "my.exw" is located in the current directory, then
> the command-line for starting it can be as simple as:
>    exw my.exw
> When your program is _not_ located in the current directory, then
> you have to pass its full pathname (surrounded by quotes if it contains
> spaces) to the Eu interpreter, e.g.
>    exw "D:\my files\test\my.exw"
> 
> Regards,
>    Juergen

Ok thanks Juergen. I was trying to write a program which would "find itself" as
it were, and I thought current_dir() would be a way to do it.
But going back to my point about consoles (sticking with Windows), I can open a
console and CD to c:\euphoria, then open another and CD to c:\windows... so which
is the current directory in this case?

new topic     » goto parent     » topic index » view message » categorize

8. Re: current_dir()

Jules wrote:

> Juergen Luethje wrote:
> > 
> > Jules wrote:
> > 
> > <snip>
> > 
> > > Thanks Don, but it didn't make any difference. Actually, I'm a little
> > > confused
> > > about what current_dir() refers to, because you can have more than one
> > > "current
> > > directory". On XP and Linux you could have any number of shells open, each
> > > one
> > > running from a different directory. I thought that current_dir() gives you
> > > the
> > > dir which the Eu program is running from. 
> > > 
> > > Please could someone set me straight on this?
> > 
> > When you open a command window (console) on Windows, and it shows say
> >    C:\Programs>
> > then "C:\Programs" is the current directory. The definition of the
> > current directory has nothing got to do with the question where your
> > Eu program is located. I think it's the same on Linux.
> > 
> > When your program "my.exw" is located in the current directory, then
> > the command-line for starting it can be as simple as:
> >    exw my.exw
> > When your program is _not_ located in the current directory, then
> > you have to pass its full pathname (surrounded by quotes if it contains
> > spaces) to the Eu interpreter, e.g.
> >    exw "D:\my files\test\my.exw"
> > 
> > Regards,
> >    Juergen
> 
> Ok thanks Juergen. I was trying to write a program which would "find itself"
> as it were, and I thought current_dir() would be a way to do it. 

No, the desired information is contained in the return value of
command_line(). Please see the documentation of command_line() for details.

> But going back to my point about consoles (sticking with Windows), I can open
> a console and CD to c:\euphoria, then open another and CD to c:\windows... so
> which is the current directory in this case?

I'm not 100% sure, but I think that actually each console window has its own
current directory. However, I personally can't remember that I ever had the
need to use current_dir() in one of my programs.

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

9. Re: current_dir()

Hello Jules,

As far as I know current_dir() is the diectory of the main program you are
  running. Example if running XYZ.EX or XYZ.EXW The current_dir() would be location
of that program. I don't Linux. From the command line which works like DOS,
after typing run/cmd [enter] mine says "c:\documents and setting/don cole>" that
sould be the current directory if you put a program in there with commad_line()
in it. I don't know how to execute current_dir() from the command line. Or why
you would want to do that. Current_dir() is only going to find the location of
the program that is calling current_dir() no matter what you are doing with
command line.





Don Cole

new topic     » goto parent     » topic index » view message » categorize

10. Re: current_dir()

don cole wrote:
> 
> Hello Jules,
> 
>   As far as I know current_dir() is the diectory of the main program you are
> running. 

No it is not!

In Windows, every process has a set of default directories, one per drive. A
command line window is a process so therefore it has a set of default dirs. The
current directory is the default directory of the current drive. It has nothing
to do whatsoever with which directory a program is stored in.

For example, if I start a Command line window I get "C:\Documents and
Settings\Derek>" as the prompt. This shows the current directory for the C:
drive. If I change drives to the D: drive the prompt changes to "D:\" which is
that drive's current directory. If I now start a program that is stored in some
other directory running, the current directory is still D:\ and not the program's
location.

Let's say I have this program ...
include file.e
printf(1, "%s\n", {current_dir()})

saved as C:\temp\showcd.ex

In my command window I run this ...

  D:\> exwc c:\temp\showcd.ex

The output is "D:\" and not "C:\temp"

Now let's change that program a little ...
include file.e
printf(1, "%s\n", {current_dir()})
constant arg = command_line()
printf(1, "%s\n%s\n", {arg[1], arg[2]})


And run it again ...

  D:\> exwc c:\temp\showcd.ex

The output is now ...

D:\
C:\EUPHORIA\BIN\exwc.exe
c:\temp\showcd.ex



-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

11. Re: current_dir()

Derek Parnell wrote:
> 
> don cole wrote:
> > 
> > Hello Jules,
> > 
> >   As far as I know current_dir() is the diectory of the main program you are
> > running. 
> 
> No it is not!
> 
> In Windows, every process has a set of default directories, one per drive. A
> command line window is a process so therefore it has a set of default dirs.
> The current directory is the default directory of the current drive. It has
> nothing to do whatsoever with which directory a program is stored in.
> 
> For example, if I start a Command line window I get "C:\Documents and
> Settings\Derek>"
> as the prompt. This shows the current directory for the C: drive. If I change
> drives to the D: drive the prompt changes to "D:\" which is that drive's
> current
> directory. If I now start a program that is stored in some other directory
> running,
> the current directory is still D:\ and not the program's location.
> 
> Let's say I have this program ...
> }}}
<eucode>
> include file.e
> printf(1, "%s\n", {current_dir()})
> </eucode>
{{{

> saved as C:\temp\showcd.ex
> 
> In my command window I run this ...
> 
>   D:\> exwc c:\temp\showcd.ex
> 
> The output is "D:\" and not "C:\temp"
> 
> Now let's change that program a little ...
> }}}
<eucode>
> include file.e
> printf(1, "%s\n", {current_dir()})
> constant arg = command_line()
> printf(1, "%s\n%s\n", {arg[1], arg[2]})
> </eucode>
{{{

> 
> And run it again ...
> 
>   D:\> exwc c:\temp\showcd.ex
> 
> The output is now ...
> 
> D:\
> C:\EUPHORIA\BIN\exwc.exe
> c:\temp\showcd.ex
> 
> 
> -- 
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell

Hello Derek,

  I'm sure you are right. I place all Eu programs in the F:\ dir.

 Everytime I use current_dir() it is from one of those programs in F:\.

So I would get F:\something or other. What I don't understand is why would one
 want to call one of those F:\ program from the command line in C:\?

Don Cole

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu