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.