I think I’d do it with a loop. This won’t be exactly right (I haven’t tested it at all), but maybe it’ll get you headed in the right direction:
gap = 36;
layers = ["TEXT1","TEXT2","TEXT3"];
times = [ 2, 2, 7 ];
maxX = 0;
for (i = 0; i < layers.length; i++){
L = thisComp.layer(i);
rect = L.sourceRectAtTime();
x = L.toComp([rect.left+rect.width,0],times[i])[0];
xclamp=clamp(x,545.70,2000);
maxX = Math.max(maxX,xclamp);
}
maxX+gap