##NOADDURL#############################################################
#
#  COUNT.TXT      Version 2.0 - Released June 27, 2004
#                 A Proxomitron 4.5 Blockfile
#
#  PURPOSE:       Incremental Counter (counts up or down by 1)
#
#  INSTALLATION:  Unzip to Prox's LISTS folder. Create a new Blocklist
#                 entry called 'Count' in Proxomitron's Config options
#                 and point it to this blockfile. (To update an earlier
#                 release, just replace the older file with this one.)
#
#  FORMAT/USAGE:
#
#  Called by filter(s) to increment "counter" variable(s).  Generally
#  called from the Match Expression using this format:
#
#      $SET(n=$GET(n)+1)&$TST(n=$LST(Count))$SET(n=$GET(i))
#
#  or, to count down:
#
#      $SET(n=$GET(n)-1)&$TST(n=$LST(Count))$SET(n=$GET(i))
#
#  Variable 'i' is required in the calling filter, it is the output
#  value which is returned by this blockfile.  (Note: any leading zeros
#  will be stripped from the returned 'i' value.)  Variable 'n' is the
#  variable assigned by the user in the filter as a "counter" variable.
#  Variable 'n' MUST be a per-request (name) variable if the counter
#  variable is to be global (i.e., if its value needs to be passed to
#  other filters during the processing of the requested Get/Response).
#
#  When NO value yet exists for 'n', a count returns '1' given the
#  expression "$SET(n=$GET(n)+1)", or '-1' given "$SET(n=$GET(n)-1)".
#  The initial value for variable 'n' can also be captured or preset
#  (e.g., prior to a looping count or by a separate filter); values
#  can be positive or negative numbers.
#
#  Important -- variable zero (\0) is also utilized in this blocklist.
#  Do NOT use variable '0' in the calling filter for anything except
#  temporary assignments PRIOR to calling this blocklist as its value
#  may be reset!
#
#  DEVELOPMENT NOTES:
#
#  "Count" is the result of the combined efforts of mizz_mona (concept,
#  calling expressions, and this version's recursive "countdown" code);
#  ScoJo, who *completely* rewrote the initial concept blockfile using
#  a brilliant implementation of recursive calling that theoretically
#  allows infinite incremental counting (the countdown code is built on
#  his groundwork); and Scott Lemmon, who helped further refine ScoJo's
#  work -- and who is, of course, the Author/Developer of Proxomitron.
#
#  Blockfile problems or suggestions should be posted directly to the
#  "prox-list" group at Yahoo Groups -- where current/future updates of
#  Count.txt will also be posted in the Files section.
#
#  Well, hopefully, all that about covers it.  Go count something. :)
#
#######################################################################
\+1(^?)                  $SET(i=1)
\-1(^?)                  $SET(i=-1)
\-0\+1                   $SET(i=1)
\-0\-1                   $SET(i=-1)
0([0-9]++[\+\-]1)\0      $SET(i=\0)   $TST(i=$LST(Count)) $SET(i=$GET(i))
\-0([0-9]++[\+\-]1)\0    $SET(i=-\0)  $TST(i=$LST(Count)) $SET(i=$GET(i))
\-1\+1                   $SET(i=0)
([0-9]++)\00\+1          $SET(i=\01)
([0-9]++)\01\+1          $SET(i=\02)
([0-9]++)\02\+1          $SET(i=\03)
([0-9]++)\03\+1          $SET(i=\04)
([0-9]++)\04\+1          $SET(i=\05)
([0-9]++)\05\+1          $SET(i=\06)
([0-9]++)\06\+1          $SET(i=\07)
([0-9]++)\07\+1          $SET(i=\08)
([0-9]++)\08\+1          $SET(i=\09)
([0-9]++)\09\+1          $SET(i=\0+1) $TST(i=$LST(Count)) $SET(i=$GET(i)0)
([0-9]++)\00\-1          $SET(i=\0-1) $TST(i=$LST(Count)) $SET(i=$GET(i)9) ($TST(i=0\0) $SET(i=\0)|)
([0-9]++)\09\-1          $SET(i=\08)
([0-9]++)\08\-1          $SET(i=\07)
([0-9]++)\07\-1          $SET(i=\06)
([0-9]++)\06\-1          $SET(i=\05)
([0-9]++)\05\-1          $SET(i=\04)
([0-9]++)\04\-1          $SET(i=\03)
([0-9]++)\03\-1          $SET(i=\02)
([0-9]++)\02\-1          $SET(i=\01)
([0-9]++)\01\-1          $SET(i=\00)
\-([0-9]++)\0\-1         $SET(i=\0+1) $TST(i=$LST(Count)) $SET(i=-$GET(i))
\-([0-9]++)\0\+1         $SET(i=\0-1) $TST(i=$LST(Count)) $SET(i=-$GET(i))
\+([0-9]++[\+\-]1)\0     $SET(i=\0)   $TST(i=$LST(Count)) $SET(i=$GET(i))
