-
Search expression
I’m trying to write an expression that will search a series of text fields (it’s a programming schedule organized in half-hour blocks, so some fields will be empty if a show is longer than half-hour and some will contain text). I would like the script to search through the fields, skipping the empty ones, until it finds one with text. And then return the text. I can then automate the building of a 3-show line-up menu.
I have a series of text layers each named: “layer1, layer2, layer3… layer10.” Everything seems to be working except I can’t get the search to wrap around after layer10 back to layer 1. Sometimes the search will have to start at say layer 8, then if it doesn’t find anything in layer9 or layer10, wrap around and start searching layer1.
See code below:
But the modulus function doesn’t seem to do anything. It goes to layer11 (which doesn’t exist) and the expression breaks.
Hope this made sense. Thanks.
show = Math.round(thisComp.layer("EXPRESSIONS CONTROLS").effect("1st SHOWnum")("Slider"));
// This determines the first time slot to search.while (comp("SHOW TITLEs & HOURs").layer("layer"+show).text.sourceText=="") {
show+=1;
show % 10;
}