-
Divide by zero? error on first frame
I’m using the expression below to have a counter go up in relationship to a slider that is applied elsewhere, this counter shows the percentage of occupancy in a parking lot and has to be accurate.
The expression works great from the second frame onwards, but in the first frame it gets disabled with the all too familiar invalid numeric value, divide by zero? error.
I’m guessing some type of conditional should help me here, but I’m not exactly clear on exactly what it needs to include.
Any help?
Thanks,
D.totalSp=Math.round(thisComp.layer("183").text.sourceText)+Math.round(thisComp.layer("752").text.sourceText);
a=thisComp.layer("183").effect("Slider Control")("Slider");
t2 =thisComp.layer("183").effect("Slider Control")("Slider").key(2);
percentAvail=(a*100)/totalSp;
r=linear(a,0,t2,0,percentAvail);
Math.round(r)+"%";