Topic Options
#55935 - 04/27/18 05:23 AM Loop break
Kenneth Tan Offline
OL Newbie

Registered: 02/07/18
Posts: 4
I got a txt sample data and 1 to N line number of content, and I would like to stop the loop immediate once detect certain criteria, to reduce the processing usage. Any help?

Or any example of scripting able to detect the number of content line inside that file, it's very helpful for me as well.

I'm trying not to use external program to detect the number of content.


Edited by Kenneth Tan (04/27/18 05:28 AM)

Top
#55937 - 04/27/18 09:31 AM Re: Loop break [Re: Kenneth Tan]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
What loop are you talking about? Are you splitting the file on each line and then looping through all lines? Or did you add a loop task?

In both cases, you can stop the loop by provoking an intentional error.

Place your splitter or your toop task inside a Branch. Inside the loop, add a Condition task to determine if the loop should continue (using whatever logic is appropriate for your data).

The True branch of your condition is where the loop continues processing, while the False branch is where you'll provoke the error intentionally (for instance, by adding add a Run Script task that contains something like "Intentional Error", which is not a valid scripting command).

Right-click on the Run Script task and select Advanced properties to access the On Error tab. Make sure you set the Action parameter to "Stop branch".

That's it, your branch containing the loop will stop running as soon as the error is generated, and the rest of the process can keep running.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#55940 - 04/29/18 11:17 PM Re: Loop break [Re: Philippe F.]
Kenneth Tan Offline
OL Newbie

Registered: 02/07/18
Posts: 4
Thank for advise Philippe F.

I'm using Text condition to detect certain criteria or empty line.

By the way, what's the scripting to return error so can trigger the "On Error" condition ~ "Stop branch"?

or Text condition to intentionally provoke the error and stop branch?


Edited by Kenneth Tan (04/29/18 11:18 PM)

Top
#55941 - 04/30/18 07:22 AM Re: Loop break [Re: Kenneth Tan]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
In VBScript, use Err.Raise. In JScript, use throw
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top