This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Replace element in list with white space

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Replace element in list with white space

Post by juanamores »

The list is stored in the cursong variable
Example: if the cursong variable returns: Another&Brick&In&The&Wall&Pink&Floyd
To return: Another Brick In The Wall Pink Floyd
I try:

Code: Select all

set cursong [string map [list "&" " "] $cursong]
But, no work
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Re: Replace element in list with white space

Post by willyw »

juanamores wrote:The list is stored in the cursong variable
Example: if the cursong variable returns: Another&Brick&In&The&Wall&Pink&Floyd
To return: Another Brick In The Wall Pink Floyd
...
<myhandle> .tcl split "Another&Brick&In&The&Wall&Pink&Floyd" &
<botnick> Tcl: Another Brick In The Wall Pink Floyd
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
w
willyw
Revered One
Posts: 1197
Joined: Thu Jan 15, 2009 12:55 am

Re: Replace element in list with white space

Post by willyw »

juanamores wrote:The list is stored in the cursong variable
Example: if the cursong variable returns: Another&Brick&In&The&Wall&Pink&Floyd
To return: Another Brick In The Wall Pink Floyd
I try:

Code: Select all

set cursong [string map [list "&" " "] $cursong]
But, no work
This does work.

<me> .tcl string map [list "&" " "] "Another&Brick&In&The&Wall&Pink&Floyd"
<botnick> Tcl: Another Brick In The Wall Pink Floyd
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

There was another line in the script that modified the command. :oops:
Both solutions work perfectly

Thank you willyw! :D
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply