[Turn on line numbering]arg @suffix; var objname, tmp; // Figure out the suffix from the arguments and child index. [(suffix ?= 0)] = suffix; if (suffix) { // so they dont confuse child_index: if (suffix.is_numeric()) throw(~perm, "You cannot specify a numeric suffix."); // so we get correct symbols & it is always lowercase: suffix = lowercase(strsed(suffix, "[^a-z0-9_]+", "", "g")); } else { // get the next valid objname objname = tostr((| .objname() |) || "unknown"); tmp = tosym(objname); while ((| lookup(tmp) |)) { child_index++; tmp = tosym(objname + "_" + tostr(child_index)); } suffix = tostr(child_index); } return suffix;
// Created as a part of ColdCore, see: @help Credit