• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Having trouble with what would seem to be a simple if then expression

New Here ,
May 03, 2024 May 03, 2024

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)

TOPICS
Expressions

Views

138

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2024 May 03, 2024

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).

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2024 May 04, 2024

Copy link to clipboard

Copied

LATEST

Hey Dan,

Thanks so much for this. Actually, changing value to "m" did the trick!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines