Modulo Counter - Increment on Button Click

I built a modulo counter (please see attached Test_Modulo.hrp) so that I can scroll through several overlapping grid selections containing streaming app buttons for my Roku. Based on the current value of a counter variable, I enable/make visible the appropriate grid and hide the rest.

The modulo “reset-to-0” operation is handled by a datatrigger conditional that compares the counter variable value (after a button click increment) to a single hard-coded “modulus” Value. When the conditional evaluates True, the datatrigger resets the counter by assigning “0” to the variable.

I’m a noob to HR: Can I construct a conditional that tests for “Greater Than” a hardcoded “modulus” Value? A single-point comparison seems to work, but is less-than-ideal if a glitch occurs that forces the counter variable outside the “modulus” range.

I saw a post where Bill mused about implementing a “ComparisonOperation” datatrigger selection that supplements the current IsRegularExpression choice. Is this a “feature” that I need to post for voting?

Note: The “Test_Modulo.hrp” load reflects my massive Test_Modulo.hrp (1.2 MB) HR inexperience, in that it includes both the button-click modulo counter and some simple static inputs I needed to prove to myself I could influence and display variable values.

As a “noob”, its seems you have a good handle for datatriggers and conditionals. If its setup correctly (like your example), you should not need a “greater than” as it will not go to a value you did not tell it to go to. A glitch would most likely be because you did not configure something correctly and you need to fix it. I think this way is perfectly fine for setting up a single button to scroll through multiple grids, device browsers, page browsers, properties (ie: images/colors), or whatever. I was trying to come up with a way to do this myself so, thanks for sharing!! As for your question if “greater than” is possible, I don’t know.

For conversations sake; keep in mind that when you close the Home Remote app, that variable with return to its default. If the variable is only being used for manipulating your HR UI its probably not a problem but, say you want it to remember the last value or you want to sync multiple instances of HR (on multiple devices), you could consider using a virtual device on a smart hub as your variable. Of course this introduces other potential issues (like if you lose comm to your hub or slow/laggy cloud based) but, it has always worked well for me.

You can use a Regular Expression to do a “Greater Than” check.

Edit: It looks like the regex generator tool is no longer online. Here’s another tool that looks to be doing a similar thing.

Great advice, all! I’ve constructed a demo load that implements both hardcoded and regex conditionals (please see attached Modulo_Roku_App.hrp). This demo cycles through 2 “Tiers” of Roku apps, and so requires a Modulo-2 counter implementation.

I’ve included two buttons that independently increment the counter and cycle the visible Tier, and each button is coded with a different conditional format. In practice only a single button would be required - Designer’s Choice!

The first button has a hardcoded conditional Value: 2, which tests the modulo counter variable for “=2”. The second button has a regex conditional Value: ^([2-9]|/d{2,})$ which tests the modulo counter variable for “>=2”.

Finally, for the sake of completeness, I uploaded the wrong load in my initial post. Please find attached Test_Modulo_Debug.hrp, which implements all the things I was blathering about in my original "Note:"Modulo_Roku_App.hrp (1.8 MB) Test_Modulo_Debug.hrp (1.3 MB)

1 Like


Looking forward to seeing the final project!