Help again! This time it's how to combine OR with a while loop.
while (strcmp(at," "))
{
atco++;
at = mid(t,atco,1);
}
Works like a charm.
while (strcmp(at," ") || strcmp(at,"?") || strcmp(at,"!"))
{
atco++;
at = mid(t,atco,1);
}
Does not work. Crashes, rather.
What now?
Oh yes, this is supossed to break a text line at spaces and punctuation.
Basically, right here you mixed up && with ||. It's not really 'crashing' so much as going irresponsive because it's in an infinite loop without ShowPage().
But yeah, if you want a loop that runs only while ALL of the conditionals are true (ie. run until ANY of the conditions is false), use && in your while().
while (strcmp(at," ") && strcmp(at,"?") && strcmp(at,"!"))
{
atco++;
at = mid(t,atco,1);
}
Alternatively, use an until() statement. until(condition) is equivalent to while(!(condition)):
until (strcmp(at," ") || strcmp(at,"?") || strcmp(at,"!"))
{
atco++;
at = mid(t,atco,1);
}
What Grue said will also work!
Also, if you're breaking a line at spaces/punctuation, is this for word-wrapping a textbox? In that case, you could just use WrapText. (I'd link to the doc entry for that, but the docs are linking to the wrong thing at the moment -- Grue? :o).