Skip to main content
18-Opal
April 28, 2022
Solved

SKIPPING PARTICULAR LOOPS in Programming

  • April 28, 2022
  • 2 replies
  • 5203 views

Hi

How do I select which particular loops to skip. Depending on a condition I may want to skip loop "k" or "j" or "k" AND "j" and just get the next "i"

How do I go about doing that in similar scenario to below:

ppal_0-1651108917124.png

 

Best answer by Werner_E

Can you explain what the reasoning behind your mod condition is?

If the only goal is to eliminate the rows which contain at least one character of "Reject", this function might do the job:

Werner_E_0-1651576913712.png

The function is not ORIGIN-aware, so ORIGIN=0 is assumed.

The "break" isn't mandatory. If you delete it, the function is just working a little bit more inefficient because every time ALL characters in "Reject" are tested even after a character was already found in the string.

2 replies

24-Ruby IV
April 28, 2022

Yo can use not the for but the while loop.

25-Diamond I
April 28, 2022

How about putting a "break" command in the else branch and also an "if Flag=1  break" after the k-loop to also skip the j-loop ?

18-Opal
April 28, 2022

I think the break function will work for me but I will need to do the following in the programming

 

Run a for loop

 

Read a file (Has rows of data)

Carry out Operations (This results in some rows of data removed)

I want to use the β€œnew” data file to be read read again  ( I dont know how to create the file and then get it to read it as a new file for the next iteration)

 

Keep doing till loop finished and data weeded out.

 

I think it may be an append or just a new writetext function function ?

 

Thanks for your help.

25-Diamond I
May 3, 2022

You may consider posting your worksheet along with a sample data. Its cumbersome to debug a picture.
It also would help if you describe in detail you would like to achieve with your program.

 

Nonetheless some remarks:

You should not use string[reject but rather a separate variable because String changes in the program loop.

In the last if you redefine String in a way so that String probably gets less elements so the outer loop eventually must fail. It may help to change the outer loop to a while loop using an appropriate condition.