<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, July 15, 2004, 1:30 PM -->
<!-- MuClient version 3.50 -->

<!-- Plugin "CheckAttribute" generated by Plugin Wizard -->

<muclient>
<plugin
   name="CheckAttribute"
   author="Nick Gammon"
   id="a3e213677c69a51c376ba5d8"
   language="VBscript"
   purpose="Counts brackets in a MUSH attribute"
   date_written="2004-07-15 13:23:44"
   requires="3.25"
   version="1.0"
   >
<description trim="y">
<![CDATA[
This counts brackets in a MUSH attribute.

Usage
-----

Type:  check dbref/attribute

eg. 

check me/name

It will send a request to the MUSH for the attribute, when it replies a trigger will catch it and count the various bracket types.

For this help, type: CheckAttribute:help
]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   match="@password *=*"
   name="attribute_editor"
   omit_from_output="y"
   script="count_brackets"
   sequence="100"
  >
  </trigger>
</triggers>

<!--  Aliases  -->

<aliases>
  <alias
   match="check */*"
   enabled="y"
   expand_variables="y"
   omit_from_output="y"
  >
  <send>@@pemit/silent me=@password %2=[get(%1/%2)]
</send>
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[
'
'  count number of times one character appears in a string
'

function count_one_thing (txt, what)
dim i
dim count

'
'  zero counter
'
  count = 0

'
'  process whole string
'
  for i = 1 to len (txt)
    if mid (txt, i, 1) = what then
      count = count + 1
    end if  ' item found
  next

'
'  return result
'
  count_one_thing = count  

end function  ' count_one_thing 

'
'  counts number of various types of brackets in an attribute
'
sub count_brackets (thename, theoutput, thewildcards)
dim txt

'
'  show the attribute name (wildcard 1) and the contents 
'       (wildcard 2)
'
  Note "Attribute: " & thewildcards (1) & _
        " = " & thewildcards (2)

'
'  save contents in temporary variable
'
  txt = thewildcards (2)

'
'  show the counts
'
  Note "Attribute: { }: " & _
       count_one_thing (txt, "{") & "/" & _
       count_one_thing (txt, "}") & " [ ]: " & _
       count_one_thing (txt, "[") & "/" & _
       count_one_thing (txt, "]") & " ( ): " & _
       count_one_thing (txt, "(") & "/" & _
       count_one_thing (txt, ")") 

end sub ' count_brackets 

'
'  initialise a unique password to prevent spoofing
'
Sub OnPluginInstall
  world.setvariable "password", world.getuniqueid
End Sub

]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="CheckAttribute:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  world.Note world.GetPluginInfo (world.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>
