Copy link to clipboard
Copied
Hello all,
I'm trying to create a simple expression that will clamp an input based on another value. More specifically, I have a slider for a month input and a day input and I'm trying tp set up the "DAY" slider so that depending on what month is inputted in the MONTH slider, the DAY slider will only allow values that correspond to actual calendar values. E.g. if the MONTH slider is set to "2" (february) then if you put "32" for the DAY it'll just change it to "28". I wrote this expression but I have no idea what is wrong based on the error which is:
"Property or method named "A" in class 'global' does not exist or is missing. Any help is greatly appreciated!
Here is the code:
value = effect("MONTH")("Slider");
if (value == 1 || value == 3 || value == 5 || value == 7 || value == 8 || value == 10 || value == 12) {
A = 31;
} else if (value == 2) {
A = 28;
} else if (value == 4 || value == 6 || value == 9 || value == 11) {
A = 30;
}
Math.min(Math.max(effect("DAY")("Slider"), 1), A)
Copy link to clipboard
Copied
Your expression works for me, but I wouldn't use "value" as a variable name, because it's a reserved word. Also, your code doesn't include what should happen if your MONTH slider is a fraction or outside the 1 to 12 range, so you probably need a final else clause for that possibility (or do some processing to force the MONTH slider value to an integer between 1 and 12).
Copy link to clipboard
Copied
Hey Dan,
Thanks so much for this. Actually, changing value to "m" did the trick!