Break From Iteration

One Star

Break From Iteration

Hello,
I'm downloading from FTP, and unfortunately, I cannot delete due to permission.
Therefore, I need to iterate fix number of times (instead of iterate through all the files).
Option 1 - Limit within Iteration count
I will download all files, but use tFileList to only import last 3 files (order by filename).
What's the best way to break from an iteration in tJava? I can set context variable, and if it iterates over the threashold, what command can I use to break the iteration?
Option 2 - Limit FTP Download (only last couple days instead of all files on FTP)
This would be the most efficient option, but could be more complicated, so if someone has a good solution, I would be interested to know about it.
Your help is appreciated!
Seven Stars

Re: Break From Iteration

See my screenprint for an example of how to break an iteration.
You can also use tFTPFileList iterating to tFTPFileProperties-->tJavaRow then RunIf to tFTPGet to only download those files you want.
One Star

Re: Break From Iteration

Hi Adam,
Just asking out of my curiosity.
Instead of "break", what if we mention "continue", the loop should continue with the next record, right?
Seven Stars

Re: Break From Iteration

Yes, it would jump over any components/code after that statement and start the next iteration, exactly the same as if you were writing your own loop. View the code the studio generates to see exactly what's happening.
One Star

Re: Break From Iteration

Hi,
The screen shot appears to be missing.
Sorry for dragging this thread back form the dead but I'd be interested to know how to continue(skip the current) iteration.
I currently have the following;
tFlowToIterate->(LoadsOfCode)->RunIf->tJava
If possible I would like to be able to do something in the tJava that will skip/continue the current iteration and move onto the next.  I know this can be done using other methods but would specificity like to know about continuing from tFlowToIterate iterations.
Cheers Andy
One Star

Re: Break From Iteration

Ok in its basic form this is very easy, see screen belowe;

continue; to continue or break; to break...
However my job is alot more complex;

Any ideas how i can continue the "loop list" iteration based on the result from the subsequent API call (No records or error code)?
The warning i get in the tJava is "continue cannot be used outside of a loop".