Strings in Tcl
A string is a sequence of characters. Unlike other languages, Tcl does not usually require double quotes around strings. Only when there is a pause between words do they become necessary. The language Tcl is built on strings. It offers a wide range of commands for working with strings.
#!/usr/bin/tclsh puts TCL puts LINUX
What if we wished to use quotes in a direct speech, for instance? In this scenario, inner quotes need to be escaped
#!/usr/bin/tclsh
puts "TermHint is the Best"
Multiline strings
In Tcl, making a multiline string is really simple. Multiline string creation is substantially less convenient in many other languages.
#!/usr/bin/tclsh set script " In Tcl, making a multiline string is really simple." puts $script
Comparing strings
The string compare command can be used to perform simple string comparisons.
#!/usr/bin/tclsh puts [string compare 12] puts [string compare 12 13] puts [string compare 13 14 15]
Character by character, strings are compared using the string compare command. If it discovers that the initial characters of both strings are identical, it moves on to the next character to the conclusion, checking for equality. If the strings are equal, it returns 0, and if a non-matching character from the first string comes before a character from the second string in the ASCII table, it returns -1. If the first string’s non-matching character appears after the second string’s character, the 1 number is returned.