No more elements

What is the javascript equivalent of a loop condition “until no more elements”?
I want to create a complex condition of “until no more elements” or “text found”.

Currently, I have 2 nested loops with a text condition inside a “until no more elements”. It seems to work ok, but logs an out-of-bounds error.

Thanks for your help.

Here’s one method, I’m sure there are other ways to achieve this as well but it’s the first that popped into my mind.
Create a Repeat step with the type Until statement is true, and set both operands to JavaScript.
In the first operand, use code like this:

var textToSearchFor = "some text";

var line = "";
var oob = false;
var textFound = false;
try {
	line = data.extract(1,100,0,1,"");
	textFound = line.indexOf(textToSearchFor)>-1;
	if(!textFound) steps.moveToNext(0);
} catch(e) {
	oob = true;
	logger.warn("End of document reached.");
}
oob || textFound;

The Javascript for the second operator contains only true;.

This code checks if a specific string of characters is found anywhere on the extracted line. It also checks whether the extraction generated an error, indicating an Out-Of-Bounds error occurred. The error is trapped so that the process can keep running.
The code also takes care of moving the pointer down if there is no error and the text is not found.

Here’s what the basic process looks like:

Note that there is an ignored Goto step inside the loop: that’s because we don’t need it since the JavaScript takes care of advancing the pointer. However, it is still required inside the loop, because without it the DataMapper would detect a possible infinite loop and refuse to run.

Thanks Phil,
I put a loop in the javascript and now I can run it as a single action step rather than as a loop step. I’m guessing this will process more efficiently.
I will use this a lot!