- Joined
- Oct 25, 2006
- Messages
- 1,550
- Reaction score
- 15
- Points
- 38
So I was just curious as to if it could be done so I wrote this little macro to parse out the members of a channel and add them to an array. Maybe someone can find it usefull for something in one of their macros. There may be better ways of doing this and this doesn't work 100% of the time, but it's what I came up wit in about 30 minutes.
Note: The problem with this macro is it can miss one person. The way the channel list works it starts a new line every 10 or so names, if the very last line only has one person on it, it will not pick it up.
Also there has to be at least two people in the channel for it to work.
One last thing, I've never seen it happen as quick as the channel list spits out but if a message does come in between two lines of a channel list and has a "," in it then it will mess up the results.
Anyway here it is, if anyone can fix the problems with it and repost be my guest, I just couldn't figure any work arounds for those problems currently.
Note: The problem with this macro is it can miss one person. The way the channel list works it starts a new line every 10 or so names, if the very last line only has one person on it, it will not pick it up.
Also there has to be at least two people in the channel for it to work.
One last thing, I've never seen it happen as quick as the channel list spits out but if a message does come in between two lines of a channel list and has a "," in it then it will mess up the results.
Anyway here it is, if anyone can fix the problems with it and repost be my guest, I just couldn't figure any work arounds for those problems currently.
Code:
|============================
|channelParse.mac
|Written By - Devestator
|11/19/2008
|============================
#Event channelName "Channel #1#(#2#) #*#"
#Event channelList "#*#,#*#"
Sub Main
/declare chanListInitiated bool outer false
/declare cName string outer
/declare cCount int outer
/declare chanList[500] string outer
/declare lastStart int outer
/declare lineFinished bool outer
/declare aStart int outer
/list 1
:mainLoop
/doevents
/goto :mainLoop
/return
Sub Event_channelName(string rLine, string chanName, int memCount)
/varset chanListInitiated true
/varset cName ${chanName}
/varset cCount ${memCount}
/return
Sub Event_channelList(string rLine)
/declare cLoop int local
/declare numComplete int local
/declare aStop int local
/if (${chanListInitiated}) {
/varset lastStart 0
/varset aStop ${Math.Calc[${aStart}+30]}
/varset lineFinished false
/varset numComplete 0
/if (${aStart}<1) {
/echo Channel ${cName} - ${cCount} players
/varset aStart 1
}
/for cLoop ${aStart} to ${aStop}
/call ParseName "${rLine}" ${cLoop} ${lastStart}
/varset numComplete ${Math.Calc[${numComplete}+1]}
/if (!${lineFinished}) /next cLoop
/varset aStart ${Math.Calc[${aStart}+${numComplete}]}
/if (${aStart}>=${Math.Calc[${cCount}-1]}) {
/varset chanListInitiated false
/call listArray
/endmacro
}
}
/return
Sub ParseName(string listString, int arrayNum, int startValue)
/declare wString string local
/declare memName string local
/varset wString ${listString.Right[${Math.Calc[${listString.Length}-${startValue}]}]}
/if (${wString.Find[,]}) {
/varset memName ${wString.Left[${Math.Calc[${wString.Find[,]}-1]}]}
/if (${startValue}>0) {
/varset lastStart ${Math.Calc[${wString.Find[,]}+1+${startValue}]}
} else {
/varset lastStart ${Math.Calc[${wString.Find[,]}+3]}
}
} else {
/varset memName ${wString}
/varset lineFinished true
}
/if (!${memName.Equal[NULL]}) {
/varset chanList[${arrayNum}] ${memName}
}
/return
Sub listArray
/declare aLoop int local
/for aLoop 1 to ${cCount}
/echo ${chanList[${aLoop}]}
/next aLoop
/return