Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control characters in a string of text. 1

Status
Not open for further replies.

hija

Programmer
Oct 30, 2002
16
AU
This tip is passed on from attempting to solve a problem in formatting a string of characters by eliminating control and field key characters.

Using [string map] function enables one to translate a range of odd characters in a string used to separate fields.

string map {ª _ ô _ ² _ Ø _ > _} "Fvx @ ª>Part No 1234 ô Use date/time 190337 APR 02 ²>Ø"

will out put a line
"Fvx @ __Part No 1234 _ Use date/time 190337 APR 02 ___

This improves readablity from the human viewpoint.

If you have a spurious EOF character in a string being read from a file this upsets Tcl to the point where you cannot process any further lines after. To override the EOF character in a string use fconfigure

set fileName [open $unformatted_file r ]
fconfigure fileName -eofchar { }
"process file of text line by line here"
close $fileName


 
Good info hija.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top