473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do you convert a TCL list into a string that PHP can read?

I have a TCL proc that needs to convert what might be a list into a
string to read

consider this:

[set string [PROPER_CASE {hello world}]]; # OUTPUTS Hello World which
is fine for PHP

[set string [PROPER_CASE {-hello world}]]; # OUTPUT {{-Hello}}
World, which PHP will print literally as {{-Hello}} World, instead of
-Hello World

Is there an easy way for TCL to brute-force a list into a
strictly-string-only format to prevent this potentially ugly display
from being displayed by PHP/etc.?

Thanx
Phil

Apr 21 '06 #1
23 9381
MH
In article <11**********************@e56g2000cwe.googlegroups .com>,
comp.lang.tcl <ph**************@gmail.com> wrote:
I have a TCL proc that needs to convert what might be a list into a
string to read

consider this:

[set string [PROPER_CASE {hello world}]]; # OUTPUTS Hello World which
is fine for PHP

[set string [PROPER_CASE {-hello world}]]; # OUTPUT {{-Hello}}
World, which PHP will print literally as {{-Hello}} World, instead of
-Hello World

Is there an easy way for TCL to brute-force a list into a
strictly-string-only format to prevent this potentially ugly display
from being displayed by PHP/etc.?


Not sure what "PROPER_CASE" does..

However, I think you want to look at the "join" command (you may need to call
it multiple times).

% set s "{{-Hello}} World"
{{-Hello}} World
% join $s
{-Hello} World
% join [join $s]
-Hello World

MH
Apr 21 '06 #2
comp.lang.tcl wrote:
I have a TCL proc that needs to convert what might be a list into a
string to read

consider this:

[set string [PROPER_CASE {hello world}]]; # OUTPUTS Hello World which
is fine for PHP

[set string [PROPER_CASE {-hello world}]]; # OUTPUT {{-Hello}}
World, which PHP will print literally as {{-Hello}} World, instead of
-Hello World

Is there an easy way for TCL to brute-force a list into a
strictly-string-only format to prevent this potentially ugly display
from being displayed by PHP/etc.?


To convert a list to a string with a space between each list element:

join $someList " "

So maybe you want:

[set string [join [PROPER_CASE ...] " "]
--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #3
comp.lang.tcl wrote:
I have a TCL proc that needs to convert what might be a list into a
string to read

consider this:

[set string [PROPER_CASE {hello world}]]; # OUTPUTS Hello World which
is fine for PHP

[set string [PROPER_CASE {-hello world}]]; # OUTPUT {{-Hello}}
World, which PHP will print literally as {{-Hello}} World, instead of
-Hello World

Is there an easy way for TCL to brute-force a list into a
strictly-string-only format to prevent this potentially ugly display
from being displayed by PHP/etc.?


The other replies here are right you may want to use join to "flatten"
your list. But I also think your [PROPER_CASE] proc is written wrongly
in that you intend it to return a string but instead it returns a list,
worse still a double nested list:

{
{
{
-Hello
}
}
World
}

which requires you to do [join] twice to flatten it out. I'd strongly
recommend that you look at the PROPER_CASE proc and correct the bug
there if it is under your control.

Of course, [join] only flattens a list by 1 level and since your list
is double nested you need to call [join] twice. But if you're not sure
how many levels deep your list is nested here's a small proc to
recursively flatten an arbitrarily nested list:

proc flatten {ls} {
set ret ""
foreach x $ls {
if {$x == "\{" || $x == "\}"} {
# handle braces:
lappend ret $x
} elseif {[llength $x] > 1} {
# recursively flatten sublist:
set ret [concat $ret [flatten $x]]
} else {
lappend ret $x
}
}
return $ret
}

So you can use it like:

set string [flatten [PROPER_CASE {-hello world}]]

Apr 21 '06 #4

sl*******@yahoo.com wrote:
comp.lang.tcl wrote:
I have a TCL proc that needs to convert what might be a list into a
string to read

consider this:

[set string [PROPER_CASE {hello world}]]; # OUTPUTS Hello World which
is fine for PHP

[set string [PROPER_CASE {-hello world}]]; # OUTPUT {{-Hello}}
World, which PHP will print literally as {{-Hello}} World, instead of
-Hello World

Is there an easy way for TCL to brute-force a list into a
strictly-string-only format to prevent this potentially ugly display
from being displayed by PHP/etc.?


The other replies here are right you may want to use join to "flatten"
your list. But I also think your [PROPER_CASE] proc is written wrongly
in that you intend it to return a string but instead it returns a list,
worse still a double nested list:

{
{
{
-Hello
}
}
World
}

which requires you to do [join] twice to flatten it out. I'd strongly
recommend that you look at the PROPER_CASE proc and correct the bug
there if it is under your control.

Of course, [join] only flattens a list by 1 level and since your list
is double nested you need to call [join] twice. But if you're not sure
how many levels deep your list is nested here's a small proc to
recursively flatten an arbitrarily nested list:

proc flatten {ls} {
set ret ""
foreach x $ls {
if {$x == "\{" || $x == "\}"} {
# handle braces:
lappend ret $x
} elseif {[llength $x] > 1} {
# recursively flatten sublist:
set ret [concat $ret [flatten $x]]
} else {
lappend ret $x
}
}
return $ret
}

So you can use it like:

set string [flatten [PROPER_CASE {-hello world}]]

Thanx for the proc, however, tclsh locks up tight, bringing down PHP
and Apache and all web services in the process, if you try this:

set string [flatten [PROPER_CASE {{-hello} {world}}]]

If you have a string with curly braces and a dash, it blows up. Take
one or the other away, all is well.

Phil

Apr 21 '06 #5
comp.lang.tcl wrote:
Thanx for the proc, however, tclsh locks up tight, bringing down PHP
and Apache and all web services in the process, if you try this:

set string [flatten [PROPER_CASE {{-hello} {world}}]]

If you have a string with curly braces and a dash, it blows up. Take
one or the other away, all is well.


"it blows up" does nothing to help us figure out the problem. Do you get
any sort of tcl error you can show us, either on the web page or in a
log? It really sounds like your problem is that PROPER_CASE is buggy,
and/or it is improperly documented.

Would it be possible for you to show us the result of the following command?
[list PROPER_CASE [info args PROPER_CASE] [info body PROPER_CASE]]


--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #6

Bryan Oakley wrote:
comp.lang.tcl wrote:
Thanx for the proc, however, tclsh locks up tight, bringing down PHP
and Apache and all web services in the process, if you try this:

set string [flatten [PROPER_CASE {{-hello} {world}}]]

If you have a string with curly braces and a dash, it blows up. Take
one or the other away, all is well.
"it blows up" does nothing to help us figure out the problem.


Sorry, there is no further description I can give you. tclsh locks,
produces 100% CPU usage when you view via top, no error logs of any
kind.

Here is PROPER_CASE:

[TCL]
################################################## #####################################
#

# Proc PROPER_CASE - this proc will convert string text into "marquee"
style
# by displaying its "proper case" (or in this case: "Proper Case").
The
# first letter of each word is capitalized except for small words
(yet,
# small words are capitalized if they are the first word in the text).

# Special capitalization consideration is taken for common ethnic
words,
# hyphenated words, and words adjoined by underscores. Also
consideration is
# taken for words surrounded by non-alphabetic characters (updated
7/10/2000)
#

# UPDATE 11/21/00: Exemptions within the phrase are now accepted
within
# PROPER_CASE to allow for words within phrases to not be capitalized.

#

# SYNTAX: set myPhrase [PROPER_CASE $myPhrase] {for all words}

# set myPhrase [PROPER_CASE -exempt[list of exempted words]
-- $myPhrase]
#
# IMPORTANT: If you include a list of words to be exempted you MUST
include the
# following:
#
# -exempt : This flag indicates an exemption list is to
follow
# -- : End of exemption list
#
# Without including "-exempt" before your exemption list
there will be no
# words to exempt; without including "--" it cannot deduce
the end of the
# exemption list and this proc will return an empty string.
#

# Written by Phil Powell. All rights reserved. on 2/14/00, updated
7/10/00, 11/21/00
#
################################################## ####################################
proc PROPER_CASE {args} {
set lb [format %c 91]; set rb [format %c 93]; set bslash [format %c
92]
lappend statesList AL AK AR AZ CA CO CT DE DC FL GA HI ID IL IN IA KS
KY LA ME MD MA
lappend statesList MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA
RI SC SD TN TX
lappend statesList UT VT VA WA WV WI WY PR GU VI
lappend directionsList NE NW SE SW N.E. S.E. S.W. N.W.
set exemptFlag {}; set exemptHash {}; set phrase {}
if {[regexp -nocase -- "-exempt" [lindex $args 0]]} {
set exemptFlag [lindex $args 0]
set i 1
if {[lsearch -exact $args "--"] < 0} {set exemptFlag {}}
if {[string length $exemptFlag] > 0} {
while {![regexp -- "--" [lindex $args $i]]} {
lappend exemptList "[lindex $args $i]"
incr i
}
set exemptHash [lindex $args $i]
set phrase [lindex $args [expr {$i + 1}]]
}
} else {
set phrase [lindex $args 0]
}
regsub -all {"} $phrase "%1%" phrase
regsub -all "$bslash[set lb](.*)$bslash$rb" $phrase "%2%[set
bslash]1%2%" phrase
lappend smallWords a an in of
lappend exemptionVars statesList directionsList
if {[string length $exemptFlag] > 0 && [string length $exemptHash] > 0
&& [info exists exemptList]} {
lappend exemptionVars exemptList
}
for {set i 0} {$i < [llength $phrase]} {incr i} {
set word [lindex $phrase $i]
set isExempted 0
foreach smallWord $smallWords {
if {$smallWord == $word && $i > 0} { set isExempted 1 }
}
if {$word == [string toupper $word] && !$isExempted} {set isExempted
1}
if {!$isExempted} {
foreach exemptionVar $exemptionVars {
if {[lsearch -exact [set $exemptionVar] "$word"] >=0} {set
isExempted 1}
}
}

if {!$isExempted} {

foreach char "- _" {

set foundChar 0
if {[regexp -- "$char" $word]} {
set word [split $word "$char"]
set foundChar 1
}

for {set j 0} {$j < [llength $word]} {incr j} {
set wordlet [lindex $word $j]
set beginIndx 0; set nonWord {}
while {![regexp -nocase {[a-z]} [string index $wordlet $beginIndx]]}
{
append nonWord [string index $wordlet $beginIndx]
incr beginIndx
}
### Check to see if word is "Scots/Irish" but > 2 chars
set tinyWord 0; set letter {}
if {[expr [string length $wordlet] - [string length $nonWord]] <
3} {
### Avoid setting of string range > 1 if word < 2 chars
set tinyWord 1
set endIndx [expr [string length $wordlet] - 1]
} else {
set endIndx [expr [string length $nonWord] + 1]
}
set snippet [string tolower [string range $wordlet $beginIndx
$endIndx]]
if {!$tinyWord} {
set letter [string index $wordlet [expr 2 + [string length
$nonWord]]]
if {($snippet == "mc" || $snippet == "o'")} {
set letter [string toupper $letter]
}
}

set tempsnippet "$nonWord[string toupper [string index $snippet
0]]"
if {$endIndx > 0} {
append tempsnippet [string index $snippet 1]
}
set snippet $tempsnippet

set tempwordlet $snippet$letter
if {!$tinyWord} {
append tempwordlet [string range $wordlet [expr 3 + [string
length $nonWord]] end]
}
set wordlet $tempwordlet

set word [lreplace $word $j $j $wordlet]
}; # end of "j" for loop

if {$foundChar} {
set word [join $word "$char"]
}
}; # End of foreach

set phrase [lreplace $phrase $i $i $word]
}; # end of "if {!$isExempted}"

}; # end of outer for loop
regsub -all "%1%" $phrase {"} phrase
regsub -all "%2%(.*)%2%" $phrase "$lb[set bslash]1$rb" phrase
return $phrase
}
[/TCL]

Do you get any sort of tcl error you can show us, either on the web page or in a
log? It really sounds like your problem is that PROPER_CASE is buggy,
and/or it is improperly documented.

Would it be possible for you to show us the result of the following command?

[list PROPER_CASE [info args PROPER_CASE] [info body PROPER_CASE]]


--
Bryan Oakley
http://www.tclscripting.com


Apr 21 '06 #7
comp.lang.tcl wrote:
Sorry, there is no further description I can give you. tclsh locks,
produces 100% CPU usage when you view via top, no error logs of any
kind.

Here is PROPER_CASE:
<snip>


Holy cow! All that just to change the case of words in a string?

The proc is a bit buggy at first glance. It's amazing it works at all.
It takes a string, does some string operations on it, then iterates over
it as if it were a list and performs list operations on it. Then, it
takes the list, performs string operations on it and returns a string.

Indeed, testing it out by copying it into a tclsh session, it _is_
buggy. If the first char is "-" it gets in an infinite loop.

Maybe you should file a bug with whomever wrote PROPER_CASE instead of
trying to work around its limitations.

--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #8
Bryan Oakley wrote:
comp.lang.tcl wrote:
Sorry, there is no further description I can give you. tclsh locks,
produces 100% CPU usage when you view via top, no error logs of any
kind.

Here is PROPER_CASE:
<snip>


Holy cow! All that just to change the case of words in a string?

The proc is a bit buggy at first glance. It's amazing it works at all.
It takes a string, does some string operations on it, then iterates over
it as if it were a list and performs list operations on it. Then, it
takes the list, performs string operations on it and returns a string.

Indeed, testing it out by copying it into a tclsh session, it _is_
buggy. If the first char is "-" it gets in an infinite loop.

Maybe you should file a bug with whomever wrote PROPER_CASE instead of
trying to work around its limitations.


It does a *little* more than [string totitle $string] -- it ignores two
letter state "names" -- but not much.

My guess is this is a "translation" of a procedure from another language by
someone who does not have a good knowledge of Tcl.

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
Apr 21 '06 #9

Gerald W. Lester wrote:
Bryan Oakley wrote:
comp.lang.tcl wrote:
Sorry, there is no further description I can give you. tclsh locks,
produces 100% CPU usage when you view via top, no error logs of any
kind.

Here is PROPER_CASE:
<snip>
Holy cow! All that just to change the case of words in a string?

The proc is a bit buggy at first glance. It's amazing it works at all.
It takes a string, does some string operations on it, then iterates over
it as if it were a list and performs list operations on it. Then, it
takes the list, performs string operations on it and returns a string.

Indeed, testing it out by copying it into a tclsh session, it _is_
buggy. If the first char is "-" it gets in an infinite loop.

Maybe you should file a bug with whomever wrote PROPER_CASE instead of
trying to work around its limitations.


It does a *little* more than [string totitle $string] -- it ignores two
letter state "names" -- but not much.


Last I checked [string totitle] doesn't capitalize hyphenated names,
Scots/Irish/Dutch names, etc. I wrote it back in 2000, when I only had
about a year's knowledge of TCL at the time, I'm sure it needs a bit of
fine-tuning, but it does the job it's supposed to do.

Phil
My guess is this is a "translation" of a procedure from another language by
someone who does not have a good knowledge of Tcl.

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+


Apr 21 '06 #10
Bryan Oakley wrote:
Maybe you should file a bug with whomever wrote PROPER_CASE instead of
trying to work around its limitations.


FWIW, the culprit is this infinite loop:

while {![regexp -nocase {[a-z]} [string index $wordlet $beginIndx]]} {
append nonWord [string index $wordlet $beginIndx]
incr beginIndx
}

Under the right conditions (such as a word beginning or ending with "-"
or "_"), $wordlet will be null. When wordlet is null, [string index
$wordlet $beginIndx] will be null for all values of $beginIndx, the
regexp will never match, and the loop will never terminate.

--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #11
comp.lang.tcl wrote:
Last I checked [string totitle] doesn't capitalize hyphenated names,
Scots/Irish/Dutch names, etc. I wrote it back in 2000, when I only had
about a year's knowledge of TCL at the time, I'm sure it needs a bit of
fine-tuning, but it does the job it's supposed to do.

Phil


It's pretty fragile though. As I pointed out in another message in this
thread, it can get into an infinite loop if a word begins or ends with
"-" or "_". It also will yield unexpected results for other types of
input as well. So, it really only works for a small set of well behaved
inputs.

We can help you with those problems if you like.

Not sure what to do about the OP, other than to suggest perhaps writing
their own PROPER_CASE proc or help to debug this one. There appears to
be no good way to solve his/her problem other than to fix PROPER_CASE.

--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #12

Bryan Oakley wrote:
Bryan Oakley wrote:
Maybe you should file a bug with whomever wrote PROPER_CASE instead of
trying to work around its limitations.

FWIW, the culprit is this infinite loop:

while {![regexp -nocase {[a-z]} [string index $wordlet $beginIndx]]} {
append nonWord [string index $wordlet $beginIndx]
incr beginIndx
}


WOW! I would never have found that one, you are truly one of the TCL
gurus out there (you came highly recommended by those I know)

this seemed to have fixed the problem (probably overkill but it was the
best I could think up at the moment:

while {[info exists wordlet] && [string length $wordlet] > 0 &&
![regexp -nocase {[a-z]} [string index $wordlet $beginIndx]]} {
append nonWord [string index $wordlet $beginIndx]
incr beginIndx
}

Phil

Under the right conditions (such as a word beginning or ending with "-"
or "_"), $wordlet will be null. When wordlet is null, [string index
$wordlet $beginIndx] will be null for all values of $beginIndx, the
regexp will never match, and the loop will never terminate.

--
Bryan Oakley
http://www.tclscripting.com


Apr 21 '06 #13
comp.lang.tcl wrote:

WOW! I would never have found that one, you are truly one of the TCL
gurus out there (you came highly recommended by those I know)
Thanks for the compliment but finding it took two minutes. I simply put
a print statement at the top of every loop, then tried a couple of very
obvious tests.
this seemed to have fixed the problem (probably overkill but it was the
best I could think up at the moment:

while {[info exists wordlet] && [string length $wordlet] > 0 &&
![regexp -nocase {[a-z]} [string index $wordlet $beginIndx]]} {
append nonWord [string index $wordlet $beginIndx]
incr beginIndx
}


Yeah, that definitely helps that particular problem but it doesn't fix
all problems in the code.

Since you seem new to programming, you might want to look at tcltest.
Once you are up to speed on it (which doesn't take long), it would take
about 5-10 minutes to craft a couple dozen tests to validate the proc
against a whole range of inputs. That would have uncovered many bugs.

http://mini.net/tcl/tcltest
--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #14
comp.lang.tcl wrote:
Gerald W. Lester wrote:
Bryan Oakley wrote:
comp.lang.tcl wrote:
> Sorry, there is no further description I can give you. tclsh locks,
> produces 100% CPU usage when you view via top, no error logs of any
> kind.
>
> Here is PROPER_CASE:
> <snip>

Holy cow! All that just to change the case of words in a string?

The proc is a bit buggy at first glance. It's amazing it works at all.
It takes a string, does some string operations on it, then iterates over
it as if it were a list and performs list operations on it. Then, it
takes the list, performs string operations on it and returns a string.

Indeed, testing it out by copying it into a tclsh session, it _is_
buggy. If the first char is "-" it gets in an infinite loop.

Maybe you should file a bug with whomever wrote PROPER_CASE instead of
trying to work around its limitations.


It does a *little* more than [string totitle $string] -- it ignores two
letter state "names" -- but not much.


Last I checked [string totitle] doesn't capitalize hyphenated names,
Scots/Irish/Dutch names, etc. I wrote it back in 2000, when I only had
about a year's knowledge of TCL at the time, I'm sure it needs a bit of
fine-tuning, but it does the job it's supposed to do.


You should factor out some of the code in there. Not because it is
faster, or to make the code re-usable or even to save memory but simply
to make it easier to understand. Here's a work-alike version I whipped
up in about 2 minutes:

######
# Reformats a string to have proper case
######
proc properCase {str} {
set ret ""
foreach x [split $str " \t\n\r"] {
append ret "[caseFormat [string trim $x]]"
append ret " "
}
return $ret
}

########
# Applies case formatting rule to a word
########
proc caseFormat {word} {
if {[set ret [irishScotFormat $word]] != ""} {
return $ret
}
if {[set ret [smallWordFormat $word]] != ""} {
return $ret
}
if {[set ret [statesFormat $word]] != ""} {
return $ret
}
return [string totitle $word [firstAlpha $word] end]
}

# Returns first alpha char in a word
proc firstAlpha {word} {
for {set i 0} {$i < [string length $word]} {incr i} {
if {[string is alpha [string index $word $i]]} {
return $i
}
}
return end
}

################ Formatting rules:

proc smallWordFormat {word} {
if {[lsearch -exact {
a an in of and at is
} $word] != -1} {
return $word
}
return ""
}

proc irishScotFormat {word} {
return ""
}

proc statesFormat {word} {
set word [string toupper $word]
if {[lsearch -exact {
AL AK AR AZ CA CO CT DE DC FL GA
HI ID IL IN IA KS KY LA ME MD MA
MI MN MS MO MT NE NV NH NJ NM NY
NC ND OH OK OR PA RI SC SD TN TX
UT VT VA WA WV WI WY PR GU VI NE
NW SE SW N.E. S.E. S.W. N.W.
} $word] != -1} {
return $word
}
return ""
}
I haven't implemented the irishScotFormat proc partly because I'm not
sure what you want and partly because I'm too lazy to do it. Notice
that the bulk of the processing happens in caseFormat which only have
to handle a single word at a time. This simplifies the properCase proc
to simply parse the string a word at a time without having to worry
about the processing. It's also very easy to add in more formatting
checks in the caseFormat proc.

Hope this helps you a little, I just had to re-implement it, the
[PROPER_CASE] proc was too ugly for me to resist.

Apr 21 '06 #15
sl*******@yahoo.com wrote:
comp.lang.tcl wrote:
Gerald W. Lester wrote:
Bryan Oakley wrote:
> comp.lang.tcl wrote:
>> Sorry, there is no further description I can give you. tclsh locks,
>> produces 100% CPU usage when you view via top, no error logs of any
>> kind.
>>
>> Here is PROPER_CASE:
>> <snip>
>

It does a *little* more than [string totitle $string] -- it ignores two
letter state "names" -- but not much.


Last I checked [string totitle] doesn't capitalize hyphenated names,
Scots/Irish/Dutch names, etc.


Oops, forgot about another thing the original code did. Add this rule
to the code I previously submitted:

proc uppercaseFormat {word} {
if {[string toupper $word] == $word} {return $word}
return ""
}

Apr 21 '06 #16

Bryan Oakley wrote:
comp.lang.tcl wrote:

WOW! I would never have found that one, you are truly one of the TCL
gurus out there (you came highly recommended by those I know)
Thanks for the compliment but finding it took two minutes. I simply put
a print statement at the top of every loop, then tried a couple of very
obvious tests.


Right, I do the same with PHP, using print_r() everywhere I go, but I
don't know how to do that with TCL especially in the environment I have
here at work (RHEL4)
this seemed to have fixed the problem (probably overkill but it was the
best I could think up at the moment:

while {[info exists wordlet] && [string length $wordlet] > 0 &&
![regexp -nocase {[a-z]} [string index $wordlet $beginIndx]]} {
append nonWord [string index $wordlet $beginIndx]
incr beginIndx
}


Yeah, that definitely helps that particular problem but it doesn't fix
all problems in the code.

Since you seem new to programming,


Sorry, I'm not new, I've been at it since 1996. Web programming that
is. Done TCL since 1999. I just don't have the means of testing my
TCL procs apart from using Wish on my very slow home PC (I use Linux at
work, haven't yet found an environment I can use to test TCL procs at
work and don't have root access to my machine even if I were to find
something).

you might want to look at tcltest. Once you are up to speed on it (which doesn't take long), it would take
about 5-10 minutes to craft a couple dozen tests to validate the proc
against a whole range of inputs. That would have uncovered many bugs.

http://mini.net/tcl/tcltest
--
Bryan Oakley
http://www.tclscripting.com


Apr 21 '06 #17
comp.lang.tcl wrote:
Sorry, I'm not new, I've been at it since 1996. Web programming that
is. Done TCL since 1999. I just don't have the means of testing my
TCL procs apart from using Wish on my very slow home PC (I use Linux at
work, haven't yet found an environment I can use to test TCL procs at
work and don't have root access to my machine even if I were to find
something).


That's an odd statement. If you have the ability to edit and run them,
you can test them. tcltest is 100% pure tcl. In fact, if you can run
them via your web server, you can run tests *in* your webserver. Just
drop the tcltest source code wherever you can access it (read: in the
same file or directory where PROPER_CASE is defined) and off you go. Of
course, you can also test them via tclsh if you have that available.

As for testing them at home, I bet even the slowest PC you can find that
is still running is sufficient to run tcltest for a modest number of tests.

I don't mean to be telling you how to work. It's just that these errors
were so trivial to reproduce that it seemed like a beginners mistake. No
offense. I just didn't think you were aware of some of the options
available to you.

--
Bryan Oakley
http://www.tclscripting.com
Apr 21 '06 #18
MH
In article <11**********************@u72g2000cwu.googlegroups .com>,
comp.lang.tcl <ph**************@gmail.com> wrote:

Bryan Oakley wrote:
comp.lang.tcl wrote:
>
> WOW! I would never have found that one, you are truly one of the TCL
> gurus out there (you came highly recommended by those I know)
Thanks for the compliment but finding it took two minutes. I simply put
a print statement at the top of every loop, then tried a couple of very
obvious tests.


Right, I do the same with PHP, using print_r() everywhere I go, but I
don't know how to do that with TCL especially in the environment I have
here at work (RHEL4)


Hmm.. Shouldn't "tclsh" be standard in that environment?

[cut]
Sorry, I'm not new, I've been at it since 1996. Web programming that
is. Done TCL since 1999. I just don't have the means of testing my
TCL procs apart from using Wish on my very slow home PC (I use Linux at
work, haven't yet found an environment I can use to test TCL procs at
work and don't have root access to my machine even if I were to find
something).


I downloaded and compiled tcl on my work machine (even though we use Tcl
extensively and already have several copies of tclsh installed) and intalled
it on my user account. Took all of 30 seconds of configuration to tell it to
install to my home directory, instead of the system directory..

../configure --prefix=/home/mydir/apps
make
make install

MH
Apr 21 '06 #19

MH wrote:
In article <11**********************@u72g2000cwu.googlegroups .com>,
comp.lang.tcl <ph**************@gmail.com> wrote:

Bryan Oakley wrote:
comp.lang.tcl wrote:
>
> WOW! I would never have found that one, you are truly one of the TCL
> gurus out there (you came highly recommended by those I know)

Thanks for the compliment but finding it took two minutes. I simply put
a print statement at the top of every loop, then tried a couple of very
obvious tests.


Right, I do the same with PHP, using print_r() everywhere I go, but I
don't know how to do that with TCL especially in the environment I have
here at work (RHEL4)


Hmm.. Shouldn't "tclsh" be standard in that environment?

[cut]
Sorry, I'm not new, I've been at it since 1996. Web programming that
is. Done TCL since 1999. I just don't have the means of testing my
TCL procs apart from using Wish on my very slow home PC (I use Linux at
work, haven't yet found an environment I can use to test TCL procs at
work and don't have root access to my machine even if I were to find
something).


I downloaded and compiled tcl on my work machine (even though we use Tcl
extensively and already have several copies of tclsh installed) and intalled
it on my user account. Took all of 30 seconds of configuration to tell it to
install to my home directory, instead of the system directory..

./configure --prefix=/home/mydir/apps
make
make install

MH


I have tclsh already on my machine here at work (Linux) so I don't have
to install it.

I read the man pages for tcltest but it's beyond me, sorry. I don't
know how to download it, where to find it (yes did a Google search,
didn't help whatsoever for me), what to do, etc.

I need a "3rd grade" step-by-step instruction to what to do.

Phil

Apr 21 '06 #20
MH
In article <11**********************@g10g2000cwb.googlegroups .com>,
comp.lang.tcl <ph**************@gmail.com> wrote:

MH wrote:
In article <11**********************@u72g2000cwu.googlegroups .com>,
comp.lang.tcl <ph**************@gmail.com> wrote:
>
>Bryan Oakley wrote:
>> comp.lang.tcl wrote:
>> >
>> > WOW! I would never have found that one, you are truly one of the TCL
>> > gurus out there (you came highly recommended by those I know)
>>
>> Thanks for the compliment but finding it took two minutes. I simply put
>> a print statement at the top of every loop, then tried a couple of very
>> obvious tests.
>>
>
>Right, I do the same with PHP, using print_r() everywhere I go, but I
>don't know how to do that with TCL especially in the environment I have
>here at work (RHEL4)


Hmm.. Shouldn't "tclsh" be standard in that environment?

[cut]
>Sorry, I'm not new, I've been at it since 1996. Web programming that
>is. Done TCL since 1999. I just don't have the means of testing my
>TCL procs apart from using Wish on my very slow home PC (I use Linux at
>work, haven't yet found an environment I can use to test TCL procs at
>work and don't have root access to my machine even if I were to find
>something).


I downloaded and compiled tcl on my work machine (even though we use Tcl
extensively and already have several copies of tclsh installed) and intalled
it on my user account. Took all of 30 seconds of configuration to tell it to
install to my home directory, instead of the system directory..

./configure --prefix=/home/mydir/apps
make
make install

MH


I have tclsh already on my machine here at work (Linux) so I don't have
to install it.

I read the man pages for tcltest but it's beyond me, sorry. I don't
know how to download it, where to find it (yes did a Google search,
didn't help whatsoever for me), what to do, etc.


Sorry 'bout that. You said you didn't have the environment to test your TCL
procs, so I read that you mean you didn't have tclsh..

I've never used tcltest, so I'm no help there..

MH
Apr 22 '06 #21
In article <gL******************@newssvr27.news.prodigy.net >,
Bryan Oakley <oa****@bardo.clearlight.com> wrote:
comp.lang.tcl wrote:
Sorry, I'm not new, I've been at it since 1996. Web programming that
is. Done TCL since 1999. I just don't have the means of testing my
TCL procs apart from using Wish on my very slow home PC (I use Linux at
work, haven't yet found an environment I can use to test TCL procs at
work and don't have root access to my machine even if I were to find
something).


That's an odd statement. If you have the ability to edit and run them,
you can test them. tcltest is 100% pure tcl. In fact, if you can run
them via your web server, you can run tests *in* your webserver. Just
drop the tcltest source code wherever you can access it (read: in the
same file or directory where PROPER_CASE is defined) and off you go. Of
course, you can also test them via tclsh if you have that available.

As for testing them at home, I bet even the slowest PC you can find that
is still running is sufficient to run tcltest for a modest number of tests.

I don't mean to be telling you how to work. It's just that these errors
were so trivial to reproduce that it seemed like a beginners mistake. No
offense. I just didn't think you were aware of some of the options
available to you.

Apr 22 '06 #22
comp.lang.tcl wrote:
... I just don't have the means of testing my
TCL procs apart from using Wish on my very slow home PC (I use Linux at
work, haven't yet found an environment I can use to test TCL procs at
work and don't have root access to my machine even if I were to find
something).


Go to: http://www.equi4.com/pub/tk/downloads.html

And download the appropriate TclKit. It does not need to be installed, it
will run as a user program.

BTW, Tcl (like most Linux/Unix programs) does not need to be installed by an
administrator -- you can compile and "install" it under your home directory
and just add to your PATH the directory where tclsh and wish are.

It is also rather surprising that the Linux at work does not already have
Tcl on it, I thought almost all distros came with Tcl/Tk.

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
Apr 22 '06 #23
In article <11**********************@i40g2000cwc.googlegroups .com>,
comp.lang.tcl <ph**************@gmail.com> wrote:
Apr 24 '06 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andrew V. Romero | last post by:
At work we have an excel file that contains the list of medications and their corresponding strengths. I would like to save the excel file as a text list and paste this list into a javascript...
1
by: OZ | last post by:
the serproxy claim itself a multi-thread proxy thing. I have sent email to write the original writer and there is no replay after 3 weeks. my configuration and setting are good. ...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
5
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
14
by: Web learner | last post by:
In the following code, I want ArrayList object x to be of type double. How can I do that? --Thanks SqlConnection objConnection = new SqlConnection("server=(local)\\SQLEXPRESS;...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
27
by: comp.lang.tcl | last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: set...
1
by: pnbaocuong | last post by:
Dear All When I try to use convert function of MS sql server like this: String sql = " (employee_id = '" + employee_id + "') and ((convert(VARCHAR,w_date,103) = '" + w_date + "'))"; ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.