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!

how to use key symbols?

Status
Not open for further replies.

RajVerma

Programmer
Jun 11, 2003
62
DE
hi all, if I want to put the string "$abcd" into my data file without having the intention of using abcd as a variable, then wat shud I do. Though I'm giving it in double quotes, it's still sayin that it cudn't find this variable. same case with "[]". so how shud I get rid of these errors?
thanq.
Raj.
 
A quick quoting primer:[ul][li]Double quotes ([tt]""[/tt]) quote an argument, but allow substitutions to occur within the argument.[/li]
[li]Curly braces ([tt]{}[/tt]) quote an argument, but prevent substitutions from occurring within the argument.[/li][li]Square brackets ([tt][ignore][][/ignore][/tt]) aren't really quoting characters. They tell the Tcl interpreter to perform command substitution. The Tcl interpreter evaluates everything within the square brackets as a Tcl command, captures the return value of the command, and substitutes it for the entire square bracket expression. For example:

Code:
set c [string length "This is a test"]
puts $c
(prints out) 14
[/li][/ul]So, all you need to do in your case is:

Code:
puts {$abcd}

Alternately, you can use the backslash character (\) as an "escape" character in situations where Tcl would otherwise perform substitutions. For example:

Code:
puts "\$abcd"

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top