: : : : Then I suggest a nested while-do loop:
: : : :
: : : : while s <> '' do
: : : : begin
: : : : Part := '';
: : : : while s[1] = ' ' do // Move all the spaces into part
: : : : begin
: : : : Part := Part + s[1];
: : : : Delete(s, 1, 1);
: : : : end;
: : : : while s[1] <> ' ' do // Move all the letters into part
: : : : begin
: : : : Part := Part + s[1];
: : : : Delete(s, 1, 1);
: : : : end;
: : : : // Now part contains the left-most spaces and letters from s
: : : : end;
: : : :
: : : : This code looks complex, but it is quite easy to follow in the debugger. I would suggest that you look at what happens to s and Part while stepping through the code.
: : : :
: : :
: : : OK....yes I see how it works. Nice. How to stop loop when s=''. Get access violation when string is empty. Seems the inside(?) loop looking for ' ' but finds '' and crash. Maybe boolean?
: : :
: : : Bob
: : :
: : :
: : Yes, after the Delete() check if the string is empty and call Break() to get out of the loop.
: :
: Yes, Break that is it. Thank you much. You are big help. One more question. Is this consider inner and outer loop? Sorry, just learning.
:
: Bob
:
The 2 blue loops are considered to be inner loops, while the black loop is the outer loop. In case of 3+ nested loops, 1 or more loop(s) can be considered to be both.