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.

unmatched open quote in list

Old posts that have not been replied to for several years.
Locked
T
TomSommer

unmatched open quote in list

Post by TomSommer »

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?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

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 »

I think I fixed the problem with

Code: Select all

regsub -all "\\\\" $text "" text
It works now anyway, are there any tcl functions used for escaping, and unescaping? besides subst? because subst only escapes?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

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 »

Nice, thanks... so list functions suck?

how do I make split work like lindex?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

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 »

Thank you, I'll try that... :)
T
TomSommer

Post by TomSommer »

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?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

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 »

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...
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

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 »

Thank you so much, I fixed all my problems now.. :)
Locked