###NOADDURL#################################################################### # # Count.txt - $LST(Count) - Version 3.0 A Proxomitron 4.5 Blockfile # Incremental/Decremental Counter (counts up or down by 1) # # FORMAT/USAGE: # # Used by filters to increment or decrement "counter" variables. # # Generally called from a Matching Expression using this format to increment. # NOTE the new calling expression (uses "+" only, not "+1"): # # $TST(($GET(n)+)=$LST(Count)|*) # $SET(n=$GET(i)) # # Or this format for decrementing. NOTE the new calling expression (uses "-", # not "-1"): # # $TST(($GET(n)-)=$LST(Count)|*) # $SET(n=$GET(i)) # # Variable 'n' represents any name or number variable being used as a counter. # Variable 'i' is the calculated result that is returned by the Count list to # update the counter. The counter variable and calculation sign (+ or -) must # be enclosed in parens together. # # Multiple independent counters can run concurrently so long as each counter- # variable is uniquely named or numbered. For "global" use (available to all # filters per connection), the counter MUST be a named variable. The initial # value of a counter can of course be preset (captured or assigned); if there # is no counter value, the count begins from zero (i.e., the list returns "1" # if incrementing or "-1" if decrementing). # # Variables used by the Count list: \0 and i # # Important: As variable \0 is extensively utilized, it's best to avoid using # \0 in the calling filter (prior to calling this list) as its value could be # reset when the list is processed. # ############################################################################### # # Last updated 2014-05-01 by Mona Oliver a/k/a mizzmona (Yahoo: mizz_mona) # ############################################################################### # # HISTORY # # Count.txt resulted from the collaboration and effort of mizz_mona (original # blocklist and calling expression, and the first decrement code); ScoJo, who # reworked the initial "concept" blockfile with breakthrough coding that used # recursive calling that theoretically allowed infinite incremental counting; # the late Scott R. Lemmon, who refined ScoJo's work; and sidki, who produced # such an elegant zero-stop variation, Count.ptxt, that much was incorporated # into the second version of the original Count.txt. For some time, Count.txt # development ended; the original list could do incrementing/decrementing and # continue below zero; however, recursion was needed for some operations, and # calls to the list generated entries in the log window (known as "log spam"). # Meanwhile, sidki continued work on Count.ptxt, improving speed of operation. # To that, Mike/z12 contributed a brilliant coding solution to produce a non- # recursive list, and by "failing" the match after processing, the Count.ptxt # list also no longer generated log spam. Debugged by mizz_mona and sidki, it # was released May 5, 2005 and still endures today. As recorded in Count.ptxt: # # Updated 2004-04-20 by sidki # -> Added decrementing (down to zero only). # # Updated 2004-10-14 by sidki # -> Format changed for speed reasons. # # Updated 2005-05-04 by Mike/z12 # -> Make the list return false so the log window doesn't fill up. # -> No longer uses recursive calling. # # Updated 2005-05-05 by Mona and sidki # -> Format changes and bugfixes. # # Sidki included the list, Count.ptxt, in his popular public config. The list # was fast, did not generate log spam, but also did not support incrementing/ # decrementing negative numbers and would not count down below zero (features # unnecessary to the operation of his config). Nine years later, the original # Count.txt list was revisited by mizz_mona, who modified the Count.ptxt code # to include counting below zero and negative incrementing/decrementing; with # a new calling expression, it was then released as an upgrade for Count.txt, # under version 3.0, on May 1, 2014. # ############################################################################### # # Main distribution site: http://mizzmona.com/proxomitron/files/ # ############################################################################### ## single digit quick check, hashable ## ---------------------------------------------------------------------------- 0\+$SET(i=1) 1\+$SET(i=2) 2\+$SET(i=3) 3\+$SET(i=4) 4\+$SET(i=5) 5\+$SET(i=6) 6\+$SET(i=7) 7\+$SET(i=8) 8\+$SET(i=9) 9\+$SET(i=10) 0-$SET(i=-1) 1-$SET(i=0) 2-$SET(i=1) 3-$SET(i=2) 4-$SET(i=3) 5-$SET(i=4) 6-$SET(i=5) 7-$SET(i=6) 8-$SET(i=7) 9-$SET(i=8) ## negative digits [ -1 to 0 | no rollover | ending 0 (+) | ending 9 (-) ] ## ---------------------------------------------------------------------------- -((0+1\+&\01\+$SET(i=\00)) |\0 (0-$SET(i=-\01) |1(-$SET(i=-\02)|\+$SET(i=-\00)) |2(-$SET(i=-\03)|\+$SET(i=-\01)) |3(-$SET(i=-\04)|\+$SET(i=-\02)) |4(-$SET(i=-\05)|\+$SET(i=-\03)) |5(-$SET(i=-\06)|\+$SET(i=-\04)) |6(-$SET(i=-\07)|\+$SET(i=-\05)) |7(-$SET(i=-\08)|\+$SET(i=-\06)) |8(-$SET(i=-\09)|\+$SET(i=-\07)) |9\+$SET(i=-\08) ) |(*0\+&\00$SET(i=9)(0$SET(i=$GET(i)9))+\+ $TST(\0= 1(^?)$SET(i=-$GET(i)) |\01(^?)$SET(i=-\00$GET(i)) |\02(^?)$SET(i=-\01$GET(i)) |\03(^?)$SET(i=-\02$GET(i)) |\04(^?)$SET(i=-\03$GET(i)) |\05(^?)$SET(i=-\04$GET(i)) |\06(^?)$SET(i=-\05$GET(i)) |\07(^?)$SET(i=-\06$GET(i)) |\08(^?)$SET(i=-\07$GET(i)) |\09(^?)$SET(i=-\08$GET(i)) ) ) |(*9-&\09$SET(i=0)(9$SET(i=$GET(i)0))+- $TST(\0= 99+-(^?)$SET(i=-1$GET(i)) |\00(^?)$SET(i=-\01$GET(i)) |\01(^?)$SET(i=-\02$GET(i)) |\02(^?)$SET(i=-\03$GET(i)) |\03(^?)$SET(i=-\04$GET(i)) |\04(^?)$SET(i=-\05$GET(i)) |\05(^?)$SET(i=-\06$GET(i)) |\06(^?)$SET(i=-\07$GET(i)) |\07(^?)$SET(i=-\08$GET(i)) |\08(^?)$SET(i=-\09$GET(i)) ) ) ) ## positive digits [ 0 to -1 | no rollover | ending 0 (-) | ending 9 (+) ] ## ---------------------------------------------------------------------------- 00+-&\00-$SET(i=-\01) \0 (0\+$SET(i=\01) |1(\+$SET(i=\02)|-$SET(i=\00)) |2(\+$SET(i=\03)|-$SET(i=\01)) |3(\+$SET(i=\04)|-$SET(i=\02)) |4(\+$SET(i=\05)|-$SET(i=\03)) |5(\+$SET(i=\06)|-$SET(i=\04)) |6(\+$SET(i=\07)|-$SET(i=\05)) |7(\+$SET(i=\08)|-$SET(i=\06)) |8(\+$SET(i=\09)|-$SET(i=\07)) |9-$SET(i=\08) ) *0-&\00$SET(i=9)(0$SET(i=$GET(i)9))+- $TST(\0= 1(^?) |\01(^?)$SET(i=\00$GET(i)) |\02(^?)$SET(i=\01$GET(i)) |\03(^?)$SET(i=\02$GET(i)) |\04(^?)$SET(i=\03$GET(i)) |\05(^?)$SET(i=\04$GET(i)) |\06(^?)$SET(i=\05$GET(i)) |\07(^?)$SET(i=\06$GET(i)) |\08(^?)$SET(i=\07$GET(i)) |\09(^?)$SET(i=\08$GET(i)) ) *9\+&\09$SET(i=0)(9$SET(i=$GET(i)0))+\+ $TST(\0= 99+\+(^?)$SET(i=1$GET(i)) |\00(^?)$SET(i=\01$GET(i)) |\01(^?)$SET(i=\02$GET(i)) |\02(^?)$SET(i=\03$GET(i)) |\03(^?)$SET(i=\04$GET(i)) |\04(^?)$SET(i=\05$GET(i)) |\05(^?)$SET(i=\06$GET(i)) |\06(^?)$SET(i=\07$GET(i)) |\07(^?)$SET(i=\08$GET(i)) |\08(^?)$SET(i=\09$GET(i)) ) ## if not matched above, no digits, start of count ## ---------------------------------------------------------------------------- *(\+$SET(i=1)|-$SET(i=-1)) ## Fail after processing (prevents log spam) ## ---------------------------------------------------------------------------- ~?