1. Euphoria environment variables (was: quick cgi question)

Greg Haberek wrote:

>> I've been thinking in getting a second computer and give
>> Linux a second try.  What distribution would you recomend?
> 
> My friends and I have come up with two terms for Linux users: those
> who want to "get in and drive" and those who want to "get under the
> hood."
> 
> If all you want to do is "get in and drive" then I suggest Ubuntu. If
> all you're concerned about is using Linux as an OS with having to
> compile anything, its great. However, setting up Euphoria is a hassle
> (environment variables don't work the same -- but I found a way around
> that).

<snip>

I also encountered problems with the environment variables when running
Euphoria from a USB drive (on Windows XP).

Rob, I think usage of Euphoria would be simpler, if Euphoria would read
its settings from an INI file rather than from environment variables,
e.g.:

---------------------------- Euphoria.ini ----------------------------
[Directories]
EUDIR=C:\Programs\Euphoria\
EUINC=C:\Programs\Euphoria\Arwen\bin\;C:\Programs\Euphoria\wxEuphoria\
----------------------------------------------------------------------

The interpreter/translator just had to look for a file "Euphoria.ini" in
the same directory where it is located itself. 100% cross-platform, and
no hassle with environment variables any more. What do you think?

Regards,
   Juergen

-- 
Have you read a good program lately?

new topic     » topic index » view message » categorize

2. Re: Euphoria environment variables (was: quick cgi question)

Juergen Luethje wrote:
> 
> Greg Haberek wrote:
> 
> >> I've been thinking in getting a second computer and give
> >> Linux a second try.  What distribution would you recomend?
> > 
> > My friends and I have come up with two terms for Linux users: those
> > who want to "get in and drive" and those who want to "get under the
> > hood."
> > 
> > If all you want to do is "get in and drive" then I suggest Ubuntu. If
> > all you're concerned about is using Linux as an OS with having to
> > compile anything, its great. However, setting up Euphoria is a hassle
> > (environment variables don't work the same -- but I found a way around
> > that).
> 
> <snip>
> 
> I also encountered problems with the environment variables when running
> Euphoria from a USB drive (on Windows XP).
> 
> Rob, I think usage of Euphoria would be simpler, if Euphoria would read
> its settings from an INI file rather than from environment variables,
> e.g.:
> 
> ---------------------------- Euphoria.ini ----------------------------
> [Directories]
> EUDIR=C:\Programs\Euphoria\
> EUINC=C:\Programs\Euphoria\Arwen\bin\;C:\Programs\Euphoria\wxEuphoria\
> ----------------------------------------------------------------------
> 
> The interpreter/translator just had to look for a file "Euphoria.ini" in
> the same directory where it is located itself. 100% cross-platform, and
> no hassle with environment variables any more. What do you think?
> 
> Regards,
>    Juergen
> 
> -- 
> Have you read a good program lately?

Thats a nice idea - how about reading from an ini file if present in the
current directory, or falling back to environment variables if not present?

Chris

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

3. Re: Euphoria environment variables (was: quick cgi question)

ChrisBurch2 wrote:
> 
> Juergen Luethje wrote:
> > 
> > I also encountered problems with the environment variables when running
> > Euphoria from a USB drive (on Windows XP).
> > 
> > Rob, I think usage of Euphoria would be simpler, if Euphoria would read
> > its settings from an INI file rather than from environment variables,
> > e.g.:
> > 
> > ---------------------------- Euphoria.ini ----------------------------
> > [Directories]
> > EUDIR=C:\Programs\Euphoria\
> > EUINC=C:\Programs\Euphoria\Arwen\bin\;C:\Programs\Euphoria\wxEuphoria\
> > ----------------------------------------------------------------------
> > 
> > The interpreter/translator just had to look for a file "Euphoria.ini" in
> > the same directory where it is located itself. 100% cross-platform, and
> > no hassle with environment variables any more. What do you think?
> > 
> 
> Thats a nice idea - how about reading from an ini file if present in the
> current directory, or falling back to environment variables if not present?

That would be really useful! Instead of the *.ini I could imagine an env.e smile
with this content:

global constant EUDIR="C:\Programs\Euphoria\"
global constant
EUINC={"C:\Programs\Euphoria\Arwen\bin\","C:\Programs\Euphoria\wxEuphoria\"}


Regards,

Salix

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

4. Re: Euphoria environment variables (was: quick cgi question)

Juergen Luethje wrote:

>The interpreter/translator just had to look for a file "Euphoria.ini"
>in the same directory where it is located itself. 100%
>cross-platform, and no hassle with environment variables any more.
>What do you think?

But is this cross-platform?

Under DOS and Windows, C compilers use argv[0] to get the complete path
to the program.

However, argv[0] isn't populated the same way under Linux. argv[0]
appears to contain the command string that was typed to start the
executable.  This is on RedHat, SlackWare, and Knoppix.  I assume the
other distributions are the same?

I don't know about FreeBSD, but I assume this is a Unix thing.

So, how does a program find the complete path to itself on Linux?

Finally, I agree, it would be nice to not require environment
variables!

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

5. Re: Euphoria environment variables (was: quick cgi question)

Ed Davis wrote:

> Juergen Luethje wrote:
> 
>> The interpreter/translator just had to look for a file "Euphoria.ini"
>> in the same directory where it is located itself. 100%
>> cross-platform, and no hassle with environment variables any more.
>> What do you think?
> 
> But is this cross-platform?
> 
> Under DOS and Windows, C compilers use argv[0] to get the complete path
> to the program.
> 
> However, argv[0] isn't populated the same way under Linux. argv[0]
> appears to contain the command string that was typed to start the
> executable.  This is on RedHat, SlackWare, and Knoppix.  I assume the
> other distributions are the same?
> 
> I don't know about FreeBSD, but I assume this is a Unix thing.
> 
> So, how does a program find the complete path to itself on Linux?

I don't know how this would work with C, but fortunately the Euphoria
interpreter front-end and translator are written in Euphoria now. smile

-- tested with Eu 2.5 on Windows
-- (should work on all supported platforms)

include misc.e                       -- for constant LINUX

function path_end (sequence name, integer slash)
   for i = length(name) to 1 by -1 do
      if name[i] = slash then
         return i
      end if
   end for
   return find(':', name)
end function

function file_path (sequence name, integer slash)
   -- in : name : filename, e.g. "c:\\programs\\nicetool.exe"
   --      slash: slash charecter in use
   -- out: path, always with trailing slash or colon
   integer p

   p = path_end(name, slash)
   if p = length(name) or name[p+1] != '.' then
      return name[1..p]
   else
      return name & slash
   end if
end function

function prog_path ()
   -- out: full path where this program itself is located,
   --      always with trailing slash or colon
   sequence cmd
   integer slash

   cmd = command_line()
   if platform() = LINUX then
      slash = '/'
   else
      slash = '\\'
   end if
   return file_path(cmd[2], slash)
end function

constant INI_NAME = "euphoria.ini"   -- we can choose this name freely

sequence ini_file
ini_file = prog_path() & INI_NAME    -- full pathname of the INI file
puts(1, ini_file)                    -- ( which is needed e.g for open() )
if getc(0) then end if


> Finally, I agree, it would be nice to not require environment
> variables!

Thanks! Since several people now had said that they share this opinion,
it shows me that the idea was not too crazy. smile

Regards,
   Juergen

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

6. Re: Euphoria environment variables (was: quick cgi question)

Me wrote:

> Ed Davis wrote:

<snip>

>> But is this cross-platform?
>> 
>> Under DOS and Windows, C compilers use argv[0] to get the complete path
>> to the program.
>> 
>> However, argv[0] isn't populated the same way under Linux. argv[0]
>> appears to contain the command string that was typed to start the
>> executable.  This is on RedHat, SlackWare, and Knoppix.  I assume the
>> other distributions are the same?
>> 
>> I don't know about FreeBSD, but I assume this is a Unix thing.
>> 
>> So, how does a program find the complete path to itself on Linux?
> 
> I don't know how this would work with C, but fortunately the Euphoria
> interpreter front-end and translator are written in Euphoria now. smile
> 
> }}}
<eucode>

<snip>

What I forgot to mention:
As I understand the documentation of Eu's command_line() function, at least
for executable files the second element always contains its full path name.
Can you confirm that regarding some Linux distributions?

Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu