Re: Having problem with SPLIT



Earl Grieda wrote:
"Bryan Oakley" <oakley@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:MFFwe.969$Ox3.533@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Earl Grieda wrote:

I am trying to embed a tab character into a line that gets emailed
to a report generator.  Upon receipt of the email, I go through each
line of it with split since in the past emails have arrived with
unbalanced braces which then caused problems.

The line I send is, \tHeader with a tab.  After the split I get,
{\tHeader} with a tab.  Another line sent without a tab, Header Without
a tab, is unaffected.  What I want is the final line that gets passed to
"puts $reportFile" to be "\tHeader with a tab", but I cannot get rid of
the curly braces.  I know this is my problem but I have run out of

ideas.

Thanks.



split returns a list, so maybe you need to do "puts [lindex $resultOfSplit 0]" to get your header? It's hard to say without seeing your actual code. Textual descriptions of code rarely describe the problem accurately.



Code:

if {$::DEBUG} {puts "FIRST0: $orgLine"}
set line [split $orgLine]
if {$::DEBUG} {puts "FIRST1: $line"}

DEBUG output:

FIRST0: \tHeader with a tab
FIRST1: {\tHeader} with a tab

What you have here is that, after the split, $line is a 4 element list. Maybe the following is illuminating:


  % set orgLine {\tHeader with a tab}
  \tHeader with a tab
  % set line [split $orgLine]
  {\tHeader} with a tab
  % lindex $line 0
  \tHeader
  % llength $line
  4
  % puts $line
  {\tHeader} with a tab
  % foreach elem $line {puts $elem}
  \tHeader
  with
  a
  tab

The curlies not part of element 0, they are part of the string representation of the complete list.

I'm not sure I understand 100% what you want to do. One possibility is that you're after
% puts $orgLine
\tHeader with a tab
Another one is
% puts [join $line]
\tHeader with a tab


HTH
Miguel
.



Relevant Pages

  • Re: Having problem with SPLIT
    ... report generator. ... I go through each line of it with split since in the past emails have arrived with unbalanced braces which then caused problems. ... Another line sent without a tab, Header Without a tab, is unaffected. ...
    (comp.lang.tcl)
  • Re: Having problem with SPLIT
    ... | that tells me this is a report header line, and after the split it becomes ... | AI_HDR1_1 with a tab ... | I would rather have "puts" make the tab substitution. ... Receiver: read line as well formatted list ...
    (comp.lang.tcl)
  • Re: How to stop print spooler from replacing command characters ?
    ... seems to me the printer spooler strips them off and puts another ... character in their place. ... I noticed there's this 'Font selection' tab ...
    (microsoft.public.dotnet.general)
  • opening a new tab in XEmacs
    ... File -> Open In New Frame ... When it does not put the file in a new tab, it just puts the ... Buffer to get the original file I was working on. ...
    (comp.emacs.xemacs)
  • Re: Formula error...
    ... > Peo Sjoblom ... >> either puts an AL if true or NL if false. ... >> tab). ...
    (microsoft.public.excel.misc)