Re: invoked from within
From: Cameron Laird (claird_at_lairds.us)
Date: 11/10/04
- Previous message: Michael Schlenker: "Re: TCL Window Exes and DLLs"
- In reply to: Simon Geard: "Re: invoked from within"
- Next in thread: Erik Leunissen: "Re: invoked from within"
- Reply: Erik Leunissen: "Re: invoked from within"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Nov 2004 19:08:07 GMT
In article <4192291a$0$33637$ed2619ec@ptn-nntp-reader02.plus.net>,
Simon Geard <simon@quintic.co.uk> wrote:
>Michael wrote:
>> Hi!
>> I'm writing a TCL script Under RH9 for CISCO.
>> I'm connecting to ORACLE database , get some values in one string and
>than try to
>> break it into tokens.
>> routine look like this
>> set wholestring "{.21;2-DEC-2004}"
>> regexp {^\{(.+);(.+)\}} $wholestring fl dt
>> ### here comes an error ####
>> puts "$fl"
>> ###################
>> while executing
>> puts "$fl"
>>
>> (procedure "the_procedure" line 26)
>> invoked from within
>>
>> what's wrong???
>> Thanks
>
>Michael,
>
>I've just run that on my setup here (ActiveTcl8.4.7 / winXP) and can't
>reproduce the error. A couple of points on your example:
>
> 1) in general you should enclose the regexp in an if block, that way
>you'll only try to use variables that have been defined
>
> 2) your regexp command is not catching all the sub-expressions (which
>may be intentional) because the first variable (fl) will be assigned the
>whole string
>
>e.g.
>
>set wholestring "{.21;2-DEC-2004}"
>if {[regexp {^\{(.+);(.+)\}} $wholestring ws first second]} {
> puts "$ws ; $first ; $second"
>} else {
> puts "no match for $wholestring"
>}
>
>-> {.21;2-DEC-2004} ; .21 ; 2-DEC-2004
.
.
.
I see issues.
First, most Tcl-Oracle databases will return data as tuples,
that is, lists; I MUCH prefer to write
set datum [lindex $wholestring 0]
than to [regexp] off the enclosing {}-s.
Next, I'm happier working with
split $datum \;
One general principle operating here is that I reserve REs
for operations other built-ins don't do easily. I know others
prefer REs whenever possible.
- Previous message: Michael Schlenker: "Re: TCL Window Exes and DLLs"
- In reply to: Simon Geard: "Re: invoked from within"
- Next in thread: Erik Leunissen: "Re: invoked from within"
- Reply: Erik Leunissen: "Re: invoked from within"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|