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

expression evaluating properly except for on one specific frame

Community Beginner ,
Feb 20, 2023 Feb 20, 2023

Copy link to clipboard

Copied

Right up front... I'm not a programmer. I have enough experience with code that I've been hacking my way through a project involving expressions, and I've run into something that I'm having difficulty troubleshooting. I imagine programmers will be horrified to see the mess I've made, but I'm hoping someone can spot what's happening that's causing my problem. I'm pulling values from a CSV spreadsheet, and in certain cases I want to pull a value associated with the current frame in addition to a value for the next frame ("tgRowNumber" and "tgRowNumberPlusOne"). Here's my mess of an expression:

 

f = ((time*24)*(1/comp("spreadsheet data driven COMP").layer("frame multiplier").effect("Slider Control")("Slider")));
tString = f.toFixed(3) ;
frameForString = Math.floor(f);
sliderControl = comp("spreadsheet data driven COMP").layer("frame multiplier").effect("Slider Control")("Slider");
tgLeader = "Total Gross ";
if (f>100) {tgRowNumber = 100} else {tgRowNumber = frameForString};
tgRowNumberPlusOne = tgRowNumber + 1;
tgString = tgLeader + tgRowNumber;
if (f>100) {tgString2 = tgLeader + tgRowNumber} else {tgString2 = tgLeader + tgRowNumberPlusOne};
if (tString.split(".")[1] == "000") {zero = "T"} else {zero = "F"};
if (tString.split(".")[1] == "125") {oneEighth = "T"} else {oneEighth = "F"};
if (tString.split(".")[1] == "250") {oneQuarter = "T"} else {oneQuarter = "F"};
if (tString.split(".")[1] == "333") {oneThird = "T"} else {oneThird = "F"};
if (tString.split(".")[1] == "375") {threeEighths = "T"} else {threeEighths = "F"};
if (tString.split(".")[1] == "500") {oneHalf = "T"} else {oneHalf = "F"};
if (tString.split(".")[1] == "625") {fiveEighths = "T"} else {fiveEighths = "F"};
if (tString.split(".")[1] == "667") {twoThirds = "T"} else {twoThirds = "F"};
if (tString.split(".")[1] == "750") {threeQuarters = "T"} else {threeQuarters = "F"};
if (tString.split(".")[1] == "875") {sevenEighths = "T"} else {sevenEighths = "F"};
n = Math.round(thisComp.layer("spreadsheet.csv")("Data")("Outline")("Total Gross")(tgString)*1000)/1000;
nPlusOne = Math.round(thisComp.layer("spreadsheet.csv")("Data")("Outline")("Total Gross")(tgString2)*1000)/1000;
if (zero == "T")
nAdjusted = 10000 * (n/1000)
else
if (sliderControl == 2 || sliderControl == 4 && oneHalf == "T") 
nAdjusted = 10000 * ((((nPlusOne - n)/2)+n)/1000)
else
if (sliderControl == 3 && oneThird == "T") 
nAdjusted = 10000 * ((((nPlusOne - n)/3)+n)/1000)
else
if (sliderControl == 3 && twoThirds == "T")
nAdjusted = 10000 * (((((nPlusOne - n)/3)*2)+n)/1000)
else
if (sliderControl == 4 && oneQuarter == "T")
nAdjusted = 10000 * ((((nPlusOne - n)/4)+n)/1000)
else
if (sliderControl == 4 && threeQuarters == "T")
nAdjusted = 10000 * (((((nPlusOne - n)/4)*3)+n)/1000)
else
nAdjusted = 10000 * (n/1000);
"n = " + n + " / nPlusOne = " + nPlusOne
+ "\r" + "nAdjusted = " + nAdjusted
+ "\r" + "f = " + f + " / " + "zero = " + zero
+ "\r" + "tgString = " + tgString + "\r" + "tgString2 = " + tgString2
 
This specific expression I pasted above is to replace Source Text on a text layer in order to help me troubleshoot why I'm getting unexpected results when f = 100 ("Total Gross 100" is the index of the last value in the CSV file to pull). Currently all of my expression-generated text is yielding helpful info on every frame except for when f = 100. When f = 100, the expression doesn't evaluate to anything... I just see the default Source Text for the text layer. I'm not seeing why f being equal to 100 is causing the expression to fail to evaluate. Evaluates properly when f<100 and when f>100, but fails when f==100. Can anyone help?
 
I'm happy to answer questions in order to provide clarification.
 
TOPICS
Expressions

Views

299

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

correct answers 1 Correct answer

LEGEND , Feb 20, 2023 Feb 20, 2023

You have not defined any valid rule for 100. All your code only works from 1 to 99 and from 101 and above. Perhaps you rather may want to use f>99 or f>=100.

 

Mylenium 

Votes

Translate

Translate
LEGEND ,
Feb 20, 2023 Feb 20, 2023

Copy link to clipboard

Copied

You have not defined any valid rule for 100. All your code only works from 1 to 99 and from 101 and above. Perhaps you rather may want to use f>99 or f>=100.

 

Mylenium 

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
Community Beginner ,
Feb 20, 2023 Feb 20, 2023

Copy link to clipboard

Copied

LATEST

Thank you very much. I'm not sure I completely understand why 100 isn't included with 1 to 99 when the test for "if (f>100)" is false and the expression moves on to "else." I must be missing something. But switching to "f>=100" fixed it, so I'm extremely grateful for your prompt response.

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