Jethro, using %period like that effectively removes any significance it has since you increase item %f by %period but then later multiply by %period in the comparison.
the logic in the original code is also incorrect.
inc -u5 %a | if (%a = 7) {
the above format checks precisely '7 times each separated by at most 5 seconds'. with maximal delays, this will trigger for 7 times in 30 seconds (each line received exactly 5s after the last). the correct logic to match '7 times in 5 seconds' can be achieved with something such as the following:
inc -zu5 %a 5 | if (%a > 30) {
the key difference here is that the information regarding the delays between each message is preserved implicitly by using -z. i used /inc in this example since /hinc is presently (7.14) bugged such that -u and -z cannot be used together (the -u is ignored). [EDIT: this was fixed in 7.16] one way around this is by using timers:
hinc -mz a b 5 | .timer 1 5 hdel a b | if ($hget(a, b) > 30) {
there is yet another equivalent form that might help you wrap your heads around the method:
hadd -mu5 a b $+ $ticks | if ($hfind(a, b*, 0, w) = 7) {