[Activetcl] split doing two different things
by Gene Osteen other posts by this author
Apr 7 2008 2:06PM messages near this date
view in the new Beta List Site
[Activetcl] Tablelist Interactive Cell Editing
|
Re: [Activetcl] split doing two different things
All,
I use the split command to tell me how many fields are in a line of text sent to
me. The data is character delimited with a � as the delimiter. Each line of text ends wit
h a �. Normally if I do a split I get one more list element than there are fields. I have
a case where this is not happening. I am including 2 examples. The first is not working as e
xpected the line of data is:
314185798�59858�2004-11-19�2004-11-19 23:08:00� KPFS-IN NCAL-INTERFACE�121314�12
1314�121314�
For some reason the list length here is 8 which is also the number of �s in the line.
The line below has 112 �s and returns a list of 113:
32020306370�60325.01�32011994804�2006-03-01�121226�CIPS Notes Historical - NCAL�
.32�12010034872��12010034872��1201400220020�����������Y�16
1898101�2006-03-01������������������������
�����������121140597����4�������2007-12-15 20:51
:00�12014����������1938672620060301154851P�Contact created via inter
face. (898101,1096539)��TRANSCRIPTION, INBOUND�N�121320���������ï¿
½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½2006-03-01��1400220020�
The following script shows the difference
set a "314185798�59858�2004-11-19�2004-11-19 23:08:00� KPFS-IN NCAL-INTERFACE�1213
14�121314�121314�"
puts "number of fields = [llength [split $a �]]"
puts "num_data_fields [expr [llength [split $a �]] - 1]"
set b "32020306370�60325.01�32011994804�2006-03-01�121226�CIPS Notes Historical -
NCAL�.32�12010034872��12010034872��1201400220020����������ï¿
½Y�161898101�2006-03-01���������������������ï¿
½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½121140597����4�������2007-12-1
5 20:51:00�12014����������1938672620060301154851P�Contact created vi
a interface. (898101,1096539)��TRANSCRIPTION, INBOUND�N�121320�������ï
¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½2006-03-01��1400220020�
"
puts "number of fields = [llength [split $b �]]"
puts "num_data_fields [expr [llength [split $b �]] - 1]"
PRODUCES THE FOLLOWING OUTPUT
number of fields = 8
num_data_fields 7
number of fields = 113
num_data_fields 112
Can anyone explain
Gene Osteen
803-649-7486
Confidentiality Notice: The electronic mail and/or documents accompanying this transmission
contain confidential information belonging to the sender, which is legally privileged. The i
nformation is intended only for the individual's) or entity named above. If you are not the
intended recipient you are hereby notified that any disclosure, copying, distribution or tak
ing of any action in reliance on the contents of this information is strictly prohibited. If
you have received this transmission in error, please immediately notify us by email or tele
phone to arrange for return or to destroy the original document. Thank You.
Thread:
Gene Osteen
Jeff Hobbs
Flavio Salgueiro
Michael Bahr
Jeff Hobbs
Michael Bahr
Dossy Shiobara
Michael Bahr
Dossy Shiobara
Michael Bahr
Jeff Hobbs
Enrico Herzke
Michael Bahr
Jeff Dinsmore
Michael Bahr
Gene Osteen
Jeff Dinsmore
Enrico Herzke
|