[Turn on line numbering]arg str, len, @stuff; var output, cutoff, firstline, prefix, plen; // takes string and wraps it by words, compared to length, breaks with [(prefix ?= ""), (firstline ?= 0)] = stuff; output = ""; if (firstline) str = prefix + str; plen = strlen(prefix); while (strlen(str) > len) { cutoff = stridx(substr(str, 1, len), " ", -1); if (cutoff <= plen) { output += " " + substr(str, 1, len); str = prefix + substr(str, len + 1); } else { output += " " + substr(str, 1, cutoff - 1); str = prefix + substr(str, cutoff + 1); } } return (output ? output.subrange(3) + " " : "") + str;
// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit