Code:
int i;
for(i = 0; i < 5; i++)
{
     //do some things here
}

//and continue without a crash



Code:
while(str_len(strMsg) > 0)
{
    str_trunc(strMsg, 1);
}



and so on...