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.

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.
https://3widgets.com/

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

:+1:

Looking forward to seeing the final project!