f



TCL equivalent of PHP "phpinfo()"?

I am seeking code that will dump all global vars out to screen or
standard out.  I tried writing it on my own, to no avail (no big
surprise, huh?).  This is what I have so far:

foreach var [info globals] {
 if {[array exists $var]} {foreach blah [array names $var] {puts
"$var\($blah\) = {{I have no idea what to put here}"}}
 if {[info exists $var] && ![array exists $var]} {puts "$var: [set
$var]"}
}

I am seeking the equivalent of PHP's "phpinfo()" command that dumps
every global variable out all nice and formatted for you.  Is there
anything out there that does that or what must I do to my existing
code to be able to view all global vars (arrays and all)?

Thanx
Phil
0
soazine (387)
12/31/2003 5:56:23 PM
comp.lang.tcl 23428 articles. 2 followers. Post Follow

52 Replies
11092 Views

Similar Articles

[PageSpeed] 27

soazine@erols.com (Phil Powell) writes:

> I am seeking code that will dump all global vars out to screen or
> standard out.  I tried writing it on my own, to no avail (no big
> surprise, huh?).  This is what I have so far:
> 
> foreach var [info globals] {
>  if {[array exists $var]} {foreach blah [array names $var] {puts
> "$var\($blah\) = {{I have no idea what to put here}"}}
>  if {[info exists $var] && ![array exists $var]} {puts "$var: [set
> $var]"}
> }
> 
> I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> every global variable out all nice and formatted for you.  Is there
> anything out there that does that or what must I do to my existing
> code to be able to view all global vars (arrays and all)?
> 
> Thanx
> Phil

I do not know what phpinfo does but this is a good start at 
dumping globals:

foreach x [info globals ] {
    set y [array get $x ]
    if { 2 > [llength $y] } {
	puts "var: $x == [set $x]"
    } else {
        foreach {mutt jeff } $y { 
           puts [format "array: %s(%s) == %s" $x $mutt $jeff]
        }
    }
}

put this in its own name space, so it does not pollute the
globals and you should be close, if you want html then
add the proper bits.

marc
0
mspitze1 (98)
1/1/2004 12:48:32 AM
soazine@erols.com (Phil Powell) writes:

> I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> every global variable out all nice and formatted for you.  Is there
> anything out there that does that or what must I do to my existing
> code to be able to view all global vars (arrays and all)?

Other people have answered this question, but may I ask what it's in
aid of?  I'm curious why you need to do this...whether it's for
debugging, web work, or something else?

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/1/2004 10:40:04 AM
Basically for the exact same reason why we have phpinfo() in the PHP
realm (see http://www.php.net/manual/en/function.phpinfo.php for more
info), only for TCL.  I want a way of determining all global
environmental variables in the environment that I'm in, like what
$env(HOME) is for example, or something.

Phil

davidw@dedasys.com (David N. Welton) wrote in message news:<87ekukt0jf.fsf@dedasys.com>...
> soazine@erols.com (Phil Powell) writes:
> 
> > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > every global variable out all nice and formatted for you.  Is there
> > anything out there that does that or what must I do to my existing
> > code to be able to view all global vars (arrays and all)?
> 
> Other people have answered this question, but may I ask what it's in
> aid of?  I'm curious why you need to do this...whether it's for
> debugging, web work, or something else?
0
soazine (387)
1/1/2004 7:13:34 PM
Thanx, however, this line makes no sense to me, could you please
explain it in detail:

 foreach {mutt jeff } $y { 
           puts [format "array: %s(%s) == %s" $x $mutt $jeff]
        }


I don't understand literally any of it. :(

Phil

Marc Spitzer <mspitze1@optonline.net> wrote in message news:<86y8ssv6hf.fsf@bogomips.optonline.net>...
> soazine@erols.com (Phil Powell) writes:
> 
> > I am seeking code that will dump all global vars out to screen or
> > standard out.  I tried writing it on my own, to no avail (no big
> > surprise, huh?).  This is what I have so far:
> > 
> > foreach var [info globals] {
> >  if {[array exists $var]} {foreach blah [array names $var] {puts
> > "$var\($blah\) = {{I have no idea what to put here}"}}
> >  if {[info exists $var] && ![array exists $var]} {puts "$var: [set
> > $var]"}
> > }
> > 
> > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > every global variable out all nice and formatted for you.  Is there
> > anything out there that does that or what must I do to my existing
> > code to be able to view all global vars (arrays and all)?
> > 
> > Thanx
> > Phil
> 
> I do not know what phpinfo does but this is a good start at 
> dumping globals:
> 
> foreach x [info globals ] {
>     set y [array get $x ]
>     if { 2 > [llength $y] } {
> 	puts "var: $x == [set $x]"
>     } else {
>         foreach {mutt jeff } $y { 
>            puts [format "array: %s(%s) == %s" $x $mutt $jeff]
>         }
>     }
> }
> 
> put this in its own name space, so it does not pollute the
> globals and you should be close, if you want html then
> add the proper bits.
> 
> marc
0
soazine (387)
1/1/2004 7:14:57 PM
Thanx, Marc, however, upon using your code I get the following error:

can't read "tcl_rcFileName": no such variable

And everything of course blows up.  Apparently it doesn't allow for
the foreach [format] to work with arrays to well.  I always thought
TCL couldn't handle arrays too well.

Phil

Marc Spitzer <mspitze1@optonline.net> wrote in message news:<86y8ssv6hf.fsf@bogomips.optonline.net>...
> soazine@erols.com (Phil Powell) writes:
> 
> > I am seeking code that will dump all global vars out to screen or
> > standard out.  I tried writing it on my own, to no avail (no big
> > surprise, huh?).  This is what I have so far:
> > 
> > foreach var [info globals] {
> >  if {[array exists $var]} {foreach blah [array names $var] {puts
> > "$var\($blah\) = {{I have no idea what to put here}"}}
> >  if {[info exists $var] && ![array exists $var]} {puts "$var: [set
> > $var]"}
> > }
> > 
> > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > every global variable out all nice and formatted for you.  Is there
> > anything out there that does that or what must I do to my existing
> > code to be able to view all global vars (arrays and all)?
> > 
> > Thanx
> > Phil
> 
> I do not know what phpinfo does but this is a good start at 
> dumping globals:
> 
> foreach x [info globals ] {
>     set y [array get $x ]
>     if { 2 > [llength $y] } {
> 	puts "var: $x == [set $x]"
>     } else {
>         foreach {mutt jeff } $y { 
>            puts [format "array: %s(%s) == %s" $x $mutt $jeff]
>         }
>     }
> }
> 
> put this in its own name space, so it does not pollute the
> globals and you should be close, if you want html then
> add the proper bits.
> 
> marc
0
soazine (387)
1/2/2004 2:18:34 PM

Phil Powell wrote:
> 
> Basically for the exact same reason why we have phpinfo() in the PHP
> realm (see http://www.php.net/manual/en/function.phpinfo.php for more
> info), only for TCL.  I want a way of determining all global
> environmental variables in the environment that I'm in, like what
> $env(HOME) is for example, or something.
A couple of things:

The categroy of "Global environmental variables" has no 
definition Tcl. Rather Tcl has globals period.
The process environment is automatically placed
into a Tcl global arrray named env.

To dump an array just us the Tcl library
procedure parray.

parray env

There is also an array called tcl_platform
parray tcl_platform


To print every global variable

# 1. get the variable names
set globals [info globals]

# 2. Sort them
set globals [lsort $globals]

# 3. Print by type
foreach g $globals {
    if {[array exists $g]} {parray $g} {puts "$g = [set $g]"}
}

parray is just a litte peice of tcl code
from the standard library ( such as (installdir)/tcl/lib/tcl8.4)

769 C:/Program File.../tcl/lib/tcl8.4> cat parray.tcl
# parray:
# Print the contents of a global array on stdout.
#
# RCS: @(#) $Id: parray.tcl,v 1.3 1998/09/14 18:40:03 stanton Exp $
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and
redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#

proc parray {a {pattern *}} {
    upvar 1 $a array
    if {![array exists array]} {
        error "\"$a\" isn't an array"
    }
    set maxl 0
    foreach name [lsort [array names array $pattern]] {
        if {[string length $name] > $maxl} {
            set maxl [string length $name]
        }
    }
    set maxl [expr {$maxl + [string length $a] + 2}]
    foreach name [lsort [array names array $pattern]] {
        set nameString [format %s(%s) $a $name]
        puts stdout [format "%-*s = %s" $maxl $nameString $array($name)]
    }
}

Please check Tcl man pages for

tclvars
library
info
etc.

Does this get you the information you
need?

> 
> Phil
> 
> davidw@dedasys.com (David N. Welton) wrote in message news:<87ekukt0jf.fsf@dedasys.com>...
> > soazine@erols.com (Phil Powell) writes:
> >
> > > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > > every global variable out all nice and formatted for you.  Is there
> > > anything out there that does that or what must I do to my existing
> > > code to be able to view all global vars (arrays and all)?
> >
> > Other people have answered this question, but may I ask what it's in
> > aid of?  I'm curious why you need to do this...whether it's for
> > debugging, web work, or something else?
0
royterry (360)
1/2/2004 2:30:30 PM
soazine@erols.com (Phil Powell) wrote in message news:<1cdca2a7.0312310956.45e2a29@posting.google.com>...
> I am seeking code that will dump all global vars out to screen or
> standard out.  I tried writing it on my own, to no avail (no big
> surprise, huh?).  This is what I have so far:

This proc returns a string suitable for printing, listing scalar
variables first, then arrays. Adjust as you see fit (process args,
change format string, etc.).

    proc tclinfo {args} {
        set buf "Global variables:\n"
        set vars [lsort [info globals]]
        foreach v $vars {
            global $v
            if {![array exists $v]} {
                append buf [format "  %-36s : '%s'\n" $v [set $v]]
            }
        }
        append buf "\nGlobal arrays:\n"
        foreach v $vars {
            if {[array exists $v]} {
                append buf [format "\n  %s:\n" $v]
                foreach key [lsort [array names $v]] {
                    append buf [format "      %-36s : '%s'\n" $key [set ${v}($key)]]
                }
            }
        }
        return $buf
    }


hj
0
hj1951 (2)
1/2/2004 7:21:14 PM
soazine@erols.com (Phil Powell) writes:

> Basically for the exact same reason why we have phpinfo() in the PHP
> realm (see http://www.php.net/manual/en/function.phpinfo.php for
> more info), only for TCL.

PHP has that, as far as I know, because "CGI" variables were at one
time created as global variables, so something like that was good for
debugging.  The page doesn't really explain the why of it.

You should know what global variables you have floating around, and
there shouldn't be too many of them, either.

> I want a way of determining all global environmental variables in
> the environment that I'm in, like what $env(HOME) is for example, or
> something.

Well, env is always there and it's always an array.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/2/2004 7:25:31 PM
In article <1cdca2a7.0401011114.360add4d@posting.google.com>,
Phil Powell <soazine@erols.com> wrote:
>Thanx, however, this line makes no sense to me, could you please
>explain it in detail:
>
> foreach {mutt jeff } $y { 
>           puts [format "array: %s(%s) == %s" $x $mutt $jeff]
>        }
>
>
>I don't understand literally any of it. :(
			.
			.
			.
$y was constructed as a list of paired elements, a common idiom
in Tcl.  Practice understanding it with this example:
  set my_list {a 1 b 2 c 3} 
  foreach character $my_list {
      puts "The character is '$character'."
  }
  foreach {letter digit} $my_list {
      puts "The letter and the digit are '$letter' and '$digit'."
  }
Does that leave any questions in your mind?
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/2/2004 7:28:21 PM
It's a great proc, Roy, but I have no clue as to how to use it
properly.  Consider my code:

proc getStruct {var} {
  return "\n$var = [set ::$var] "
 }

 proc setArrayStruct {arrayName} {
  puts "\narrayName = $arrayName\n"
  global $arrayName
  if {![array exists $arrayName]} {exit}
  upvar 0 $arrayName myArray
  set arrayName [parray $arrayName]
 }

 proc dumpGlobalVars {} {
  foreach var [info globals] { global $var }; # FORCE ALL VARS WITHIN
globals LIST TO EXIST WITHIN PROC CONSTRUCT (TCL EQUIV OF JAVA
"super")
  global $envinfo::exceptionList
  puts "\nGLOBAL VARS:\n"
  set varTable {}
  foreach var [lsort -increasing [info globals]] {
   if {[array exists $var] && [lsearch -exact $envinfo::exceptionList
$var] < 0} {
    append varTable "\n$var = ARRAY:"
    envinfo::setArrayStruct $var
    append varTable "\n[envinfo::getStruct $var]"
   } elseif {[info exists $var] && ![array exists $var] && [lsearch
-exact $envinfo::exceptionList $var] < 0} {
    append varTable [envinfo::getStruct $var]
   } else {
    append varTable "\n$var does not exist"
   }
  }
  return "$varTable\n\n"
 }

The following produces the following error:

can't read "::auto_index": variable is array

I have this proc instead that works that doesn't use parray because,
frankly, I have no idea how to use it:

proc getArrayStruct {arrayName} {
  global $arrayName
  upvar 0 $arrayName myArray
  set outputList [list "$arrayName = ARRAY:"]
  set keyList [lsort -dictionary [array names $arrayName]]
  foreach key $keyList {
   lappend outputList " $arrayName\($key\) = $myArray($key)"
  }
  return "\n[join $outputList \n]"
 } 

Bottom line is that parray is probably much easier and more elegant,
but for me impossible to implement into the coding structure. :(

Phil

Roy Terry <royterry@earthlink.net> wrote in message news:<3FF58077.1997D436@earthlink.net>...
> Phil Powell wrote:
> > 
> > Basically for the exact same reason why we have phpinfo() in the PHP
> > realm (see http://www.php.net/manual/en/function.phpinfo.php for more
> > info), only for TCL.  I want a way of determining all global
> > environmental variables in the environment that I'm in, like what
> > $env(HOME) is for example, or something.
> A couple of things:
> 
> The categroy of "Global environmental variables" has no 
> definition Tcl. Rather Tcl has globals period.
> The process environment is automatically placed
> into a Tcl global arrray named env.
> 
> To dump an array just us the Tcl library
> procedure parray.
> 
> parray env
> 
> There is also an array called tcl_platform
> parray tcl_platform
> 
> 
> To print every global variable
> 
> # 1. get the variable names
> set globals [info globals]
> 
> # 2. Sort them
> set globals [lsort $globals]
> 
> # 3. Print by type
> foreach g $globals {
>     if {[array exists $g]} {parray $g} {puts "$g = [set $g]"}
> }
> 
> parray is just a litte peice of tcl code
> from the standard library ( such as (installdir)/tcl/lib/tcl8.4)
> 
> 769 C:/Program File.../tcl/lib/tcl8.4> cat parray.tcl
> # parray:
> # Print the contents of a global array on stdout.
> #
> # RCS: @(#) $Id: parray.tcl,v 1.3 1998/09/14 18:40:03 stanton Exp $
> #
> # Copyright (c) 1991-1993 The Regents of the University of California.
> # Copyright (c) 1994 Sun Microsystems, Inc.
> #
> # See the file "license.terms" for information on usage and
> redistribution
> # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
> #
> 
> proc parray {a {pattern *}} {
>     upvar 1 $a array
>     if {![array exists array]} {
>         error "\"$a\" isn't an array"
>     }
>     set maxl 0
>     foreach name [lsort [array names array $pattern]] {
>         if {[string length $name] > $maxl} {
>             set maxl [string length $name]
>         }
>     }
>     set maxl [expr {$maxl + [string length $a] + 2}]
>     foreach name [lsort [array names array $pattern]] {
>         set nameString [format %s(%s) $a $name]
>         puts stdout [format "%-*s = %s" $maxl $nameString $array($name)]
>     }
> }
> 
> Please check Tcl man pages for
> 
> tclvars
> library
> info
> etc.
> 
> Does this get you the information you
> need?
> 
> > 
> > Phil
> > 
> > davidw@dedasys.com (David N. Welton) wrote in message news:<87ekukt0jf.fsf@dedasys.com>...
> > > soazine@erols.com (Phil Powell) writes:
> > >
> > > > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > > > every global variable out all nice and formatted for you.  Is there
> > > > anything out there that does that or what must I do to my existing
> > > > code to be able to view all global vars (arrays and all)?
> > >
> > > Other people have answered this question, but may I ask what it's in
> > > aid of?  I'm curious why you need to do this...whether it's for
> > > debugging, web work, or something else?
0
soazine (387)
1/2/2004 9:20:55 PM
Phil Powell wrote:

> It's a great proc, Roy, but I have no clue as to how to use it
> properly.  Consider my code:
> 
>...
> 
>  proc dumpGlobalVars {} {
>   foreach var [info globals] { global $var }; # FORCE ALL VARS WITHIN
> globals LIST TO EXIST WITHIN PROC CONSTRUCT (TCL EQUIV OF JAVA
> "super")

I missed this bit of code from an earlier post. This looks to be a Very 
Bad Idea. For example, two lines later you do "set varTable {}". If 
varTable happens to be a global variable your reporting procedure just 
modified a global variable. For that reason this doesn't look like a 
particularly good solution.


0
bryan1 (353)
1/2/2004 10:05:42 PM
soazine@erols.com (Phil Powell) writes:

> Thanx, Marc, however, upon using your code I get the following error:
> 
> can't read "tcl_rcFileName": no such variable
> 
> And everything of course blows up.  Apparently it doesn't allow for
> the foreach [format] to work with arrays to well.  I always thought
> TCL couldn't handle arrays too well.
> 
> Phil

Well it worked reasonably well for me.  Also just a FYI top posting is
considered rude, the reason for this is that it makes things harder to
follow for the readers of the group.  

marc

> 
> Marc Spitzer <mspitze1@optonline.net> wrote in message news:<86y8ssv6hf.fsf@bogomips.optonline.net>...
> > soazine@erols.com (Phil Powell) writes:
> > 
> > > I am seeking code that will dump all global vars out to screen or
> > > standard out.  I tried writing it on my own, to no avail (no big
> > > surprise, huh?).  This is what I have so far:
> > > 
> > > foreach var [info globals] {
> > >  if {[array exists $var]} {foreach blah [array names $var] {puts
> > > "$var\($blah\) = {{I have no idea what to put here}"}}
> > >  if {[info exists $var] && ![array exists $var]} {puts "$var: [set
> > > $var]"}
> > > }
> > > 
> > > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > > every global variable out all nice and formatted for you.  Is there
> > > anything out there that does that or what must I do to my existing
> > > code to be able to view all global vars (arrays and all)?
> > > 
> > > Thanx
> > > Phil
> > 
> > I do not know what phpinfo does but this is a good start at 
> > dumping globals:
> > 
> > foreach x [info globals ] {
> >     set y [array get $x ]
> >     if { 2 > [llength $y] } {
> > 	puts "var: $x == [set $x]"
> >     } else {
> >         foreach {mutt jeff } $y { 
> >            puts [format "array: %s(%s) == %s" $x $mutt $jeff]
> >         }
> >     }
> > }
> > 
> > put this in its own name space, so it does not pollute the
> > globals and you should be close, if you want html then
> > add the proper bits.
> > 
> > marc
0
mspitze1 (98)
1/2/2004 10:24:38 PM
davidw@dedasys.com (David N. Welton) wrote in message news:<87isjuqhjl.fsf@dedasys.com>...
> soazine@erols.com (Phil Powell) writes:
> 
> > Basically for the exact same reason why we have phpinfo() in the PHP
> > realm (see http://www.php.net/manual/en/function.phpinfo.php for
> > more info), only for TCL.
> 
> PHP has that, as far as I know, because "CGI" variables were at one
> time created as global variables, so something like that was good for
> debugging.  The page doesn't really explain the why of it.
> 
> You should know what global variables you have floating around, and
> there shouldn't be too many of them, either.

Not if you're doing web programming you won't.  That is why PHP
invented phpinfo(), for web developers like me who normally don't have
command-line practice to learn what global environmental variables you
have.

I think it might help to know my background: I feel that all of you
are engineers and software developers.  I'm a web developer. 
Basically the same as someone who speaks Swedish in a room of people
who speak Mongolian.

Phil


> 
> > I want a way of determining all global environmental variables in
> > the environment that I'm in, like what $env(HOME) is for example, or
> > something.
> 
> Well, env is always there and it's always an array.
0
soazine (387)
1/2/2004 10:33:58 PM
soazine@erols.com (Phil Powell) writes:

> > You should know what global variables you have floating around,
> > and there shouldn't be too many of them, either.

> Not if you're doing web programming you won't.  That is why PHP
> invented phpinfo(), for web developers like me who normally don't
> have command-line practice to learn what global environmental
> variables you have.

If you use a system like Rivet ( http://tcl.apache.org/rivet/ ), all
your "CGI" variables (the one that the user inputs) are not globals.

You would use the 'var' command:

http://tcl.apache.org/rivet/html/commands.en.html

Something like:

foreach {var val} [vars all] {
        puts "Variable $var is set to $val <br>"
}

> I think it might help to know my background: I feel that all of you
> are engineers and software developers.  I'm a web developer.
> Basically the same as someone who speaks Swedish in a room of people
> who speak Mongolian.

I understand a thing or two about web programming, including, I hope,
how to make it reasonably accessible to people who are not expert
programmers.  I try at least:-)

Tcl itself is pretty easy to get a handle on in a lot of ways.  Maybe
I missed it, but did you mention what your ultimate goal with your
project is?  Often, it's easier to give advice if you know what
someone wants to achieve.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/2/2004 11:12:53 PM
"Marc Spitzer" <mspitze1@optonline.net> wrote in message
news:86ekuij8ei.fsf@bogomips.optonline.net...
> soazine@erols.com (Phil Powell) writes:
>
> > Thanx, Marc, however, upon using your code I get the following error:
> >
> > can't read "tcl_rcFileName": no such variable
> >
> > And everything of course blows up.  Apparently it doesn't allow for
> > the foreach [format] to work with arrays to well.  I always thought
> > TCL couldn't handle arrays too well.
> >
> > Phil
>
> Well it worked reasonably well for me.  Also just a FYI top posting is
> considered rude, the reason for this is that it makes things harder to
> follow for the readers of the group.
>
> marc
>

Sorry, I can't follow threads unless you do post to the top, unless you
reference below, I never look there.

Phil


> >
> > Marc Spitzer <mspitze1@optonline.net> wrote in message
news:<86y8ssv6hf.fsf@bogomips.optonline.net>...
> > > soazine@erols.com (Phil Powell) writes:
> > >
> > > > I am seeking code that will dump all global vars out to screen or
> > > > standard out.  I tried writing it on my own, to no avail (no big
> > > > surprise, huh?).  This is what I have so far:
> > > >
> > > > foreach var [info globals] {
> > > >  if {[array exists $var]} {foreach blah [array names $var] {puts
> > > > "$var\($blah\) = {{I have no idea what to put here}"}}
> > > >  if {[info exists $var] && ![array exists $var]} {puts "$var: [set
> > > > $var]"}
> > > > }
> > > >
> > > > I am seeking the equivalent of PHP's "phpinfo()" command that dumps
> > > > every global variable out all nice and formatted for you.  Is there
> > > > anything out there that does that or what must I do to my existing
> > > > code to be able to view all global vars (arrays and all)?
> > > >
> > > > Thanx
> > > > Phil
> > >
> > > I do not know what phpinfo does but this is a good start at
> > > dumping globals:
> > >
> > > foreach x [info globals ] {
> > >     set y [array get $x ]
> > >     if { 2 > [llength $y] } {
> > > puts "var: $x == [set $x]"
> > >     } else {
> > >         foreach {mutt jeff } $y {
> > >            puts [format "array: %s(%s) == %s" $x $mutt $jeff]
> > >         }
> > >     }
> > > }
> > >
> > > put this in its own name space, so it does not pollute the
> > > globals and you should be close, if you want html then
> > > add the proper bits.
> > >
> > > marc


0
soazine (387)
1/2/2004 11:56:31 PM
But I have to modify varTable else the entire proc will break because
$varTable will not locally exist.  Otherwise, how on earth do I return the
results of parsing through [info globals] to be seen by any TCL script
including this proc?  I'm not getting this!

Phil

"Bryan Oakley" <bryan@bitmover.com> wrote in message
news:WWlJb.146$W46.90191999@newssvr11.news.prodigy.com...
> Phil Powell wrote:
>
> > It's a great proc, Roy, but I have no clue as to how to use it
> > properly.  Consider my code:
> >
> >...
> >
> >  proc dumpGlobalVars {} {
> >   foreach var [info globals] { global $var }; # FORCE ALL VARS WITHIN
> > globals LIST TO EXIST WITHIN PROC CONSTRUCT (TCL EQUIV OF JAVA
> > "super")
>
> I missed this bit of code from an earlier post. This looks to be a Very
> Bad Idea. For example, two lines later you do "set varTable {}". If
> varTable happens to be a global variable your reporting procedure just
> modified a global variable. For that reason this doesn't look like a
> particularly good solution.
>
>


0
soazine (387)
1/3/2004 12:00:54 AM
My ultimate goal is very simple:

I'm required to come up with a command-line solution to file manipulation:
archiving/transferring/etc.  The company I work for does not want a
web-based solution for security reasons; they decided on a command-line
solution instead.

I don't do command-line stuff, I'm a web programmer.  So while having 4+
years of TCL experience (limited to Vignette) I have very little experience
having to do command-line anything except the occasional simple Unix stuff.

They want me to create a command-line script that is easy enough for the
receptionist to use w/o having to learn Unix and, again, no web-based
anything.  It should be a simple one-liner she enters and bango everything
is done.

So I created a front-end shell script that uses the "tclsh" command to run
various back-end TCL scripts.

1) transfer - will transfer 1+ files from one directory to another after
versioning the original file in the destination directory first -> this has
been already written by me, tested and signed off

2) archive - will archive 1+ files in any directory (or a default directory)
into a .tar.gz file and optionally delete the files.

There you go, the entire spec.

Phil
"David N. Welton" <davidw@dedasys.com> wrote in message
news:87hdzeosg7.fsf@dedasys.com...
> soazine@erols.com (Phil Powell) writes:
>
> > > You should know what global variables you have floating around,
> > > and there shouldn't be too many of them, either.
>
> > Not if you're doing web programming you won't.  That is why PHP
> > invented phpinfo(), for web developers like me who normally don't
> > have command-line practice to learn what global environmental
> > variables you have.
>
> If you use a system like Rivet ( http://tcl.apache.org/rivet/ ), all
> your "CGI" variables (the one that the user inputs) are not globals.
>
> You would use the 'var' command:
>
> http://tcl.apache.org/rivet/html/commands.en.html
>
> Something like:
>
> foreach {var val} [vars all] {
>         puts "Variable $var is set to $val <br>"
> }
>
> > I think it might help to know my background: I feel that all of you
> > are engineers and software developers.  I'm a web developer.
> > Basically the same as someone who speaks Swedish in a room of people
> > who speak Mongolian.
>
> I understand a thing or two about web programming, including, I hope,
> how to make it reasonably accessible to people who are not expert
> programmers.  I try at least:-)
>
> Tcl itself is pretty easy to get a handle on in a lot of ways.  Maybe
> I missed it, but did you mention what your ultimate goal with your
> project is?  Often, it's easier to give advice if you know what
> someone wants to achieve.
>
> -- 
> David N. Welton
>    Consulting: http://www.dedasys.com/
>      Personal: http://www.dedasys.com/davidw/
> Free Software: http://www.dedasys.com/freesoftware/
>    Apache Tcl: http://tcl.apache.org/


0
soazine (387)
1/3/2004 12:05:03 AM
I'm sorry, wrong spec..

I am trying to create the TCL equivalent of PHP's phpinfo(), where I can
view all of the global variables on the fly in my environment.  In PHP it's
a simple command (again, web programmers, such as myself, won't intuitively
know what our environmental variables are and prefer the comfort of a
web-based method to view them).  So that is what this whole crap does: show
all of my environmental variables and their values, plain and simple.

Phil

"Phil Powell" <soazine@erols.com> wrote in message
news:JInJb.62419$hf1.10625@lakeread06...
> My ultimate goal is very simple:
>
> I'm required to come up with a command-line solution to file manipulation:
> archiving/transferring/etc.  The company I work for does not want a
> web-based solution for security reasons; they decided on a command-line
> solution instead.
>
> I don't do command-line stuff, I'm a web programmer.  So while having 4+
> years of TCL experience (limited to Vignette) I have very little
experience
> having to do command-line anything except the occasional simple Unix
stuff.
>
> They want me to create a command-line script that is easy enough for the
> receptionist to use w/o having to learn Unix and, again, no web-based
> anything.  It should be a simple one-liner she enters and bango everything
> is done.
>
> So I created a front-end shell script that uses the "tclsh" command to run
> various back-end TCL scripts.
>
> 1) transfer - will transfer 1+ files from one directory to another after
> versioning the original file in the destination directory first -> this
has
> been already written by me, tested and signed off
>
> 2) archive - will archive 1+ files in any directory (or a default
directory)
> into a .tar.gz file and optionally delete the files.
>
> There you go, the entire spec.
>
> Phil
> "David N. Welton" <davidw@dedasys.com> wrote in message
> news:87hdzeosg7.fsf@dedasys.com...
> > soazine@erols.com (Phil Powell) writes:
> >
> > > > You should know what global variables you have floating around,
> > > > and there shouldn't be too many of them, either.
> >
> > > Not if you're doing web programming you won't.  That is why PHP
> > > invented phpinfo(), for web developers like me who normally don't
> > > have command-line practice to learn what global environmental
> > > variables you have.
> >
> > If you use a system like Rivet ( http://tcl.apache.org/rivet/ ), all
> > your "CGI" variables (the one that the user inputs) are not globals.
> >
> > You would use the 'var' command:
> >
> > http://tcl.apache.org/rivet/html/commands.en.html
> >
> > Something like:
> >
> > foreach {var val} [vars all] {
> >         puts "Variable $var is set to $val <br>"
> > }
> >
> > > I think it might help to know my background: I feel that all of you
> > > are engineers and software developers.  I'm a web developer.
> > > Basically the same as someone who speaks Swedish in a room of people
> > > who speak Mongolian.
> >
> > I understand a thing or two about web programming, including, I hope,
> > how to make it reasonably accessible to people who are not expert
> > programmers.  I try at least:-)
> >
> > Tcl itself is pretty easy to get a handle on in a lot of ways.  Maybe
> > I missed it, but did you mention what your ultimate goal with your
> > project is?  Often, it's easier to give advice if you know what
> > someone wants to achieve.
> >
> > -- 
> > David N. Welton
> >    Consulting: http://www.dedasys.com/
> >      Personal: http://www.dedasys.com/davidw/
> > Free Software: http://www.dedasys.com/freesoftware/
> >    Apache Tcl: http://tcl.apache.org/
>
>


0
soazine (387)
1/3/2004 12:11:09 AM
"Phil Powell" <soazine@erols.com> writes:

> 
> Sorry, I can't follow threads unless you do post to the top, unless you
> reference below, I never look there.
> 
> Phil

Sure you can, here is how you do it:
1: see article
2: assume there is something new to read in it
3: scroll down until you find it
4: at end of post stop.

If you choose not to do it that is your business,
but keep in mind that you are making it harder to 
get help for your problems by alienating part of 
your audience.  

marc
0
mspitze1 (98)
1/3/2004 12:12:25 AM
"Phil Powell" <soazine@erols.com> writes:

> So that is what this whole crap does: show all of my environmental
> variables and their values, plain and simple.

parray env

should do the trick.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/3/2004 12:16:11 AM
Phil Powell wrote:
> Sorry, I can't follow threads unless you do post to the top, unless you
> reference below, I never look there.

I guess that explains why you don't answer my questions; you never
scroll down far enough to read them.

Usenet may not be for you.  :(

-- 
| Don Porter          Mathematical and Computational Sciences Division |
| donald.porter@nist.gov             Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|
0
dgp1 (946)
1/3/2004 12:17:01 AM
"David N. Welton" <davidw@dedasys.com> wrote in message
news:877k09q434.fsf@dedasys.com...
> "Phil Powell" <soazine@erols.com> writes:
>
> > So that is what this whole crap does: show all of my environmental
> > variables and their values, plain and simple.
>
> parray env

Ok, this is what I told Roy as well.  That command is very cool and useful,
however, using it within the confines of controlled output is beyond me.
parray has its own "puts" embedded so you can't do this:

if {[array exists $var]} {
 puts "$var = ARRAY: "
 parray $var
}

Your output will not come out too nice as a result.  I know in PHP (yeah I
know you all are sick of hearing this but bear with me it's my background)
there is a way to suppress buffering of stdout temporarily to redirect
output somewhere else, so in TCL I would do something like (pseudo-code,
please don't take it too seriously)

if {[array exists $var]} {
 puts "$var = ARRAY: "
 fconfigure stdout -buffering 0
 set myPArray [parray $var]
 fconfigure stdout -buffering 1
 puts "\n$myPArray"
}

Phil

>
> should do the trick.
>
> -- 
> David N. Welton
>    Consulting: http://www.dedasys.com/
>      Personal: http://www.dedasys.com/davidw/
> Free Software: http://www.dedasys.com/freesoftware/
>    Apache Tcl: http://tcl.apache.org/


0
soazine (387)
1/3/2004 12:26:14 AM
"Phil Powell" <soazine@erols.com> writes:

> "David N. Welton" <davidw@dedasys.com> wrote in message
> news:877k09q434.fsf@dedasys.com...
> > "Phil Powell" <soazine@erols.com> writes:
> >
> > > So that is what this whole crap does: show all of my environmental
> > > variables and their values, plain and simple.
> >
> > parray env
> 
> Ok, this is what I told Roy as well.  That command is very cool and useful,
> however, using it within the confines of controlled output is beyond me.
> parray has its own "puts" embedded so you can't do this:
> 
> if {[array exists $var]} {
>  puts "$var = ARRAY: "
>  parray $var
> }

Well, so don't print it unless you need to.  If you want a snapshot of
it's value at a given point, just copy the elements to your own array
somewhere.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/3/2004 12:32:48 AM
"David N. Welton" <davidw@dedasys.com> wrote in message
news:873caxq3bg.fsf@dedasys.com...
> "Phil Powell" <soazine@erols.com> writes:
>
> > "David N. Welton" <davidw@dedasys.com> wrote in message
> > news:877k09q434.fsf@dedasys.com...
> > > "Phil Powell" <soazine@erols.com> writes:
> > >
> > > > So that is what this whole crap does: show all of my environmental
> > > > variables and their values, plain and simple.
> > >
> > > parray env
> >
> > Ok, this is what I told Roy as well.  That command is very cool and
useful,
> > however, using it within the confines of controlled output is beyond me.
> > parray has its own "puts" embedded so you can't do this:
> >
> > if {[array exists $var]} {
> >  puts "$var = ARRAY: "
> >  parray $var
> > }
>
> Well, so don't print it unless you need to.  If you want a snapshot of
> it's value at a given point, just copy the elements to your own array
> somewhere.
>

Will my earlier code and manipulation using fconfigure stdout ensure that?
Otherwise, I have no clue how to set the return of [parray $var] into an
array when it is set up to automatically go to stdout by the way the proc
parray is written in the first place.

Phil

> -- 
> David N. Welton
>    Consulting: http://www.dedasys.com/
>      Personal: http://www.dedasys.com/davidw/
> Free Software: http://www.dedasys.com/freesoftware/
>    Apache Tcl: http://tcl.apache.org/


0
soazine (387)
1/3/2004 12:33:51 AM
"Phil Powell" <soazine@erols.com> writes:

> "David N. Welton" <davidw@dedasys.com> wrote in message
> news:877k09q434.fsf@dedasys.com...
> > "Phil Powell" <soazine@erols.com> writes:
> >
> > > So that is what this whole crap does: show all of my environmental
> > > variables and their values, plain and simple.
> >
> > parray env
> 
> Ok, this is what I told Roy as well.  That command is very cool and useful,
> however, using it within the confines of controlled output is beyond me.
> parray has its own "puts" embedded so you can't do this:

first start off with:

man n array ; pay attention to get
man n foreach
man n puts
man n format

the rest should be simple

marc
0
mspitze1 (98)
1/3/2004 12:34:42 AM
(top posting to continue the trend *sigh*)

You return the results by picking a different approach. Several 
solutions have already been posted to this thread, some of them only a 
dozen lines or so long.

To put it simply, there is no way to declare every global variable 
automatically without running the risk of picking a local variable with 
the same name unless you know the names of all the global variables.

This is just a weak approach; pick something more foolproof.


Phil Powell wrote:

> But I have to modify varTable else the entire proc will break because
> $varTable will not locally exist.  Otherwise, how on earth do I return the
> results of parsing through [info globals] to be seen by any TCL script
> including this proc?  I'm not getting this!
> 
> Phil
> 
> "Bryan Oakley" <bryan@bitmover.com> wrote in message
> news:WWlJb.146$W46.90191999@newssvr11.news.prodigy.com...
> 
>>Phil Powell wrote:
>>
>>
>>>It's a great proc, Roy, but I have no clue as to how to use it
>>>properly.  Consider my code:
>>>
>>>...
>>>
>>> proc dumpGlobalVars {} {
>>>  foreach var [info globals] { global $var }; # FORCE ALL VARS WITHIN
>>>globals LIST TO EXIST WITHIN PROC CONSTRUCT (TCL EQUIV OF JAVA
>>>"super")
>>
>>I missed this bit of code from an earlier post. This looks to be a Very
>>Bad Idea. For example, two lines later you do "set varTable {}". If
>>varTable happens to be a global variable your reporting procedure just
>>modified a global variable. For that reason this doesn't look like a
>>particularly good solution.
>>
>>
> 
> 
> 

0
bryan1 (353)
1/3/2004 12:55:23 AM
Phil Powell wrote:

> I'm sorry, wrong spec..
> 
> I am trying to create the TCL equivalent of PHP's phpinfo(), where I can
> view all of the global variables on the fly in my environment.  In PHP it's
> a simple command (again, web programmers, such as myself, won't intuitively
> know what our environmental variables are and prefer the comfort of a
> web-based method to view them).  So that is what this whole crap does: show
> all of my environmental variables and their values, plain and simple.
> 

I'll post this solution again in case you missed it (it was originally 
named "f" after a series of illustrative procs named a-e). If you wish 
I'll annotate every line so you understand what is happening.

proc dumpGlobals {} {
	foreach var [lsort [info globals]] {
		if {[array exists ::$var]} {
			# variable is an array
			foreach element [lsort [array names ::$var]] {
				set varname "${var}($element)"
				puts "$varname = [set ::$varname]"
			}
		} else {
			# variable is a scaler
			puts "$var = [set ::$var]"
		}
	}
}


0
bryan1 (353)
1/3/2004 1:32:48 AM
Don Porter wrote:

> Phil Powell wrote:
> 
>>Sorry, I can't follow threads unless you do post to the top, unless you
>>reference below, I never look there.
> 
> 
> I guess that explains why you don't answer my questions; you never
> scroll down far enough to read them.

That must be it -- he didn't respond to lots of my posts either.

0
bryan1 (353)
1/3/2004 1:33:22 AM
Phil Powell wrote:

> I don't do command-line stuff, I'm a web programmer.  So while having 4+
> years of TCL experience (limited to Vignette) I have very little experience
> having to do command-line anything except the occasional simple Unix stuff.

If you learned Tcl through Vignette's educational system no wonder 
you're confused. They use a very odd implementation of Tcl and do a 
very, very bad job of teaching the language. I worked there for a couple 
years and was appalled at some of the things they taught.


0
bryan1 (353)
1/3/2004 1:35:41 AM
In article <JInJb.62419$hf1.10625@lakeread06>,
Phil Powell <soazine@erols.com> wrote:
>My ultimate goal is very simple:
>
>I'm required to come up with a command-line solution to file manipulation:
>archiving/transferring/etc.  The company I work for does not want a
>web-based solution for security reasons; they decided on a command-line
>solution instead.
			.
			.
			.
This task sounds to me like one you might wisely subcontract.

Perhaps my observation is biased; I do in fact regularly offer
my services for hire.  On the other hand, I can assure you that
I'd be better off financially turning down such work.

There's value in doing such work yourself.  There's also value--
in this case, I suspect it's greater--in taking advantage of *and
learning from* expertise.  Pay for the attention of a Tcl veteran,
then study his solution.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/3/2004 1:43:34 AM
In article <J7oJb.62428$hf1.28912@lakeread06>,
Phil Powell <soazine@erols.com> wrote:
>
>"David N. Welton" <davidw@dedasys.com> wrote in message
>news:873caxq3bg.fsf@dedasys.com...
>> "Phil Powell" <soazine@erols.com> writes:
>>
>> > "David N. Welton" <davidw@dedasys.com> wrote in message
>> > news:877k09q434.fsf@dedasys.com...
>> > > "Phil Powell" <soazine@erols.com> writes:
>> > >
>> > > > So that is what this whole crap does: show all of my environmental
>> > > > variables and their values, plain and simple.
>> > >
>> > > parray env
>> >
>> > Ok, this is what I told Roy as well.  That command is very cool and
>useful,
>> > however, using it within the confines of controlled output is beyond me.
>> > parray has its own "puts" embedded so you can't do this:
>> >
>> > if {[array exists $var]} {
>> >  puts "$var = ARRAY: "
>> >  parray $var
>> > }
>>
>> Well, so don't print it unless you need to.  If you want a snapshot of
>> it's value at a given point, just copy the elements to your own array
>> somewhere.
>>
>
>Will my earlier code and manipulation using fconfigure stdout ensure that?
>Otherwise, I have no clue how to set the return of [parray $var] into an
>array when it is set up to automatically go to stdout by the way the proc
>parray is written in the first place.
			.
			.
			.
No.  While I don't know what you want, your imaginative
invocation of [fconfigure] can't come close to it.

$var names a global array.  You want to "show" it (that's
a verb you've repeated), but you don't want to print it,
as [parray] does.  I'm catching on that "show" means some-
thing to you other than, "print to stdout", but I don't 
know what it is.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/3/2004 1:48:25 AM
In article <rOnJb.62420$hf1.42082@lakeread06>,
Phil Powell <soazine@erols.com> wrote:
			.
			.
			.
>view all of the global variables on the fly in my environment.  In PHP it's
>a simple command (again, web programmers, such as myself, won't intuitively
>know what our environmental variables are and prefer the comfort of a
>web-based method to view them).  So that is what this whole crap does: show
			.
			.
			.
I don't understand the putative distinction which labels
"web programmers".  I certainly am responsible for the
design, implementation, and deployment of Web applications
(sometimes even in PHP!), and I often dump out environment
variables.  Apparently I'm not a "web programmer", though,
and I just don't get a fair amount of what you're trying
to communicate.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/3/2004 1:55:12 AM
In article <N%oJb.181$4I2.108553489@newssvr11.news.prodigy.com>,
Bryan Oakley  <bryan@bitmover.com> wrote:
			.
			.
			.
>If you learned Tcl through Vignette's educational system no wonder 
>you're confused. They use a very odd implementation of Tcl and do a 
>very, very bad job of teaching the language. I worked there for a couple 
>years and was appalled at some of the things they taught.
>
>

There's a lot of stuff I don't understand.  Companies pay MILLIONS
(well, nowadays, many tens of thousands of dollars, and occasionally
as much as a million more) for "Content Management" and other
"Enterprise Solutions", some of which are, from all I can tell, 
positively harmful.  Some day I'd like to understand how this works.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/3/2004 1:59:30 AM
Cameron Laird wrote:
> 
> In article <N%oJb.181$4I2.108553489@newssvr11.news.prodigy.com>,
> Bryan Oakley  <bryan@bitmover.com> wrote:
>                         .
>                         .
>                         .
> >If you learned Tcl through Vignette's educational system no wonder
> >you're confused. They use a very odd implementation of Tcl and do a
> >very, very bad job of teaching the language. I worked there for a couple
> >years and was appalled at some of the things they taught.
> >
> >
> 
> There's a lot of stuff I don't understand.  Companies pay MILLIONS
> (well, nowadays, many tens of thousands of dollars, and occasionally
> as much as a million more) for "Content Management" and other
> "Enterprise Solutions", some of which are, from all I can tell,
> positively harmful.  Some day I'd like to understand how this works.
> --
> 
> Cameron Laird <claird@phaseit.net>
> Business:  http://www.Phaseit.net

http://www.guntheranderson.com/v/data/yagottro.htm

--
Les Cargill
0
lcargill (131)
1/3/2004 2:07:16 AM
On Fri, 2 Jan 2004, Phil Powell wrote:

> I am trying to create the TCL equivalent of PHP's phpinfo(), where I can
> view all of the global variables on the fly in my environment.  In PHP it's
> a simple command (again, web programmers, such as myself, won't intuitively
> know what our environmental variables are and prefer the comfort of a
> web-based method to view them).  So that is what this whole crap does: show
> all of my environmental variables and their values, plain and simple.

I'm not clear whether you want just your environment variables inherited
from the *nix shell (HOME, PATH, etc.), or whether you want to display
the value of each and every global variable within Tcl (such as auto_path,
tcl_version, tcl_platform, etc.)

If it is just to pretty-print all the environment variables, does this 
meet your needs?

    proc pretty-print-env {} {
        global env
        foreach var [lsort [array names env]] {
            append output "\n    env($var) = $env($var)"
        }
        return $output
    }

Michael

0
michael6504 (290)
1/3/2004 3:18:33 AM
claird@lairds.com (Cameron Laird) wrote in message news:<vvc8g2thfove29@corp.supernews.com>...
> In article <N%oJb.181$4I2.108553489@newssvr11.news.prodigy.com>,
> Bryan Oakley  <bryan@bitmover.com> wrote:
> 			.
> 			.
> 			.
> >If you learned Tcl through Vignette's educational system no wonder 
> >you're confused. They use a very odd implementation of Tcl and do a 
> >very, very bad job of teaching the language. I worked there for a couple 
> >years and was appalled at some of the things they taught.
> >
> >
> 
> There's a lot of stuff I don't understand.  Companies pay MILLIONS
> (well, nowadays, many tens of thousands of dollars, and occasionally
> as much as a million more) for "Content Management" and other
> "Enterprise Solutions", some of which are, from all I can tell, 
> positively harmful.  Some day I'd like to understand how this works.


Out of fairness two things:

1) Nearly everyone involved in Vignette are business-oriented
individuals, not necessarily hardcore programmers or engineers and so
look at more non-technical solutions with techincal solutions, if that
makes sense

2) They're getting away from TCL for J2EE which they feel is more
Enterprise-ready.

I hope that helps you understand my background and why as Cameron
stated I'm probably a bit more "opaque" to you guys than you are to
each other.

Phil
0
soazine (387)
1/3/2004 7:13:46 PM
Phil Powell wrote:

> Out of fairness two things:
> 
>...
> 
> 2) They're getting away from TCL for J2EE which they feel is more
> Enterprise-ready.

I'm curious, though this falls in the category of getting off topic... 
For at least 6 years, maybe more, Vignette has been "getting away from 
Tcl". Do they still have Tcl in the product or have they finally succeeded?

I never quite understood the rationale of removing the core of a product 
that help you build a $500M company (though I'm guessing revenues are 
likely more like half that now). I remember seeing a memo from a time 
when Vignette was only a year or two old where they were already talking 
about getting rid of Tcl.

Personally, I think if they hadn't hobbled Tcl and spoke down about it 
since day one they would have been much better off. Tcl is a darn near 
perfect language for content management IMO. What other conclusion could 
one draw given that Vignette built such a huge customer base with a Tcl 
based product and the fact that AOLServer seems to be a pretty good 
performer, too.




0
bryan1 (353)
1/3/2004 8:28:17 PM
Bryan Oakley <bryan@bitmover.com> writes:

> I'm curious, though this falls in the category of getting off
> topic... For at least 6 years, maybe more, Vignette has been
> "getting away from Tcl". Do they still have Tcl in the product or
> have they finally succeeded?

> I never quite understood the rationale of removing the core of a
> product that help you build a $500M company (though I'm guessing
> revenues are likely more like half that now). I remember seeing a
> memo from a time when Vignette was only a year or two old where they
> were already talking about getting rid of Tcl.

Because the web these days is pretty much only about Java and, to some
degree, PHP:-(

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/3/2004 8:31:01 PM
Bryan Oakley <bryan@bitmover.com> wrote in message news:<N%oJb.181$4I2.108553489@newssvr11.news.prodigy.com>...
> Phil Powell wrote:
> 
> > I don't do command-line stuff, I'm a web programmer.  So while having 4+
> > years of TCL experience (limited to Vignette) I have very little experience
> > having to do command-line anything except the occasional simple Unix stuff.
> 
> If you learned Tcl through Vignette's educational system no wonder 
> you're confused. They use a very odd implementation of Tcl and do a 
> very, very bad job of teaching the language. I worked there for a couple 
> years and was appalled at some of the things they taught.

I won't want to tell you then about the story about the requirement
for building a   store demo project where all of the code had to be
written "entirely in Story Server".  I still giggle when I think of
that one.

Phil
0
soazine (387)
1/3/2004 10:00:25 PM
"David N. Welton" <davidw@dedasys.com> wrote in message
news:87u13c6agl.fsf@dedasys.com...
> Bryan Oakley <bryan@bitmover.com> writes:
>
> > I'm curious, though this falls in the category of getting off
> > topic... For at least 6 years, maybe more, Vignette has been
> > "getting away from Tcl". Do they still have Tcl in the product or
> > have they finally succeeded?
>
> > I never quite understood the rationale of removing the core of a
> > product that help you build a $500M company (though I'm guessing
> > revenues are likely more like half that now). I remember seeing a
> > memo from a time when Vignette was only a year or two old where they
> > were already talking about getting rid of Tcl.
>
> Because the web these days is pretty much only about Java and, to some
> degree, PHP:-(
>

And to which I'm actually secretly eternally grateful!

Long Rule TCL and PHP!

Phil

> -- 
> David N. Welton
>    Consulting: http://www.dedasys.com/
>      Personal: http://www.dedasys.com/davidw/
> Free Software: http://www.dedasys.com/freesoftware/
>    Apache Tcl: http://tcl.apache.org/


0
soazine (387)
1/4/2004 9:54:13 PM
"Phil Powell" <soazine@erols.com> writes:

> > Because the web these days is pretty much only about Java and, to
> > some degree, PHP:-(

> And to which I'm actually secretly eternally grateful!
> 
> Long Rule TCL and PHP!

But with Tcl you can do pretty much everything that PHP does, plus
more:-)  And all with one language!

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/4/2004 10:08:36 PM
"David N. Welton" <davidw@dedasys.com> wrote in message
news:87y8sn4b9y.fsf@dedasys.com...
> "Phil Powell" <soazine@erols.com> writes:
>
> > > Because the web these days is pretty much only about Java and, to
> > > some degree, PHP:-(
>
> > And to which I'm actually secretly eternally grateful!
> >
> > Long Rule TCL and PHP!
>
> But with Tcl you can do pretty much everything that PHP does, plus
> more:-)  And all with one language!
>

Not quite.  There is no native TCL process for doing what PHP's phpinfo()
can do to provide the values of all global environmental variables to be
viewable via browser.  It can be done in TCL but it's not native to TCL core
to do so, at least not yet.  That is just one example.

My view is that TCL has one advantage over PHP in string manipulation being
so darned superior over everything else, and that it doesn't embed default
HTTP header information into stdout like what PHP does.

Phil

> -- 
> David N. Welton
>    Consulting: http://www.dedasys.com/
>      Personal: http://www.dedasys.com/davidw/
> Free Software: http://www.dedasys.com/freesoftware/
>    Apache Tcl: http://tcl.apache.org/


0
soazine (387)
1/5/2004 2:47:47 AM
"Phil Powell" <soazine@erols.com> writes:

> > But with Tcl you can do pretty much everything that PHP does, plus
> > more:-) And all with one language!

> Not quite.  There is no native TCL process for doing what PHP's
> phpinfo() can do to provide the values of all global environmental
> variables to be viewable via browser.  It can be done in TCL but
> it's not native to TCL core to do so, at least not yet.  That is
> just one example.

That is an advantage.  Instead of having to rely on something built
in, you can construct it yourself.  In the long run, it's better to
have the tools to create something than one version of the something
that they can create.  Of course if that something proves useful, it
might be included in tcllib, or the Tcl files that accompany Tcl.

> My view is that TCL has one advantage over PHP in string
> manipulation being so darned superior over everything else, and that
> it doesn't embed default HTTP header information into stdout like
> what PHP does.

Tcl is also faster and more flexible:-)

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/5/2004 9:35:24 AM
"Phil Powell" <soazine@erols.com> writes:

> 
> Not quite.  There is no native TCL process for doing what PHP's phpinfo()
> can do to provide the values of all global environmental variables to be
> viewable via browser.  It can be done in TCL but it's not native to TCL core
> to do so, at least not yet.  That is just one example.

umm does this really need to be in core:

proc phpinfo {} {
    puts "<table>"
    foreach {a b} [array get ::env ] {
	puts "<tr><td>$a</td><td>$b</td></tr>"
    }
    puts "</table>"
}

admittedly it could be embellished a bit.

> 
> My view is that TCL has one advantage over PHP in string manipulation being
> so darned superior over everything else, and that it doesn't embed default
> HTTP header information into stdout like what PHP does.

tcl has many advantages over php: scotty, tk, bwidget, tclthhpd, aolserver,
startpacks ...

php does 1 thing ok, tcl does may things well

marc
0
mspitze1 (98)
1/5/2004 8:26:52 PM
Marc Spitzer <mspitze1@optonline.net> writes:

> tcl has many advantages over php: scotty, tk, bwidget, tclthhpd,
> aolserver, starpacks ...

Not to toot my own horn, so to speak, but please do keep in mind the
work of the various Apache Tcl groups (mod_tcl, Rivet, and WebSH) when
you talk about Tcl's capabilities on the web.  A lot of people are
quite happy with Apache (more than %50 of the market), and like the
idea of a solution that works well with it.  To add a bit of blatant
horn-tooting, I think Rivet manages to equal PHP in terms of ease of
use for non-programmer types - meaning that it's easy to script a
simple dynamic page.

-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/
0
davidw (997)
1/5/2004 8:42:47 PM
In article <86k746kuoz.fsf@bogomips.optonline.net>,
Marc Spitzer  <mspitze1@optonline.net> wrote:
>"Phil Powell" <soazine@erols.com> writes:
>
>> 
>> Not quite.  There is no native TCL process for doing what PHP's phpinfo()
>> can do to provide the values of all global environmental variables to be
>> viewable via browser.  It can be done in TCL but it's not native to TCL core
>> to do so, at least not yet.  That is just one example.
>
>umm does this really need to be in core:
>
>proc phpinfo {} {
>    puts "<table>"
>    foreach {a b} [array get ::env ] {
>	puts "<tr><td>$a</td><td>$b</td></tr>"
>    }
>    puts "</table>"
>}
>
>admittedly it could be embellished a bit.
			.
			.
			.
I've exchanged correspondence with Phil outside clt, and I think I
understand his point.  I don't agree with it; perhaps I can still
help explain it.

From a Tcl standpoint, what he *really* wants is to save off an
HTMLized display of ::env now, but only include it in the stream
he returns to the browser at some later time.  I don't get the point
of that at all; as near as I can tell, he doesn't expect ::env to
change from "now" to "then", so I don't understand why he doesn't
use any of the half dozen data-dumpers that have already appeared
in this thread.

Let's assume, though, the requirement of "snapshotting" ::env for
later display.  In Tcl, I think this is most naturally done simply
by making a copy of the array.  Some languages have an atomic 
operation for this; an array can be assigned to a new array.  Cur-
rent Tcl makes it slightly more prolix:
  array set my_copy [array get ::env]

Part of what's been throwing us off all along is that PHP (like 
Perl) encourages what I regard as the lamentable idiom of redirec-
ting stdout.  Phil therefore conceived this as
  redirect stdout to a variable
  dump ::env to the redirected stdout
  restore stdout
  ...
  print variable to stdout
I leave to readers to judge how this compares to the
  copy ::env to my_copy
  ...
  prinv my_copy to stdout
I recommend.

As it turns out, Tcl *can* redirect stdout the way I think Phil
wants; I even did so about four weeks ago in code for production.
It's so rarely a good idea that I don't want to encourage it, 
though.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/5/2004 9:00:42 PM
In article <87wu86w2i7.fsf@dedasys.com>,
David N. Welton <davidw@dedasys.com> wrote:
			.
			.
			.
>idea of a solution that works well with it.  To add a bit of blatant
>horn-tooting, I think Rivet manages to equal PHP in terms of ease of
>use for non-programmer types - meaning that it's easy to script a
>simple dynamic page.
			.
			.
			.
'Everybody realize what a strong statement this is?  PHP is
supposed to be the absolute apex of ease-of-Web-scripting--yet
David says Rivet's just as good.

And I think he's right.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/5/2004 9:03:24 PM



According to Phil Powell <soazine@erols.com>:
:Basically for the exact same reason why we have phpinfo() in the PHP
:realm (see http://www.php.net/manual/en/function.phpinfo.php for more
:info), only for TCL.  I want a way of determining all global
:environmental variables in the environment that I'm in, like what
:$env(HOME) is for example, or something.

Note that there are two ways to interprete what you are asking here.

1. you literally say "global environmental variable" and reference
$env(HOME).

That array contains all global environment variables.  If you want
to know what they all are, you just work with the array:

$ man -s n array
Tcl                   Tcl Built-In Commands              array(n)
______________________________________________________________________

NAME
     array - Manipulate array variables

:
:
array names arrayName ?mode? ?pattern?
          Returns a list containing the names of all of the elements
          in the array that match pattern.  Mode may be one of -exact,
          -glob, or -regexp.  If specified, mode designates which
          matching rules to use to match pattern against the names of
          the elements in the array.  If not specified, mode defaults
          to -glob.  See the documentation for string match for infor-
          mation on glob style matching, and the documentation for
          regexp for information on regexp matching.  If pattern is
          omitted then the command returns all of the element names in
          the array.  If there are no (matching) elements in the
          array, or if arrayName isn't the name of an array variable,
          then an empty string is returned.



$ tclsh
% set lst [array names env]
MLDIR HISTFILE DTXSERVERLOCATION HOME BIN COLUMNS SDT_NO_APPGATHER LANG
HISTSIZE LOGNAME tclfaq GNUOS VISUAL wiki port HOST time
XRSH_ENVS_TO_PASS SHELL SunOS src DOMAIN HOSTS XMICONSEARCHPATH lcb
MAILMSG CPUTYPE ftp PRODPATH DTSOURCEPROFILE xrast DTSPSYSHELP LC_CTYPE
ECOLOR TERMINFO PRINTER ISH WMPHOME TZ SOUNDPATH
GNOME_DESKTOP_SESSION_ID SESSION_SVR USER SPELL MAILCHECK BCOLOR
MANPATH rast XUSERFILESEARCHPATH CONSOLE info DTSPSYSAPPHOSTS
SESSION_MANAGER HELPPATH lint u029 HELPDIR TMPDIR USERNAME PCEDIT
LWV_PROFILE HOMETERM OPENWINHOME ToolInfo OS udoc DTSPSYSICON
DTHELPSEARCHPATH lvirden CDPATH DTSCREENSAVERLIST PATH SESSIONTYPE
XCONFIGHOME _ PAGER LC_ALL EDITOR LD_LIBRARY_PATH sprs
DTDATABASESEARCHPATH DAYWK TTY PWD FPATH wikihist FMHOME FONTPATH
ORACLE_SQL snd EDIT VENDOR DISPLAY DAY ICONPATH DEBUG AB_CARDCATALOG
ICONDIR AB2_DEFAULTSERVER XMBINDDIR ENV PERLDOC ORACLE_FORM TMOUT
LOGIN_ENV gnu julian CLEARCASE_MAKE_COMPAT PS1 MM_USEPAGER PS2 HOMEPROC
WINDOWID VCAL HTML_TIDY PS3 doc RASTPATH PS4 HOSTNAME l

$ llength $lst
148

There's the number of entries in the array.

2. If, perchance, you really meant to say "the tcl variables within
a tcl interpreter, in the global name space", then I suspect subsequent
posters will help with that mission.
-- 
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >
0
lvirden272 (610)
1/7/2004 12:37:48 PM
According to Phil Powell <soazine@erols.com>:
:Not quite.  There is no native TCL process for doing what PHP's phpinfo()
:can do to provide the values of all global environmental variables to be
:viewable via browser.  It can be done in TCL but it's not native to TCL core
:to do so, at least not yet.  


Okay, when I take a look at http://us4.php.net/phpinfo I see the man
page for phpinfo.

It appears to be a simple output of general information.

Here's the info phpinfo outputs-  what steps would it take to create
a tcl proc to produce similar results:

Name (constant) Value Description
INFO_CONFIGURATION Current Local and Master values for PHP directives. See also ini_get().
INFO_CREDITS PHP 4 Credits. See also phpcredits().
INFO_ENVIRONMENT Environment Variable information that's also available in $_ENV.
INFO_GENERAL The configuration line, php.ini location, build date, Web Server, System and more.
INFO_LICENSE PHP License information. See also the license faq.
INFO_MODULES Loaded modules and their respective settings. See also get_loaded_modules().
INFO_VARIABLES Shows all predefined variables from EGPCS (Environment, GET, POST, Cookie, Server).
INFO_ALL Shows all of the above. This is the default value.

Let's see.

1. INFO_CONFIGURATION - I've no idea what local and master values are.  I
presume they have something to do with the way PHP configuration parameters.
What is the similar concept for Tcl?

2. INFO_CREDITS - the credit information for Tcl is not available in the
running interpreter.  

3. INFO_ENVIRONMENT - this is in tcl.  Just access the $env array - make use
of , for example, 
set envlist [array name env]
if you just want to get the names of the variables in a list
If you want to display all the names and the values of the environment
variables, just walk through the array like this:

foreach var [array names env] {
	puts "$var = $env($var)"
}

4. INFO_GENERAL - the closest thing to this is probably the info in 
the install directory/lib/tclConfig.sh file.

5. INFO_LICENSE - the licensing information for Tcl is not available in
the running interpreter.

5. INFO_MODULES - does the
package names
command provide sufficient info for this one?

6. INFO_VARIABLEs - I'm uncertain about this term and why it is different
from INFO_ENVIRONMENT ... perhaps it is equivalent to what variables are
in the global namespace when the tcl interpreter is started.
-- 
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >
0
lvirden272 (610)
1/7/2004 1:11:35 PM
According to Phil Powell <soazine@erols.com>:
:Thanx, however, this line makes no sense to me, could you please
:explain it in detail:
:
: foreach {mutt jeff } $y { 

Please note, the code that is confusing you expects two variables to be
set.  The first, y, is expected to be a list typically consisting of
two or more list elements.  The writer of this code expected the values
in list y to be an array element name and the array element value.
So, for example, one might have:

set y [list "HOME" "/home/lvirden" "PATH" "/bin:/usr/bin"]

The second variable is x, containing a string representing an array name.
In this example, for instance, x might be set:

set x "env"

foreach - a looping construct
In this particular line, it will go through the loop, assigning
the first list element of a pair to the tcl variable mutt and
the second to jeff. 

It is, basically, a shortcut for saying

set mutt [lindex $y 0]
set jeff [lindex $y 1]

and if y has more than 2 elements, then the second time through,
you get

set mutt [lindex $y 2]
set jeff [lindex $y 3]

and so forth.

:           puts [format "array: %s(%s) == %s" $x $mutt $jeff]

puts - produce output to , in this case, standard output
format - produce a string, formatted as specified in the first argument.
The first argument says: construct a string that has the constant
"array: " followed by the contents of the x variable (in my example the value
"env"), followed by a constant "(" followed by the contents of
the mutt variable (the value "HOME" the first time through the loop),
followed by the constant ") == " followed by the value of the jeff variable
(the value "/home/lvirden" the first time through the loop.

:        }
:
:
:I don't understand literally any of it. :(

The results of the original code, with my example setup, would be thus:

set x "env"
set y [list "HOME" "/home/lvirden" "PATH" "/bin:/usr/bin"]
foreach {mutt jeff } $y { 
           puts [format "array: %s(%s) == %s" $x $mutt $jeff]
}

array: env(HOME) == /home/lvirden
array: env(PATH) == /bin:/usr/bin
-- 
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >
0
lvirden272 (610)
1/7/2004 1:23:29 PM
In article <lh4Kb.69257$hf1.15018@lakeread06>,
Phil Powell <soazine@erols.com> wrote:
			.
			.
			.
>My view is that TCL has one advantage over PHP in string manipulation being
>so darned superior over everything else, and that it doesn't embed default
>HTTP header information into stdout like what PHP does.
			.
			.
			.
I want to understand this.

Phil, do you know you can use PHP as a fairly conventional
command-line processor with, for example, the -q command-
line flag?

For me, Tcl has at least a half-dozen distinct significant
technical advantages over PHP (Tk integration; superior
introspection--but am I just not acclimated to PHP 5's
Reflection yet?; ease of embedding/extending; ...).  One
I don't get, though, is "superior ... string manipulation".
What's an example of an operation on string data that you
find significantly easier in Tcl than PHP?
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
1/7/2004 11:39:39 PM
Phil Powell wrote:

> 
> My view is that TCL has one advantage over PHP in string manipulation being
> so darned superior over everything else, and that it doesn't embed default
> HTTP header information into stdout like what PHP does.
> 
> Phil
> 

Hi Phil,

take a look at websh, a Tcl implementation for web programming.
http://tcl.apache.org/websh/

Best regards

Ulrich


0
usus1 (11)
1/9/2004 11:51:25 AM
Reply:

Similar Artilces:

How to do PHP "require()" or TCL "source" in bash script
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone...

PHP equivalent of TCL command "subst"?
I need to find a PHP equivalent to a very familiar TCL command "subst" (see http://www.hume.com/html84/mann/subst.html ). This command will take a string and evaluate anything TCL inside of it and return values. for example, if this were my line: [TCL] set word {World} set line {Hello #word#} regsub -all {#([^#]+)#} $line {$$1} line return [subst $line] [/TCL] My return should be Hello World and not Hello #word# Nor Hello $word Because of a requirement for my app I am having to do the same kind of substitution variation, however, I am having to do it entirely in PHP. I don...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

tcl equivalent of perl "chop"
Is there an equivalent tcl command to perl's "chop" ? I would like to delete out the last character (not necessarily new line) off of a string. Is there an easy way to do this "chop" in tcl? Thanks Mahurshi Akilla wrote: > I would like to delete out the last character (not necessarily new > line) off of a string. % string replace foo end end fo -- | Don Porter Mathematical and Computational Sciences Division | | donald.porter@nist.gov Information Technology Laboratory | | http://math.nist.gov/~DPorter/ NIST | |______________________________________________________________________| Mahurshi Akilla schrieb: > I would like to delete out the last character (not necessarily new > line) off of a string. Is there an easy way to do this "chop" in > tcl? set v [string range $v 0 end-1] > Thanks At your pleasure ;-). Eckhard Actually, this one is the true "chop" clone: string trim string ?chars? Returns a value equal to string except that any leading or trailing characters from the set given by chars are removed. If chars is not specified then white space is removed (spaces, tabs, newlines, and carriage returns). string trimleft string ?chars? Returns a value equal to string except that any leading characters from the set given by chars are removed. If chars is not specified then white space is removed (spaces, tabs, newlines, and carriage ret...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Does it need a ";" at the very after of "if" and "for"
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if statement? marsarden said: > write code like: > > int main(void) > { > int a=10; > if(a<20) > {} > } > > Compiler ok on dev-cpp . don't we have to add a ";" after if > statement? The syntax for 'if' is: if(expression) statement There is no semicolon after the ) but before the statement. The statement is either a normal statement (which can be empty), ending in a semicolon:- if(expr) ...

Looking for binary "expect" and "TCL/Tk" (if required) for OpenServer6
Does anybody know where to find "expect" (and related requirements) for OpenServer6? I can download the source files from nist.gov, but they do not compile. The MAN pages are already loaded on the system, so I suspect the programs would be on the distribution media somewhere. Any help would be appreciated. Thanks, Rick On 9 Feb, 17:57, Rick_Hoyle <motosl...@hotmail.com> wrote: > Does anybody know where to find "expect" (and related requirements) > for OpenServer6? I can download the source files from nist.gov, but > they do not compile. The MAN pages are al...

How to open a pty from Tcl (or "please translate C example to Tcl")
Hello out there, still struggling with getting TCP/IP to work in my somewhat bizarre setup (TCP/IP over 10.000 Volt power-line modems) I got a hint to try to use a pseudo tty. I got the advice --- What you would do is write a small C program (or perl, or any of a number of other languages). This program would call the "openpty" function, which: - Locates the next available (unused) pseudo-TTY device in the system, - Opens both ends of it, into two different descriptors, - Returns the file-descriptor numbers for the two ends (the "slave" end which mimics a tty, and the master end that your program will be using as the intercept point), and the filename of the slave (e.g. "/dev/ptya0"). --- Q1: Any way I could accomplish this from Tcl? Well, knowing nothing about openpty and pseude ttys I hunted around and found the following code snippet: --- /* * Allocate pseudo tty, returns master side fd. * Stores slave name in the first arg(must be large enough). */ int pty_open(char *sl_name) { int mr_fd; char ptyname[] = "/dev/ptyXY"; char ch[] = "pqrstuvwxyz"; char digit[] = "0123456789abcdefghijklmnopqrstuv"; int l, m; /* This algorithm should work for almost all standard Unices */ for(l=0; ch[l]; l++ ) { for(m=0; digit[m]; m++ ) { ptyname[8] = ch[l]; ptyname[9] = digit[m]; /* Open the master */ if( (mr_fd=open(ptyname, O_RDWR)) < 0 ) continue...

Does Python have equivalent to MATLAB "varargin", "varargout", "nargin", "nargout"?
Thank you in advance for your response. Dmitrey openopt@ukr.net writes: > Thank you in advance for your response. And those do ... ? -- Jorge Godoy <jgodoy@gmail.com> Where you would use varargin and nargin in Matlab, you would use the *args mechanism in Python. Try calling def t1(*args): print args print len(args) with different argument lists Where you would use varargout and nargout in Matlab you would use tuple unpacking in Python. Play with this def t2(n): return tuple(range(n)) a, b = t2(2) x = t2(3) On Feb 18, 12:58 pm, open...@ukr.net wrote: > Th...

Using "source" vs "package require" for Tcl application files
I would like to divide my Tcl application into separate files. Should I generally use "source" to combine the files, or should I use the package mechanism (package provide, package require, etc.)? What is the generally accepted practice? Thanks, Gregg On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: > I would like to divide my Tcl application into separate files. Should I > generally use "source" to combine the files, or should I use the package > mechanism (package provide, package require, etc.)? > > What is the generally accepted practice? > > Thanks, > > Gregg IMHO use [source]. My reasoning: - The package mechanism is meant for getting access to general-purpose libraries, installed directly under the Tcl installation. - You talk of source files for your own application. So I would expect these files to reside in a directory containing that application. Then [source] is easier to use - and you guarantee that you get the source files from your application (otherwise a random package with the same name from the installation could interfer, if you are not careful with the library path) - Using [source] also makes it clear that these files are meant for your application only, not for more general purposes. Regards, Arjen Arjen Markus wrote: > On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: >> I would like to divide my Tcl application into separate files. Should I >> gen...

Is there a "DIGITAL" equivalent of "Q"?
Please note quotation marks in subject ;) Also, I'm not the oldest on group --- BUT my father operated a *LEGAL* land based spark gap xmtr All that to say that I think in "linear passive discrete" domain rather than in "digital" domain. I have a "filter" problem. I have a reasonable idea on how to implement it. *UNFORTUNATELY* requires HENRY's and FARADs ;/ I can write and solve the associated mesh equations My solution will obviously be a subset of SPICE BUT will I be able to describe either PROBLEM or SOLUTION to those educated in d...

"Vectors" in tcl?
Hi all, What is my "best" alternative in handling vectors in Tcl? ("best" as in using a package available in ActiveTcl. I know about VecTcl, but...) I want to use a vector (potentially large, as in half a million boolean values). If this vector is created with all zeros, and I want to turn some of them (I have their indices as a tcl list) to 1. Right now I am using a tcl list, but I need to loop over this list, and set each one to 1. And I was wondering if there is a faster way (as in doing it with a single tcl command). I was looking at the the math:...

TCL scripting or "dialer-watch" equivalent for GRE tunnels?
I've been fighting the crux of this problem for months, but I'll try to keep it short here. I need some advice. I have an MPLS network through my provider with about 20 sites. We are fully meshed. Most sites have a 2811 router and our routing protocol is OSPF. I cannot use EIGRP with my provider, which is a shame, because I think it would solve all my problems. I've installed a second router at some of my remote MPLS sites that have their own Internet connection. I want to use a GRE/IPSEC (or DMVPN) tunnel to backup the MPLS network with a tunnel back to Corporate. I have t...

"open with" tcl
hi, i just joined here today. have been reading and learning tcl/tk to help convert my VB6/MSwindows programs to tcl/tk on gnu/linux (debian , gnome). i have a tcl script that includes a text widget and menu and i can load, edit, save text files via the menu. but i would also like to start the tcl script and load a text file directly from the gnome file browser utility, using the "open with .... " option on the right mouse button. when i do "open with ...." and select the tcl script, the script starts up but the selected file does not load into the text widget. i understand that i'm missing a piece of the technology here, and any guidance would be appreciated. regards daveleo daveleo wrote: > hi, i just joined here today. > have been reading and learning tcl/tk to help convert my VB6/MSwindows > programs to tcl/tk on gnu/linux (debian , gnome). > > i have a tcl script that includes a text widget and menu and i can > load, edit, save text files via the menu. > but i would also like to start the tcl script and load a text file > directly from the gnome file browser utility, using the "open with .... > " option on the right mouse button. > > when i do "open with ...." and select the tcl script, the script > starts up but the selected file does not load into the text widget. You're going to have to figure out how Gnome is passing that information to your script. You could write a s...

TCL "subshell"
Hi, I'm working on a kind of simulator /debugger application for some special multiprocessor hardware. The application has a number of TCL commands which the user can use to drive it. I'd like to implement breakpoints where the user can register TCL scripts to be executed when the breakpoint event is encountered. I really wanted to run these scripts in a "sub-shell" of the TCL environment which runs the main application. The reason for this is I want to provide a number of environment variables which can be accessed by the "subshell" but do not make sense int he main shell - for instance, the break point script could ask which process the breakpoint occured on, or the line number/file, ( there are a number of different things here which would only make sense to those involved in the development of the hardware). My first attempt was to use Tcl_CreateSlave(), but this doesnt "inherit" the commands from the main shell so doesn't work for me - in particular, the scripts registered for the breakpoints are not available in the slave. Does this "subshell" idea which makes sense in TCL or am I flogging a dead horse? dave In article <T66dnUaDisWokVXVnZ2dnUVZ_ofinZ2d@comcast.com>, CockneyWinker <datownsend@comcast.net> wrote: >Hi, > >I'm working on a kind of simulator /debugger application for some special >multiprocessor hardware. >The application has a number of TCL commands which ...

"?" in Tcl regexp
Any one can explain why I can not match the character "?" in Expect: expect -re "bala bala\?" Thanks, Dao "Dao" <youdao_du@hotmial.com> wrote in message news:bgt790$aca$1@zcars0v6.ca.nortel.com... > Any one can explain why I can not match the character "?" in Expect: > expect -re "bala bala\?" Backslash substitution in the quoted string is taking away the backslash for you; so the regexp you are using is "bala bala?" Put the string in braces instead of quotes. -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 mail: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. "Dao" <youdao_du@hotmial.com> wrote: # Any one can explain why I can not match the character "?" in Expect: # expect -re "bala bala\?" Because it does backslash substitution before passing into expect? You can try {bala bala\?} or "bala bala\\?". -- Derk Gwen http://derkgwen.250free.com/html/index.html What kind of convenience store do you run here? ...

Question about "sprintf" "@" "do for"
Hello, this works: A1=3D1 A2=3D2 A3=3D3 i=3D1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari do for [i=3D1:3]{ vari=3Dsprintf("A%.f",i) print vari } But I want to have "print vari,"=3D",@vari" in the loop. But it dosen't=20 work. Why can't I use "print vari,"=3D",@vari" in the loop? Is there a=20 solution for? J=C3=B6rg Jörg ...

Gary Sokolich """"""
"""""""""" http://www.manta.com/c/mmlq5dm/w-gary-sokolich W Gary Sokolich 801 Kings Road Newport Beach, CA 92663-5715 (949) 650-5379 http://www.tbpe.state.tx.us/da/da022808.htm TEXAS BOARD OF PROFESSIONAL ENGINEERS February 28, 2008 Board Meeting Disciplinary Actions W. Gary Sokolich , Newport Beach, California �V File B-29812 - It was alleged that Dr. Sokolich unlawfully offered or attempted to practice engineering in Texas (...) Dr. Sokolich chose to end the proceedings by signing a Consent Order that was accepted by ...

Web resources about - TCL equivalent of PHP "phpinfo()"? - comp.lang.tcl

Resources last updated: 3/13/2016 8:07:37 PM