Re: Having problem with SPLIT
- From: "Earl Grieda" <egriedaNOT@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 30 Jun 2005 18:24:03 GMT
"Ralf Fassel" <ralfixx@xxxxxx> wrote in message
news:yga1x6j99zj.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxx
> * "Earl Grieda" <egriedaNOT@xxxxxxxxxxxxxxxxxxx>
> | if {$::DEBUG} {puts "FIRST0: $orgLine"}
>
> Please show how 'orgLine' is set.
> Is it
> set orgLine "\tHeader with a tab"
orgline is set by reading a file (the email file).
set orgLine [gets $inputFileID]
and the line in the email file is
\tHeader with a tab ;# \t is 2 chars
I then do
set line [split [regsub -all { +} $orgLine " "]]
to insure there is only one space between each word and make it a list so I
can use list operations on it. The idea being that the first item in the
list is a flag and, depending on the flag, some action is done with the rest
of the line.
In this case the actual line is:
AI_HDR1_1 \tHeader with a tab
that tells me this is a report header line, and after the split it becomes
AI_HDR1_1 {\tHeader} with a tab
without a tab the line would be
AI_HDR1_1 Header with a tab
This (along with a lot of other stuff) then gets passed, via a file, to
another program. The other program then does various things with that file,
one of which is extract the report headers. This is done via this proc.
proc GetReportHeaders {job} {
set headers ""
catch {open $job r} jobFileId
foreach line [split [read $jobFileId] \n] {
if {[string first $::WEB_HEADER [lindex $line 0]] >= 0} {
;# web header flag is AI_HDR
for {set i 1} {$i < [llength $line]} {incr i} {
;# the rest of the line is the header
lappend header [lindex $line $i]
}
;# More than one header so make a list of headers
;# Item 0,2,4,etc is flag, item 1,3,5,etc is header
lappend headers "[lindex $line 0] [list $header]"
set header ""
}
} ;# for each
close $jobFileId
return $headers
}
After this is done "headers" can contain:
{{AI_HDR1_1} {This is a header} {AI_HDR3_2} {This is another header}}
or if a tab starts the header
{{AI_HDR1_1} {{\tThis} is a header} {AI_HDR3_2} {This is another header}}
Depending on the header flag, which contains posistion information, the
header is placed on the report like this:
This is a header
...... report stuff
...... report stuff
...... report stuff
This is another header
...... report stuff
...... report stuff
The problem is that if I want the header, which is a user defined item, to
be able to start with a tab so I end up with:
{\tThis} is a header
If I do a join on the proc line above:
lappend header [join [lindex $line $i]]
I end up with:
{ This} is a header
which gets printed on the report as:
{ This} is a header
If I do not have the \t (I have only tested it by placing it at the start)
there is no problem.
I got around this problem by using append versus lappend:
append header "[join [lindex $line $i]] "
I needed to add a space between each word since it would otherwise be
Thisisaheader
without the space.
However, this also has a potential problem in that the join changes the \t
into 5 spaces so that I have this:
This is a header
versus
\tThis is a header
I would rather have "puts" make the tab substitution.
.
- Follow-Ups:
- Re: Having problem with SPLIT
- From: Bryan Oakley
- Re: Having problem with SPLIT
- References:
- Having problem with SPLIT
- From: Earl Grieda
- Re: Having problem with SPLIT
- From: Bryan Oakley
- Re: Having problem with SPLIT
- From: Earl Grieda
- Re: Having problem with SPLIT
- From: Ralf Fassel
- Having problem with SPLIT
- Prev by Date: Re: Commercial/Shareware and Extensions ?
- Next by Date: Re: TCL socket connection
- Previous by thread: Re: Having problem with SPLIT
- Next by thread: Re: Having problem with SPLIT
- Index(es):
Relevant Pages
|