Using env variables in tcl script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Soumen

    Using env variables in tcl script

    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
  • santosh

    #2
    Re: Using env variables in tcl script

    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.programmin g.

    Comment

    • Mark Bluemel

      #3
      Re: Using env variables in tcl script

      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?

      Comment

      • Kenny McCormack

        #4
        Re: Using env variables in tcl script

        In article <fr89b2$9nc$1@a ioe.org>,
        Mark Bluemel <mark_bluemel@p obox.comwrote:
        ....
        >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.

        Comment

        Working...