5de @verb #51:"fill_string" this none this rxdo #60 @program #51:"fill_string" this none this "fill(string,width[,prefix])" "tries to cut into substrings of length < along word boundaries. Prefix, if supplied, will be prefixed to the 2nd..last substrings." if (length(args) < 2) width = 2 + player:linelength() prefix = "" else width = args[2] + 1 prefix = {@args, ""}[3] endif if (width < 3 + length(prefix)) return E_INVARG endif string = "$" + args[1] + " $" len = length(string) if (len <= width) last = len - 1 next = len else last = rindex(string[1..width], " ") if (last < (width + 1) / 2) last = width + index(string[width + 1..len], " ") endif next = last while (string[next = next + 1] == " ") endwhile endif while (string[last = last - 1] == " ") endwhile ret = {string[2..last]} width = width - length(prefix) minlast = (width + 1) / 2 while (next < len) string = "$" + string[next..len] len = len - next + 2 if (len <= width) last = len - 1 next = len else last = rindex(string[1..width], " ") if (last < minlast) last = width + index(string[width + 1..len], " ") endif next = last while (string[next = next + 1] == " ") endwhile endif while (string[last = last - 1] == " ") endwhile if (last > 1) ret = {@ret, prefix + string[2..last]} endif endwhile return ret "Last modified by Dax (#789) on Thu Jul 9 17:28:11 1998 EDT." . 0