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.
Old posts that have not been replied to for several years.
T
TomSommer
Post
by TomSommer » Wed Aug 28, 2002 1:03 pm
I get this error "unmatched open quote in list"
I guess it's because I need to escape something in my string... so I was wondering if there was a way to escape a string and unescape it... some functions?
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Wed Aug 28, 2002 5:19 pm
This is not due to a character being un-escaped
It is likely to have allready been excaped, yet due to bad handling of strings (using list commands), it is processed wrong.
If you post the script, we can pinpoint the problem.
T
TomSommer
Post
by TomSommer » Wed Aug 28, 2002 5:41 pm
I think I fixed the problem with
It works now anyway, are there any tcl functions used for escaping, and unescaping? besides subst? because subst only escapes?
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Mon Sep 02, 2002 5:16 pm
Your regsub is a temporary solution. It could break again when you modify the script. PPslim was right in saying that it is due to bad handling of the string.
You are probably saying [lindex $text 1] or something. To correct this code, use [split] on $text, not regsub.
T
TomSommer
Post
by TomSommer » Mon Sep 02, 2002 5:25 pm
Nice, thanks... so list functions suck?
how do I make split work like lindex?
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Mon Sep 02, 2002 5:49 pm
No list functions don't suck. But they are not designed to operate on strings. A word in a string does not equal an element in a list.
Split takes a string and turns it into a list, based on spaces. So after split, each word is an element in a list.
So to use lindex and split together, simply say:
lindex [split $text] 1
T
TomSommer
Post
by TomSommer » Mon Sep 02, 2002 5:54 pm
Thank you, I'll try that...
T
TomSommer
Post
by TomSommer » Mon Sep 02, 2002 6:08 pm
Code: Select all
set text [string trimleft $text "$trigger "]
This code seems to make trubble...
If $text is "$trigger ic is fun"
Then it not only strips down the "$trigger " but also the i in "ic"
Is this the same problem?
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Mon Sep 02, 2002 6:26 pm
Hehe no that's a misunderstanding of what the trim command does. You give it a list of characters and it trims them. You're giving it a whole word, but it only sees individual letters. So if there's an i in your trigger, it trims all i's, etc.
You're probably better off using regsub.
T
TomSommer
Post
by TomSommer » Mon Sep 02, 2002 6:29 pm
oh... hehehe, I see... learning a lot here
I was using regsub before, but that replaces all occurences of the pattern, I only want to kill the first word in a string...
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Mon Sep 02, 2002 6:38 pm
It only replaces all matches if you use the -all flag.
regsub {^[^\w]*[\w]+[^\w]*} $text "" text
That replaces the first word and any space around it.
T
TomSommer
Post
by TomSommer » Mon Sep 02, 2002 6:41 pm
Thank you so much, I fixed all my problems now..