Control a variable with several levels

I think that you should define an input resource. Take a look at this post.