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!

curly brace question in tcl 2

Status
Not open for further replies.

daisy4u721

Programmer
Aug 24, 2009
34
US
I have a code that outputs some information from Sql database using tcl. I noticed that when the information i output have a space in it, it is surrounded by a curly brace {} and when it does not have a space there is no curly brace surrounded. Does anyone know why and how i can output it without the curly brace?

Any help will be appreciated.

Daisy
 
You can write:
puts {1. Hello World}
or
puts "2. Hello World
 
Hi

Additionally, you can also write :
Code:
[b]puts[/b] [purple]3[/purple][teal].\[/teal] Hello[teal]\[/teal] World
The difference is visible when you have variable or command substitution :
Code:
[gray]# variable :[/gray]
[b]set[/b] attribute destroyed

[b]puts[/b] [teal]{[/teal][purple]1[/purple][teal].[/teal] Hello [navy]$attribute[/navy] World[teal]}[/teal]
[b]puts[/b] [green][i]"2. Hello $attribute World"[/i][/green]
[b]puts[/b] 3a[teal].\[/teal] Hello[teal]\[/teal] [navy]$attribute[/navy][teal]\[/teal] World
[b]puts[/b] 3b[teal].\[/teal] Hello[teal]\[/teal] [teal]\[/teal][navy]$attribute[/navy][teal]\[/teal] World

[gray]# command :[/gray]
[b]puts[/b] [teal]{[/teal][purple]1[/purple][teal].[/teal] Hello [teal][[/teal][b]clock[/b] [b]format[/b] [teal][[/teal][b]clock[/b] seconds[teal]]][/teal] World[teal]}[/teal]
[b]puts[/b] [green][i]"2. Hello [clock format [clock seconds]] World"[/i][/green]
[b]puts[/b] 3a[teal].\[/teal] Hello[teal]\[/teal] [teal][[/teal][b]clock[/b] [b]format[/b] [teal][[/teal][b]clock[/b] seconds[teal]]]\[/teal] World
[b]puts[/b] 3b[teal].\[/teal] Hello[teal]\[/teal] [teal]\[[/teal][b]clock[/b][teal]\[/teal] [b]format[/b][teal]\[/teal] [teal]\[[/teal][b]clock[/b][teal]\[/teal] seconds[teal]\]\]\[/teal] World
Code:
1. Hello $attribute World
2. Hello destroyed World
3a. Hello destroyed World
3b. Hello $attribute World
1. Hello [clock format [clock seconds]] World
2. Hello Sat Oct 24 14:46:06 EEST 2009 World
3a. Hello Sat Oct 24 14:46:06 EEST 2009 World
3b. Hello [clock format [clock seconds]] World
But of course, the Tcl documentation and the tutorial explains it better.

Feherke.
 
Thank you guys for the reply. Im not sure if you guys understand what im trying to say. Let me explain better.

I have a code that outputs some information from sql database. This is the code below:
Code:
set query "select Comment FROM Table WHERE Name = 'Daisy'"
set foo [database $query]
but when i type puts $foo, it outputs the information with a curly brace and the curly brace is not in the info in the database. This is an example of the output below:
Code:
{comment: this is a very good site. I hope to see more}
but if there are not spaces in the information it outputs it with no curly brace, something like:
Code:
Wonderful

How do i get rid of the curly brace in the information outputted with the space?

Thanks
 
Take a look at the string trim ... function.

_________________
Bob Rashkin
 
Hi

daisy4u721 said:
but when i type puts $foo, it outputs the information with a curly brace and the curly brace is not in the info in the database.
I would say, that is because the database command probably returns a list. Try this :
Code:
[b]puts[/b] [teal][[/teal][b]lindex[/b] [navy]$foo[/navy] [purple]0[/purple][teal]][/teal]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top