Options
Simple While loop problem
Hi have a simple while loop and I don't know what's wrong, I want the contents of the Line variable spilt by commas to be placed in a structure.
The loop never stops, If I clear the contents of the Line variable in debug then the loop stops and the structure is populated.
Line = ",105,103,125,117,102,116,126,113,112,119,108,109,110,118" WHILE(LENGTH_STRING(Line) > 2){ Sources.ButtonNo[count] = ATOI(REMOVE_STRING(Line, ',', 1)) count=count+1 }
The loop never stops, If I clear the contents of the Line variable in debug then the loop stops and the structure is populated.
Comments
Another thing to bear in mind is that when you hit the last number, there is no longer a comma to remove. So "Line" will be stuck at 3 chars long. You might want to put the whole evaluation inside an if(find_string(Line,',',1)) statement. That way when you're on the last number you'll know because the find_string:comma will fail. you could do something like this:
Thank you.
The function REMOVE_STRING() is not the problem here. Your *logic* is the culprit.
Line 1: evaluates to TRUE if anything is in SOURCEDATA
Line 3: evaluates to TRUE if Obs Cabin2 exists in the Line variable.
Why should a FALSE for Line 3 automatically assume Line 1 is FALSE? They have nothing to do with each other.
Hi, Line 2 should be removing one line at a time from SOURCESDATA, when all lines have gone then line 1 should return FALSE.
Thanks....