mIRC Home    About    Download    Register    News    Help

Print Thread
#170375 07/02/07 07:56 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
to show the sellected nicks i have this piece of code:
Code:
var %nicklijst = $+(%nicklijst,$chr(32),$nick($chan,%nick1)) 


nicks are sepperated by a space.
i would like it to show like this:

john & jack & charles & sophie & etc & etc

the & is $chr(38) but i always get the & sign before the firts or after the last nick like this:

& john & jack & charles & sophie & etc & etc

or

john & jack & charles & sophie & etc & etc &

Depending on where i put that code
How do i stop those first or last & signs from showing

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
I use $iif for such things. Here's just an example:

Code:
var %nick = $iif(%nick,%nick & $nick($chan,%i),$nick($chan,%i))



That assumes that %i is a variable that's used in a loop to add everyone in the nicklist to the variable. Anyhow, what that will do is check to see if there is already a name in the %nick variable. If there is, then it will put the variable followed by the & followed by the new nick. If not, it will just put the new nick.

The result would look like:

John & James & Amy & Ashley & Mark & Sarah & Christy & Steve

Joined: Oct 2005
Posts: 1,671
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,671
You could also use $replace after all the names are added. Build the list with only a space between each name. After the list is complete, do this:

Code:
%before = your list of nicks delimited by spaces
%after = $replace(%before,$chr(32),$+($chr(32),$chr(38),$chr(32)))


-genius_at_work

Joined: Jan 2003
Posts: 1,057
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,057
if you want to show selected nicks I presume you mean the ones selected in the nicklist? then try:
Code:
$replace($snicks,$chr(44),$+($chr(32),&,$chr(32)))

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Originally Posted By: genius_at_work
You could also use $replace after all the names are added.


For nicks, this is a good method. However, if you're combining other items that already have spaces in them, then this won't work. By using the $iif method, it will work regardless of whether the items being combined have spaces or any other separating character. Might be better to use that method just to get used to it in case it's needed for something else later, so he doesn't need to ask again for help with that one. smile


Link Copied to Clipboard