5b5 @verb #13:"_list_file" this none this rxdo #789 @program #13:"_list_file" this none this "List the contents of a file for #/@list" if (caller != this) raise(E_PERM) endif set_task_perms(this) {dobj, iobjstr, args} = args if (!dobj:fileexists(iobjstr)) return player:tell("=> E_INVARG (File not found)") elseif ($file_utils:is_binary(dobj, iobjstr) && !$command_utils:yes_or_no("WARNING: This file appears to be binary, not ascii. Are you sure you want to display it to your screen?")) return player:tell("Aborted.") endif range = {} if (args && (index("0123456789", args[1][1]) || index(args[1], "..") == 1)) if (E_INVARG == (s = $seq_utils:from_string(args[1]))) return this:notify(tostr("Garbled range: ", args[1])) else range = $seq_utils:union(range, s) args = listdelete(args, 1) endif endif code = `dobj:fileread(iobjstr) ! ANY' if (typeof(code) == $ERR) return this:notify(tostr(code)) endif this:notify(tostr(dobj, "!\"", iobjstr, "\" ", dobj:fileaccess(iobjstr))) lineseq = {1, length(code) + 1} range && (lineseq = $seq_utils:intersection(range, lineseq)) if (!lineseq) return this:notify("No lines in that range.") endif for k in [1..length(lineseq) / 2] for i in [lineseq[2 * k - 1]..lineseq[2 * k] - 1] this:notify($html_utils:literal_text(code[i])) $command_utils:suspend_if_needed() endfor endfor "Last modified by Dax (#789) on Tue May 3 13:45:55 2005 MDT." . 0