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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concat variables in new lines 1

Status
Not open for further replies.

Natiya

Programmer
May 14, 2017
12
ES
I'd like to concat some string-based variables and I want each of them in a new line. However, I can't find the correct way to write the code. This is what I tried:

Code:
set mensaje "Error: esta atenuacion: $att dB\n"

gset listaMensajes  [concat [gget listaMensajes] "$mensaje"]

set mensaje "Error: esta atenuacion: $att dB\n"

gset listaMensajes  [concat [gget listaMensajes] "$mensaje"]

puts "[gget listaMensajes]"

The variable $att takes different values in the different parts of the code.

I also tried:

Code:
gset listaMensajes  [concat [gget listaMensajes] "\n" "$mensaje"]

but none of them work; I get the messages in the same line [sad]
 
Hi

I think you may want
Code:
gset listaMensajes [teal][[/teal][b]concat[/b] [highlight][teal][[/teal][b]join[/b] [/highlight][teal][[/teal]gget listaErroneos[teal]][/teal][highlight] [i][green]"[/green][/i][lime]\n[/lime][i][green]"[/green][/i][teal]][/teal][/highlight] [i][green]"[/green][/i][lime]\n[/lime][i][green]"[/green] [green]"$mensaje"[/green][/i][teal]][/teal]
If listaErroneos is a list, [tt]concat[/tt] just flatten it, not joins its items.


Feherke.
feherke.github.io
 
Sorry, it's the same list I want to concatenate!

Code:
gset listaMensajes [concat [join [gget listaMensajes] "\n"] "\n" "$mensaje"]

Anyway, I tried the code you wrote and it separates each word in the first puts and it shows it in one line in the second puts [neutral]
 
I found the solution:

Code:
gset listaMensajes [join [list "[gget listaMensajes]" "$mensaje"] \n]
[peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top