Cancel
Showing results for 
Search instead for 
Did you mean: 

Doing Loop until cell empty

Valued Contributor
Valued Contributor

Hi everyone,

 

I have a loop that's working nearly perfect.


for var i:=1 to main.yDim loop
  main.erzeugeSubliste(4,i); 
  main[4,i] [1,1] := "Color"; 
  main[4,i] [4,1] := main[5,i]
next

 

Now I have the problem because the yDim is variable the loop is not stopping if the cell is empty.

So I wanted to modify my code that the loop stops while the cell is empty.

 

I tried this:

 

if main [3,i] /= " " then

for var i:=1 to main.yDim loop
  main.erzeugeSubliste(4,i); 
  main[4,i] [1,1] := "Color"; 
  main[4,i] [4,1] := main[5,i]
next

else

doContiunue:= false;

end;

 

but its not working...

 

Can someone help me?

 

Thank You.

Best regards,

IceTea

3 REPLIES

Re: Doing Loop until cell empty

Creator
Creator

Hi IceTea,

 

I'm not sure what u want but my first intention was:

"he hast to put the exception into the loop"

 

so something like this:

 

for var i:=1 to main.yDim loop

  if main [3,i] /= " " then

    main.erzeugeSubliste(4,i); 
    main[4,i] [1,1] := "Color"; 
    main[4,i] [4,1] := main[5,i]

  end;
next

 

or you create a new boolean variable

 

maybe you can specify your question?

Re: Doing Loop until cell empty

Gears Phenom Gears Phenom
Gears Phenom

Hello,

 

Based on the code attempt you have pasted I think I know roughly what you are trying to do.

 

The following untested code should loop until it reaches a empty cell and then stop looping, reguardless of if there is more cells with data futher on within the table.

 

for var i := 1 to main.yDim loop
  if main[3,i] /= "" then
    main.erzeugeSubliste(4,i); 
    main[4,i][1,1] := "Color"; 
    main[4,i][4,1] := main[5,i];
  else
    exitLoop;
  end;
next;

If you instead want it to keep going but ignore any empty cells then you should remove the else case of the if statment and you will get to what C__M has suggested.

 

JamesM

Re: Doing Loop until cell empty

Valued Contributor
Valued Contributor

This was the mistake.

Thank You!

Now its working Smiley Happy