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.

help with spliting a long phrase

Old posts that have not been replied to for several years.
Locked
j
jlongo

help with spliting a long phrase

Post by jlongo »

changing a tcl script for what i need... i made this piece of code

i made this piece of code

Code: Select all

	if {[string match "*PVT*" $response]}{
		regsub -all -- "PVT" $response "" response
		set comando [split $response |]
		foreach saida $comando { puthelp "PRIVMSG $who: $saida" }
		}
what i pretend is to split a long phrase initiated by "PRV" and the point of split is marked with a "|" but this code i only get the first word between any "|" ... whats wrong or how i can resolve this problem ???

Thanks
d
darko``
Op
Posts: 121
Joined: Sun Sep 08, 2002 5:33 pm
Location: Malta

Post by darko`` »

You need to provide more info, cause i don't see where do you get the splitchar from. If you are generating it in your regsub, replacing PVT with | then you have a typo there.

Your replace string is "" instead of "|".
Ignorant and lazy people will save 30 minutes by chosing simple config file. Smart ones will save 3000 minutes of *everyone's* time by opting for complete config file.
j
jlongo

Post by jlongo »

i have the one string with this 'PVT some text to send | some more text to send | and some more text too'

what i pretend is to remove PVT from string (regsub -all -- "*PVT*" $string "" string) and next split the string by "|" and send to user all the splited strings... something similar to explode () of PHP... but in this code i create... the remove of PVT works ok... but i only get the first word of the splited string...

in the string exemple i wrote before the output gived is something like this:

-some
-some
-and

i pretend something like:

-some text to send
-some more text to send
-and some more text too

i'm very new to TCL ... one day...
i can't figure what i'm doing wrong... logicaly seems correct... i think is some bad utilization of split....

thanks for any help
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Very simple mistake, you have your : in the wrong place in the privmsg.

puthelp "privmsg $who :$saida"
j
jlongo

Post by jlongo »

Thanks , now works fine !!!

can you explain the diference using the : or not ???

Thanks ;)
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

In most scripting/programming languages, there is a way of using long parameters, by placing them within ""'s.

However, in the IRC protocol, they don't use "", as they can be used within normal text.

As such, any commands requiring/able to take multi word parameters, allways take this parameter last.

Usign the PRIVMSG command as an example.

PRIVMSG ppslim hello to you
PRIVMSG ppslim :hello to you

The first version would only display the word "hello"
The second would display "hello to you".

The : is used to specify the start of the last parameter, in commands where a parameter is multi word.

The only reason it is used as the start, is so that : can be used within the parameter.

Thus
PRIVMSG ppslim ::Hello to: you
Would send ":Hello to: you"
j
jlongo

Post by jlongo »

thanks again for your patience ;)

have a nice day, night or whatever
Locked