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.

problems with set

Old posts that have not been replied to for several years.
Locked
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

problems with set

Post by ranny »

hello,
i have

Code: Select all

set bibo($color1)
set bibo($color2)
And I don't know how to compare the contents of these 2 variables and to write the elements who are in the 2.
if you could guide me in this demarche.

thanks
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

if {$bibo($color1) > $bibo($color2)} {
   # the first array element is greater than the second, do something
} else {
   # it's less or equal, do something else
}
r
ranny
Halfop
Posts: 49
Joined: Wed Jun 22, 2005 2:00 pm
Location: switzerland

Post by ranny »

hello,

But i have

Code: Select all

set chan($nick) [lindex [split $arg :] 1]

who's the list of the chans where is $nick.

And I want to write the chans that 2 nicks have in common??

I want to compare for example: $chan(tom) and $chan(jim). how to make??

thanks.

PS: sorry for my bad English.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

then you need 2 lists, keeping the channels those nicks are on, and finding the intersection (common elements) of the two:

Code: Select all

foreach chan $chans($nick1) {
   if {[lsearch -exact $chans($nick2) $chan] != -1} {
      lappend comchans $chan
   }
}
# now you have a list of common channels in comchans
Locked