Min and max set value from another varibale?

Min and max set value from another varibale?

Hi all.
I made two buttons, 1st button INC, increments variable value named INDEX by 1. Also there is DEC button which decrements INDEX by -1.
I would like to dynamicaly change max set value limit for Index variable.
Sample.
Max set value should be limited by value from variable MAX_INDEX.
When user click on button INC the value Index increments untill it reached MAX_INDEX value.

How to achieve this?

BR,Miloš

This is a migrated post! Originally posted on 10.08.2021 by user milosh. Please be aware that information can be outdated.