2000 grep any any any #9780 rdo "grep %1[b=%2][a=%3][o=%4][l=%5=l] [r=%6] "; " "; "Take into acount that %1 through %5 are optional"; "You can redefine any of the arguments you give "; "Adding them again afterwards. "; " "; "Spaces and brackets dont matter, you simply have"; "To make sure all args are seperated by either. "; " "; "The order of all args doesnt matter, but keep in"; "Mind that the verb executes a grep every range "; "Argument it receives. "; " "; "All arguments can be used in a + - way, meaning "; "That you can add and substract information from "; "Each arg. Use common sense to figure out how it"; "It used in each case. "; " "; " %1 use '.'-props ':'-verbs '!'-files "; " %2 use 'r' 'd' 'o' 'x' 'w' 'f' 'c' bits "; " %3 use {dobjstr, prepstr, iobjstr},'$'-0 "; " %4 use '$' for object owner, do like %6 "; " %5 use a STR style text for the line "; " %6 use '$' for max_obj, '~' for x to z "; " "; "Example of grep for any verbs containing 'x=1' "; " grep v[l=x=1=l] 0~$ "; " "; object = verb_info(this, verb); if (!(arguments = argstr) || arguments == "syntax") return player:tell($help_utils:fetch(tostr(this, ":", verb))); elseif (player == object[1]) if (index(object[2], "x") && player == this) return set_verb_info(this, verb, strsub(object[2], "x", "")); endif object = object[1]; else object = $no_one; endif arguments = $su:tokenise(arguments, {"[", "]", " ", "l=", "=l"}); while ((a = "l=" in arguments) && (b = "=l" in arguments)) arguments[a..b] = tostr(arguments[a..b]); $cmd_utils:suspend_if_needed(0); endwhile "[" in arguments && (arguments = $list_utils:setremove_all(arguments, "[")); "]" in arguments && (arguments = $list_utils:setremove_all(arguments, "]")); " " in arguments && (arguments = $list_utils:setremove_all(arguments, " ")); lines = nolines = verbs = noverbs = props = noprops = files = nofiles = bits = nobits = objects = owners = noowners = {}; argumes = noargumes = {{}, {}, {}}; for arg in (arguments) if (`arg[1..2] == "b=" ! E_RANGE') for x in ($com_utils:range(`arg[3..$] ! E_RANGE => {}')) for z in ($su:char_list(x[3])) if (x[2] == "add") bits = setadd(bits, z); nobits = setremove(nobits, z); elseif (x[2] == "sus") bits = setremove(bits, z); bits = setadd(bits, z); endif $cmd_utils:suspend_if_needed(0); endfor $cmd_utils:suspend_if_needed(0); endfor elseif (`arg[1..2] == "a=" ! E_RANGE') a = $su:tokenise(`arg[3..$] ! E_RANGE => ""', {" ", ",", "{", "}"}); a = setremove(setremove(a, "{"), "}"); a = {a[1], a[3], a[5]}; for x in [1..length(a)] for z in ($com_utils:range(a[x])) if (z[3] == "$") continue; elseif (z[2] == "add") argumes[x] = setadd(argumes[x], z[3]); noargumes[x] = setremove(noargumes[x], z[3]); elseif (z[2] == "sus") noargumes[x] = setadd(noargumes[x], z[3]); argumes[x] = setremove(argumes[x], z[3]); endif $cmd_utils:suspend_if_needed(0); endfor $cmd_utils:suspend_if_needed(0); endfor elseif (`arg[1..2] == "l=" ! E_RANGE') arg = `arg[3..$ - 2] ! E_RANGE => ""'; if (`arg[1..2] == "-=" ! E_RANGE') nolines = setadd(nolines, arg[3..$]); lines = setremove(lines, arg[3..$]); else `arg[1..2] == "+=" ! E_RANGE' && (arg = arg[3..$]); lines = setadd(lines, arg); nolines = setremove(nolines, arg); endif elseif (`args[1..2] == "o=" ! E_RANGE') arg = $com_utils:Range(`arg[3..$] ! E_RANGE => ""'); for x in (arg) if (x[2] == "add") owners = setadd(owners, x[3]); noowners = setremove(noowners, x[3]); elseif (x[2] == "sus") noowners = setadd(noowners, x[3]); owners = setremove(owners, x[3]); endif $cmd_utils:suspend_if_needed(0); endfor elseif (`arg[1..2] == "r=" ! E_RANGE') arg = $com_utils:range(`arg[3..$] ! E_RANGE => ""', {{"+", 1, "add"}, {"-", 1, "sus"}, {"$", 2, max_object()}}); for x in (arg) if (index(x[3], "~")) x[3] = $su:explode(x[3], "~"); `x[3][1][1] == "#" ! E_RANGE => 0' || (x[3][1] = tostr("#", x[3][1])); `x[3][$][1] == "#" ! E_RANGE => 0' || (x[3][$] = tostr("#", x[3][$])); for z in [tonum(x[3][1])..tonum(x[3][$])] if (x[2] == "add") objects = setadd(objects, z); elseif (x[2] == "sus") objects = setremove(objects, z); endif $cmd_utils:suspend_if_needed(0); endfor else `x[3][1] == "#" ! E_RANGE => 0' || (x[3] = tostr("#", x[3])); x[3] = tonum(x[3]); if (x[2] == "add") objects = setadd(objects, x[3]); else objects = setremove(objects, x[3]); endif endif $cmd_utils:suspend_if_needed(0); endfor "This isnt actually range parsing anymore, but the grep executing"; for x in (objects) ok = 1; tok = 0; for z in (owners) results = object:eval(z)[2]; if (typeof(results[2]) == OBJ && valid(results[2])) tok = 1; elseif (typeof(results[2]) == INT && results[2]) tok = 1; endif $cmd_utils:suspend_if_needed(0); endfor tok || (ok = 0); tok = 1; for z in (noowners) results = object:eval(z)[2]; if (typeof(results[2]) == OBJ && valid(results[2])) tok = 0; elseif (typeof(results[2]) == INT && results[2]) tok = 0; endif $cmd_utils:suspend_if_needed(0); endfor tok && (ok = 0); "f" in bits && !(`x:is_fertile_for(object) ! ANY => x.f' || object:controls(x)) && (ok = 0); "w" in bits && !x.w && (ok = 0); "f" in nobits && (`x:is_fertile_for(object) ! ANY => x.f' || object:controls(x)) && (ok = 0); "w" in nobits && x.w && (ok = 0); $cmd_utils:suspend_if_needed(0); endfor else arg = $com_utils:range(`arg[3..$] ! E_RANGE => ""'); looking = "verbs"; for x in (arg) if (x[2] == "add") if (x[3] == ".") props = 1; looking = "props"; elseif (x[3] == ":") verbs = 1; looking = "verbs"; elseif (x[3] == "!") files = 1; looking = "files"; elseif (looking == "props" && typeof(props) == LIST) props = setadd(props, x[3]); typeof(noprops) == LIST && (noprops = setremove(noprops, x[3])); elseif (looking == "verbs" && typeof(verbs) == LIST) verbs = setadd(verbs, x[3]); typeof(noverbs) == LIST && (noverbs = setremove(noverbs, x[3])); elseif (looking == "files" && typeof(files) == LIST) files = setadd(files, x[3]); typeof(nofiles) == LIST && (nofiles = setremove(nofiles, x[3])); endif elseif (x[2] == "sus") if (x[3] == "." && props == 1) props = {}; noprops = 1; elseif (x[3] == ":" && verbs == 1) verbs = {}; noverbs = 1; elseif (x[3] == "!" && files == 1) files = {}; nofiles = 1; elseif (x[3] == ".") props = {}; looking = "props"; elseif (x[3] == ":") verbs = {}; looking = "verbs"; elseif (x[3] == "!") files = {}; looking = "files"; elseif (looking == "props" && typeof(props) == LIST) noprops = setadd(noprops, x[3]); 1a1 elseif (looking == "verbs" && typeof(verbs) == LIST) noverbs = setadd(noverbs, x[3]); elseif (looking == "files" && typeof(files) == LIST) nofiles = setadd(nofiles, x[3]); endif endif $cmd_utils:suspend_if_needed(0); endfor endif $cmd_utils:suspend_if_needed(0); endfor "Last modified by Quadir (#9780) on Mon Feb 7 14:15:59 2000 MST."; . 0