Using env variables in tcl script

Discussion in 'C Programming' started by Soumen, Mar 12, 2008.

  1. Soumen

    Soumen Guest

    Hi,

    If I do following in tclsh prompt, it works;

    %set i [array names env PATH]
    %echo $env($i)

    But if I wrap it in a.tcl, source it in tclsh prompt and call test, it
    gives me following error:

    can't read "env": no such variable

    ----------- a.tcl -----------------
    proc test {} {
    set i [array names env PATH]
    echo $env($i)
    }
    --------------------------------------

    %source a.tcl
    %test
    can't read "env": no such variable
    %

    Please let me know how to resolve this.

    Regards,
    ~ Soumen
    Soumen, Mar 12, 2008
    #1
    1. Advertising

  2. Soumen

    santosh Guest

    Soumen wrote:

    <snip>

    Please post to a TCL group or forum like comp.lang.tcl. This group is
    for standard C. You might also try comp.programming.
    santosh, Mar 12, 2008
    #2
    1. Advertising

  3. Soumen

    Mark Bluemel Guest

    Soumen wrote:
    > Hi,
    >
    > If I do following in tclsh prompt, it works;
    >
    > %set i [array names env PATH]
    > %echo $env($i)
    >
    > But if I wrap it in a.tcl, source it in tclsh prompt and call test, it
    > gives me following error:
    >
    > can't read "env": no such variable
    >
    > ----------- a.tcl -----------------
    > proc test {} {
    > set i [array names env PATH]
    > echo $env($i)
    > }
    > --------------------------------------
    >
    > %source a.tcl
    > %test
    > can't read "env": no such variable
    > %
    >
    > Please let me know how to resolve this.


    Would you like us to diagnose your car's timing problem as well?

    This has nothing to do with C - why should we be expected to know
    anything about it?

    There appears to be a comp.lang.tcl group - why not ask there?
    Mark Bluemel, Mar 12, 2008
    #3
  4. In article <fr89b2$9nc$>,
    Mark Bluemel <> wrote:
    ....
    >> Please let me know how to resolve this.

    >
    >Would you like us to diagnose your car's timing problem as well?
    >
    >This has nothing to do with C - why should we be expected to know
    >anything about it?


    No, sorry, you are wrong. See, tcl is written in C, therefore this is
    on topic in a C group.

    See, ultimately, we all know that "tcl" is just a wrapper around the
    underlying C runtime. For example, the error message that the OP
    mentions - that actually comes from C.

    >There appears to be a comp.lang.tcl group - why not ask there?


    Interesting. That might work, as well.
    Kenny McCormack, Mar 12, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Powell
    Replies:
    0
    Views:
    414
    Phil Powell
    Sep 17, 2003
  2. Ankit Mehta
    Replies:
    1
    Views:
    1,419
    Simon Brooke
    Sep 29, 2006
  3. TDR
    Replies:
    3
    Views:
    172
    Daniel Berger
    Aug 31, 2007
  4. Narayanan K
    Replies:
    1
    Views:
    132
    Gabriel Horner
    Jun 18, 2010
  5. Mumia W.

    Inline::Tcl vs. Inline::Tcl

    Mumia W., Aug 23, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    137
    Mumia W.
    Aug 23, 2006
Loading...

Share This Page