[Turn off line numbering]
1: arg @suffix;
2: var objname, tmp;
3:
4: // Figure out the suffix from the arguments and child index.
5: [(suffix ?= 0)] = suffix;
6: if (suffix) {
7: // so they dont confuse child_index:
8: if (suffix.is_numeric())
9: throw(~perm, "You cannot specify a numeric suffix.");
10:
11: // so we get correct symbols & it is always lowercase:
12: suffix = lowercase(strsed(suffix, "[^a-z0-9_]+", "", "g"));
13: } else {
14: // get the next valid objname
15: objname = tostr((| .objname() |) || "unknown");
16: tmp = tosym(objname);
17: while ((| lookup(tmp) |)) {
18: child_index++;
19: tmp = tosym(objname + "_" + tostr(child_index));
20: }
21: suffix = tostr(child_index);
22: }
23: return suffix;
["// Created as a part of ColdCore, see: @help Credit"]