/* MATCHDemo by Ariel Magnum
** Demonstrates usage of MATCHUSERHOST Command
** Finds Germans,Israelis,Brits and swedes in your current
** channel and displays results
*/
Options Results  /* Enable rc/result return codes */
signal on syntax /* Enables syntax checking       */
prefix='MatchDemo'  /* Prefix for echos              */
colour=3         /* Colour fo echos               */

/* Begin */
"GETUSERS"
users=compress(result,'@+') /* Remove the status markers */
de=0;il=0;uk=0;se=0
do until users=''
	parse var users user users
	"USERHOST" user
	host=result
	"MATCHUSERHOST" user"!"host "*!*@*.de"
	if rc=1 then de=de+1
	"MATCHUSERHOST" user"!"host "*!*@*.il"
	if rc=1 then il=il+1
	"MATCHUSERHOST" user"!"host "*!*@*.uk"
	if rc=1 then uk=uk+1
	"MATCHUSERHOST" user"!"host "*!*@*.se"
	if rc=1 then se=se+1
end
cecho("Found" il "Israelis")
cecho("Found" de "Germans")
cecho("Found" uk "British")
cecho("Found" se "Swedish")

/* End   */
exit

/* Shared Functions */
bold:      /* This function bolds text*/
return '02'x||arg(1)||'02'x

underline: /* This function underlines text*/
return '1F'x||arg(1)||'1F'x

inverse:   /* This function inverses text*/
return '16'x||arg(1)||'16'x

cecho:     /* This function echo's text to listview*/
"ECHO P="d2c(27)"b«"prefix"» C="colour arg(1)
return 0

syntax:   /* This function returns where you made a syntax error */
prefix="Syntax"
cecho("Command on line" SIGL "returned" RC ":" errortext(rc) sourceline(SIGL))
exit

