string utilities #20
Aliases: string utilities, string, utils
74 verbs · 12 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
space(noansi) | this none this | rxd | #20 | 24 |
left(noansi) | this none this | rxd | #20 | 13 |
right(noansi) | this none this | rxd | #20 | 13 |
centre center | this none this | rxd | #20 | 13 |
columnize columnise | this none this | rxd | #20 | 17 |
from_list | this none this | rxd | #20 | 14 |
english_list | this none this | rxd | #20 | 24 |
names_of | this none this | rxd | #20 | 8 |
from_seconds | this none this | rxd | #20 | 30 |
trim | this none this | rxd | #20 | 6 |
triml | this none this | rxd | #20 | 6 |
trimr | this none this | rxd | #20 | 5 |
strip_chars | this none this | rxd | #20 | 6 |
strip_all_but | this none this | rxd | #20 | 11 |
uppercase lowercase | this none this | rxd | #20 | 13 |
capitalize capitalise | this none this | rxd | #20 | 5 |
literal_object | this none this | rxd | #20 | 27 |
match | this none this | rxd | #20 | 38 |
match_str*ing | this none this | rxd | #20 | 40 |
match_object | this none this | rxd | #20 | 20 |
match_player | this none this | rxd | #20 | 34 |
match_player_or_object | this none this | rxd | #20 | 24 |
find_prefix | this none this | rxd | #20 | 13 |
index_d*elimited | this none this | rxd | #20 | 3 |
is_integer is_numeric | this none this | rxd | #20 | 18 |
ordinal | this none this | rxd | #20 | 8 |
group_number | this none this | rxd | #20 | 12 |
english_number | this none this | rxd | #20 | 28 |
english_ordinal | this none this | rxd | #20 | 19 |
english_ones | this none this | rxd | #20 | 3 |
english_tens | this none this | rxd | #20 | 10 |
subst*itute | this none this | rxd | #20 | 48 |
substitute_d*elimited | none none none | rxd | #20 | 44 |
_cap_property | this none this | rxd | #20 | 29 |
pronoun_sub | this none this | rxd | #20 | 78 |
pronoun_sub_secure | this none this | rxd | #20 | 9 |
pronoun_quote | this none this | rxd | #20 | 23 |
alt_pronoun_sub | none none none | rxd | #20 | 76 |
explode | this none this | rxd | #20 | 14 |
words | this none this | rxd | #20 | 34 |
word_start | this none this | rxd | #20 | 28 |
to_value | this none this | rxd | #20 | 14 |
prefix_to_value | this none this | rxd | #20 | 23 |
_tolist | this none this | rxd | #20 | 35 |
_unquote | this none this | rxd | #20 | 15 |
_toscalar | this none this | rxd | #20 | 21 |
parse_command | this none this | rxd | #20 | 40 |
from_value | this none this | rxd | #20 | 36 |
print print_suspended | this none this | rxd | #20 | 21 |
reverse | this none this | rxd | #20 | 13 |
char_list | this none this | rxd | #20 | 11 |
regexp_quote | this none this | rxd | #20 | 9 |
connection_hostname_bsd | this none this | rxd | #20 | 3 |
connection_hostname | this none this | rxd | #20 | 2 |
from_value_suspended | this none this | rxd | #20 | 40 |
end_expression | this none this | rxd | #20 | 42 |
first_word | this none this | rxd | #20 | 30 |
common | this none this | rxd | #20 | 13 |
title_list*c list_title*c | this none this | rxd | #20 | 14 |
name_and_number nn name_and_number_list nn_list | this none this | rxd | #20 | 13 |
columnize_suspended columnise_suspended | this none this | rxd | #20 | 18 |
a_or_an | this none this | rxd | #20 | 25 |
index_all | this none this | rxd | #20 | 16 |
match_stringlist match_string_list | this none this | rx | #20 | 38 |
from_ASCII | this none this | rxd | #20 | 5 |
to_ASCII | this none this | rxd | #20 | 4 |
abbreviated_value | this none this | rxd | #20 | 14 |
_abbreviated_value | this none this | rxd | #20 | 69 |
match_suspended | this none this | rxd | #20 | 40 |
incr_alpha | this none this | rxd | #20 | 11 |
is_float | this none this | rxd | #20 | 4 |
redirect_ansi left right center centre columnize columnise space | this none this | rx | #20 | 7 |
get_say_verb_prep | this none this | rxd | #20 | 11 |
get_say_verb | this none this | rxd | #20 | 64 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
digits | #20 | rc | #2 | "0123456789" |
ascii | #20 | rc | #2 | " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" |
alphabet | #20 | rc | #2 | "abcdefghijklmnopqrstuvwxyz" |
use_article_a | #20 | r | #36 | {"unit", "unix", "one", "once", "utility"} |
use_article_an | #20 | r | #36 | {} |
tab | #20 | rc | #2 | "\t" |
help_msg | #79 | rc | #2 | list of 99{"For a complete description of a given verb, do `help $string_utils:verbname'", "", " Conversion routines:", "", ":from_list (list [,sep]) => \"foo1foo2foo3\"", ":english_list (str-list[,none-str[,and-str[, sep]]]) => \"foo1, foo2, and foo3\"", ":title_list*c (obj-list[,none-str[,and-str[, sep]]]) => \"foo1, foo2, and foo3\"", " or => \"Foo1, foo2, and foo3\"", ":from_value (value [,quoteflag [,maxlistdepth]]) => \"{foo1, foo2, foo3}\"", ":print (value) => value in string", ":abbreviated_value (value, options) => short value in string", "", ":to_value (string) => {success?, value or error message}", ":prefix_to_value(string) => {rest of string, value} or {0, error message}", "", ":english_number(42) => \"forty-two\"", ":english_ordinal(42) => \"forty-second\"", ":ordinal(42) => \"42nd\"", ":group_number(42135 [,sep]) => \"42,135\"", ":from_ASCII(65) => \"A\"", ":to_ASCII(\"A\") => 65", ":from_seconds(number) => string of rough time passed in large increments", "", ":name_and_number(obj [,sep]) => \"ObjectName (#obj)\"", ":name_and_number_list({obj1,obj2} [,sep])", " => \"ObjectName1 (#obj1) and ObjectName2 (#obj2)\"", ":nn is an alias for :name_and_number.", ":nn_list is an alias for :name_and_number_list.", "", " Type checking:", "", ":is_integer (string) => return true if string is composed entirely of digits", ":is_float (string) => return true if string holds just a floating point", "", " Parsing:", "", ":explode (string,char) -- string => list of words delimited by char", ":words (string) -- string => list of words (as with command line parser)", ":word_start (string) -- string => list of start-end pairs.", ":first_word (string) -- string => list {first word, rest of string} or {}", ":char_list (string) -- string => list of characters in string", "", ":parse_command (cmd_line [,player] => mimics action of builtin parser", "", " Matching:", "", ":find_prefix (prefix, string-list)=>list index of element starting with prefix", ":index_delimited(string,target[,case]) =>index of delimited string occurrence", ":index_all (string, target string) => list of all matched positions", ":common (first string, second string) => length of longest common prefix", ":match (string, [obj-list, prop-name]+) => matching object", ":match_player (string-list[,me-object]) => list of matching players", ":match_object (string, location) => default object match...", ":match_player_or_object (string, location) => object then player matching", ":literal_object (string) => match against #xxx, $foo", ":match_stringlist (string, targets) => match against static strings", ":match_string (string, wildcard target,options)=> match against a wildcard", ":get_say_verb(string) => 3rd person 'says' synonym to match emoticons in string.", ":get_say_verb_prep(string) => A preposition to match a 'says' verb synonym.", "", " Pretty printing:", "", ":space (n/string[,filler]) => n spaces", ":left (string,width[,filler]) => left justified string in field ", ":right (string,width[,filler]) => right justified string in field", ":center/re (string,width[,lfiller[,rfiller]]) => centered string in field", ":columnize/se (list,n[,width]) => list of strings in n columns", "", " Substitutions", "", ":substitute (string,subst_list [,case]) -- general substitutions.", ":substitute_delimited (string,subst_list [,case])", " -- like subst, but uses index_delim", ":pronoun_sub (string/list[,who[,thing[,location]]])", " -- pronoun substitutions.", ":pronoun_sub_secure (string[,who[,thing[,location]]],default)", " -- substitute and check for names.", ":pronoun_quote (string/list/subst_list) -- quoting for pronoun substitutions.", "", " Miscellaneous string munging:", "", ":trim (string) => string with outside whitespace removed.", ":triml (string) => string with leading whitespace removed.", ":trimr (string) => string with trailing whitespace removed.", ":strip_chars (string,chars) => string with all chars in `chars' removed.", ":strip_all_but(string,chars) => string with all chars not in `chars' removed.", ":capitalize/se(string) => string with first letter capitalized.", ":uppercase/lowercase(string) => string with all letters upper or lowercase.", ":names_of (list of OBJ) => string with names and object numbers of items.", ":a_or_an (word) => \"a\" or \"an\" as appropriate for that word.", ":reverse (string) => \"gnirts\"", ":incr_alpha (string) => \"increments\" the string alphabetically", "", " A useful property:", "", ".alphabet => \"abcdefghijklmnopqrstuvwxyz\"", "", "Suspended versions (with _suspended at end of name) for", " :print :from_value :columnize/se :match"} |
key | #1 | c | #2 | <clear> |
aliases | #1 | rc | #2 | {"string utilities", "string", "utils"} |
description | #1 | rc | #2 | {"This is the string utilities utility package. See `help $string_utils' for more details."} |
object_size | #1 | r | #36 | {85546, -1090650497} |
html | #1 | rc | #2 | <clear> |
Ancestry
Ancestors (nearest first): #79 Generic Utilities Package → #1 Root Class
Children: none
Call graph
Showing 48 of 67 verbs; 19 not shown.
Source
space(noansi)
Referenced by
none
Source
1"space(len,fill) returns a string of length abs(len) consisting of copies of fill. If len is negative, fill is anchored on the right instead of the left."; 2{n, ?fill = " "} = args; 3if (typeof(n) == STR) 4n = length(n); 5endif 6if (n > 1000) 7"Prevent someone from crashing the moo with $string_utils:space($maxint)"; 8return E_INVARG; 9endif 10if (" " != fill) 11fill = fill + fill; 12fill = fill + fill; 13fill = fill + fill; 14elseif ((n = abs(n)) < 70) 15return " "[1..n]; 16else 17fill = " "; 18endif 19m = (n - 1) / length(fill); 20while (m) 21fill = fill + fill; 22m = m / 2; 23endwhile 24return (n > 0) ? fill[1..n] | fill[($ + 1) + n..$];
left(noansi)
Referenced by
none
Source
1"$string_utils:left(string,width[,filler])"; 2""; 3"Assures that <string> is at least <width> characters wide. Returns <string> if it is at least that long, or else <string> followed by enough filler to make it that wide. If <width> is negative and the length of <string> is greater than the absolute value of <width>, then the <string> is cut off at <width>."; 4""; 5"The <filler> is optional and defaults to \" \"; it controls what is used to fill the resulting string when it is too short. The <filler> is replicated as many times as is necessary to fill the space in question."; 6{text, len, ?fill = " "} = args; 7abslen = abs(len); 8out = tostr(text); 9if (length(out) < abslen) 10return out + this:space(length(out) - abslen, fill); 11else 12return (len > 0) ? out | out[1..abslen]; 13endif
right(noansi)
Referenced by
none
Source
1"$string_utils:right(string,width[,filler])"; 2""; 3"Assures that <string> is at least <width> characters wide. Returns <string> if it is at least that long, or else <string> preceded by enough filler to make it that wide. If <width> is negative and the length of <string> is greater than the absolute value of <width>, then <string> is cut off at <width> from the right."; 4""; 5"The <filler> is optional and defaults to \" \"; it controls what is used to fill the resulting string when it is too short. The <filler> is replicated as many times as is necessary to fill the space in question."; 6{text, len, ?fill = " "} = args; 7abslen = abs(len); 8out = tostr(text); 9if ((lenout = length(out)) < abslen) 10return this:space(abslen - lenout, fill) + out; 11else 12return (len > 0) ? out | out[($ - abslen) + 1..$]; 13endif
centre center
Referenced by
- #58:@d*isplay line 196:
$string_utils:centre - #58:@d*isplay line 198:
$string_utils:centre - #92:@paste line 16:
$string_utils:center - #92:@paste line 21:
$string_utils:center - #92:@pasteto line 12:
$string_utils:center - #92:@pasteto line 16:
$string_utils:center - #95:@ansi-t*est line 3:
$string_utils:center
Source
1"$string_utils:center(string,width[,lfiller[,rfiller]])"; 2""; 3"Assures that <string> is at least <width> characters wide. Returns <string> if it is at least that long, or else <string> preceded and followed by enough filler to make it that wide. If <width> is negative and the length of <string> is greater than the absolute value of <width>, then the <string> is cut off at <width>."; 4""; 5"The <lfiller> is optional and defaults to \" \"; it controls what is used to fill the left part of the resulting string when it is too short. The <rfiller> is optional and defaults to the value of <lfiller>; it controls what is used to fill the right part of the resulting string when it is too short. In both cases, the filler is replicated as many times as is necessary to fill the space in question."; 6{text, len, ?lfill = " ", ?rfill = lfill} = args; 7out = tostr(text); 8abslen = abs(len); 9if (length(out) < abslen) 10return (this:space((abslen - length(out)) / 2, lfill) + out) + this:space(((abslen - length(out)) + 1) / -2, rfill); 11else 12return (len > 0) ? out | out[1..abslen]; 13endif
columnize columnise
Referenced by
- #6:tell_contents line 16:
$string_utils:columnize - #57:display_list line 27:
$string_utils:columnize - #91:tell_contents line 20:
$string_utils:columnize - #91:@stats line 17:
$string_utils:columnize - #91:@stats line 18:
$string_utils:columnize - #91:@stats line 26:
$string_utils:columnize - #91:@stats line 33:
$string_utils:columnize - #91:cash line 9:
$string_utils:columnize - #91:cash line 12:
$string_utils:columnize - #100:@doomed line 10:
$string_utils:columnize - #100:@protected line 7:
$string_utils:columnize - #102:command-list line 1:
$string_utils:columnize - #107:tell_contents line 20:
$string_utils:columnize - #134:list line 25:
$string_utils:columnize - #141:description line 7:
$string_utils:columnize - #141:description line 28:
$string_utils:columnize - #141:description line 29:
$string_utils:columnize - #141:description line 31:
$string_utils:columnize - #141:pick_race line 26:
$string_utils:columnize - #141:pick_org line 23:
$string_utils:columnize - #143:show_who line 10:
$string_utils:columnize
Source
1"columnize (items, n [, width]) - Turn a one-column list of items into an n-column list. 'width' is the last character position that may be occupied; it defaults to a standard screen width. Example: To tell the player a list of numbers in three columns, do 'player:tell_lines ($string_utils:columnize ({1, 2, 3, 4, 5, 6, 7}, 3));'."; 2{items, n, ?width = 79} = args; 3height = ((length(items) + n) - 1) / n; 4items = {@items, @$list_utils:make((height * n) - length(items), "")}; 5colwidths = {}; 6for col in [1..n - 1] 7colwidths = listappend(colwidths, 1 - (((width + 1) * col) / n)); 8endfor 9result = {}; 10for row in [1..height] 11line = tostr(items[row]); 12for col in [1..n - 1] 13line = tostr(this:left(line, colwidths[col]), " ", items[row + (col * height)]); 14endfor 15result = listappend(result, line[1..min($, width)]); 16endfor 17return result;
from_list
Referenced by
- #3:@exits line 9:
$string_utils:from_list - #3:@entrances line 9:
$string_utils:from_list - #4:@create line 15:
$string_utils:from_list - #4:@create line 16:
$string_utils:from_list - #4:@recreate line 18:
$string_utils:from_list - #4:@recreate line 19:
$string_utils:from_list - #4:@dig line 8:
$string_utils:from_list - #4:@check-chp*arent line 21:
su:from_list - #4:@measure line 13:
$string_utils:from_list - #4:@measure line 29:
$string_utils:from_list - #4:@measure line 39:
$string_utils:from_list - #4:@measure line 75:
$string_utils:from_list - #4:@measure line 97:
$string_utils:from_list - #6:page line 24:
$string_utils:from_list - #6:@addalias*# line 57:
$string_utils:from_list - #6:@rmalias*# line 45:
$string_utils:from_list - #11:@* line 11:
$string_utils:from_list - #11:@* line 12:
$string_utils:from_list - #20:parse_command line 25:
$string_utils:from_list - #20:parse_command line 26:
$string_utils:from_list - #20:parse_command line 29:
$string_utils:from_list - #24:check_player_request line 48:
$string_utils:from_list - #24:do_make_player line 9:
$string_utils:from_list - #24:do_register line 7:
$string_utils:from_list - #24:newt_player line 24:
$string_utils:from_list - #30:index line 6:
su:from_list - #32:update_all line 7:
$string_utils:from_list - #32:update_all line 11:
$string_utils:from_list - #32:update_all line 12:
$string_utils:from_list - #32:update_all line 13:
$string_utils:from_list - #32:@ansi-setup line 69:
$string_utils:from_list - #40:parse_folder_spec line 19:
$string_utils:from_list - #40:parse_mailread_cmd line 25:
$string_utils:from_list - #40:@unrmm*ail line 6:
$string_utils:from_list - #40:@@sendmail line 77:
$string_utils:from_list - #45:look_self line 3:
$string_utils:from_list - #47:send line 27:
$string_utils:from_list - #49:com*pile line 19:
$string_utils:from_list - #49:com*pile line 39:
$string_utils:from_list - #49:com*pile line 45:
$string_utils:from_list - #49:working_on line 7:
$string_utils:from_list - #49:parse_invoke line 13:
$string_utils:from_list - #49:verb_args line 8:
$string_utils:from_list - #50:m*ove line 12:
$string_utils:from_list - #50:parse_range line 60:
$string_utils:from_list - #57:@toad line 53:
$string_utils:from_list - #57:parse_templist_duration line 25:
$string_utils:from_list - #58:@args*# line 29:
$string_utils:from_list - #58:@rmverb*# line 9:
$string_utils:from_list - #58:@rmverb*# line 42:
$string_utils:from_list - #58:@prog*ram line 30:
$string_utils:from_list - #58:@d*isplay line 154:
$string_utils:from_list - #58:@check-p*roperty line 14:
$string_utils:from_list - #58:@dump line 56:
$string_utils:from_list - #58:@list*# line 108:
$string_utils:from_list - #59:dump_preamble line 10:
$string_utils:from_list - #61:_parse line 10:
$string_utils:from_list - #65:show_@mail line 2:
$string_utils:from_list - #65:show_@mail line 5:
$string_utils:from_list - #65:parse_news line 4:
$string_utils:from_list - #68:parse line 29:
$string_utils:from_list - #71:exit_alias_builder line 11:
$string_utils:from_list - #76:show_verb_args line 2:
$string_utils:from_list - #76:parse_verb_args line 11:
$string_utils:from_list - #77:parse_create_flags line 10:
$string_utils:from_list - #77:parse_dig_room line 4:
$string_utils:from_list - #90:parse_out_object line 31:
$string_utils:from_list - #91:transfer_ammo line 18:
$string_utils:from_list - #91:short_desc_matches line 6:
$string_utils:from_list - #91:short_desc_matches line 8:
$string_utils:from_list - #95:@ansi-s*tatus line 42:
$string_utils:from_list - #108:replicate line 12:
$string_utils:from_list - #108:replicate line 24:
$string_utils:from_list - #108:replicate line 26:
$string_utils:from_list - #116:ask line 60:
$string_utils:from_list - #118:@vways line 9:
$string_utils:from_list - #118:@vdig line 8:
$string_utils:from_list
Source
1"$string_utils:from_list(list [, separator])"; 2"Return a string being the concatenation of the string representations of the elements of LIST, each pair separated by the string SEPARATOR, which defaults to the empty string."; 3{thelist, ?separator = ""} = args; 4if (separator == "") 5return tostr(@thelist); 6elseif (thelist) 7result = tostr(thelist[1]); 8for elt in (listdelete(thelist, 1)) 9result = tostr(result, separator, elt); 10endfor 11return result; 12else 13return ""; 14endif
english_list
Referenced by
- #1:examine_names line 3:
$string_utils:english_list - #3:@add-exit line 36:
$string_utils:english_list - #3:@add-entrance line 27:
$string_utils:english_list - #3:@resident*s line 15:
$string_utils:english_list - #4:@create line 45:
$string_utils:english_list - #4:@recreate line 43:
$string_utils:english_list - #4:@cl*asses line 29:
$string_utils:english_list - #6:@listgag line 5:
$string_utils:english_list - #6:@listgag line 17:
$string_utils:english_list - #6:@sw*eep line 32:
$string_utils:english_list - #6:@addalias*# line 54:
$string_utils:english_list - #6:@addalias*# line 60:
$string_utils:english_list - #6:@addalias*# line 89:
$string_utils:english_list - #6:@addalias*# line 93:
$string_utils:english_list - #6:@rmalias*# line 42:
$string_utils:english_list - #6:@rmalias*# line 48:
$string_utils:english_list - #6:@rmalias*# line 79:
$string_utils:english_list - #6:@rmalias*# line 83:
$string_utils:english_list - #6:@gender line 5:
$string_utils:english_list - #6:@exam*ine line 11:
$string_utils:english_list - #6:@add-feature line 28:
$string_utils:english_list - #6:@lastlog line 42:
$string_utils:english_list - #6:@users line 4:
$string_utils:english_list - #10:? line 15:
$string_utils:english_list - #14:from_msg_seq line 27:
$string_utils:english_list - #14:%from_msg_seq line 29:
$string_utils:english_list - #14:to_msg_seq line 28:
$string_utils:english_list - #14:%to_msg_seq line 29:
$string_utils:english_list - #20:_cap_property line 13:
$string_utils:english_list - #20:title_list*c line 14:
$string_utils:english_list - #20:name_and_number line 13:
$string_utils:english_list - #24:show_netwho_from_listing line 69:
su:english_list - #29:from_msg_seq line 24:
$string_utils:english_list - #29:to_msg_seq line 23:
$string_utils:english_list - #29:%to_msg_seq line 24:
$string_utils:english_list - #39:why_bad_name line 9:
$string_utils:english_list - #40:notify_mail line 15:
$string_utils:english_list - #40:notify_mail line 22:
$string_utils:english_list - #40:@unsub*scribe line 43:
$string_utils:english_list - #43:english_time line 40:
$string_utils:english_list - #46:resolve_addr line 37:
$string_utils:english_list - #46:match_failed line 9:
$string_utils:english_list - #46:name_list line 1:
$string_utils:english_list - #46:from_msg_seq line 23:
$string_utils:english_list - #46:%from_msg_seq line 25:
$string_utils:english_list - #46:to_msg_seq line 24:
$string_utils:english_list - #46:%to_msg_seq line 25:
$string_utils:english_list - #47:who line 16:
$string_utils:english_list - #47:subsc*ribe line 25:
$string_utils:english_list - #47:unsubsc*ribe line 23:
$string_utils:english_list - #49:uncomment line 27:
$string_utils:english_list - #51:object_match_failed line 26:
$string_utils:english_list - #56:player_match_result line 38:
$string_utils:english_list - #56:read_lines_escape line 12:
$string_utils:english_list - #57:@blacklist line 57:
$string_utils:english_list - #57:@blacklist line 74:
$string_utils:english_list - #57:@blacklist line 88:
$string_utils:english_list - #57:@blacklist line 106:
$string_utils:english_list - #57:@blacklist line 132:
$string_utils:english_list - #57:@blacklist line 147:
$string_utils:english_list - #57:@blacklist line 170:
$string_utils:english_list - #58:@d*isplay line 196:
$string_utils:english_list - #58:@gethelp line 31:
$string_utils:english_list - #68:set line 39:
$string_utils:english_list - #68:desc_type line 16:
$string_utils:english_list - #68:parsechoice line 6:
$string_utils:english_list - #74:help_msg line 18:
$string_utils:english_list - #83:help_msg line 18:
$string_utils:english_list - #84:list line 12:
$string_utils:english_list - #90:tell_ways line 5:
$string_utils:english_list - #90:tell_ways line 7:
$string_utils:english_list - #90:parse_refuse_arguments line 42:
$string_utils:english_list - #90:whois line 69:
$string_utils:english_list - #91:@stats line 42:
$string_utils:english_list - #91:@stats line 43:
$string_utils:english_list - #95:@ansi-title line 29:
$string_utils:english_list - #104:@fakes line 9:
$string_utils:english_list - #104:@fakes line 12:
$string_utils:english_list - #104:@seatalias line 10:
$string_utils:english_list - #104:@seatalias line 15:
$string_utils:english_list - #104:who_do_what line 35:
$string_utils:english_list - #104:who_do_what line 47:
$string_utils:english_list - #116:l*ook line 17:
$string_utils:english_list - #116:l*ook line 32:
$string_utils:english_list - #118:add_virtual_exit line 9:
$string_utils:english_list - #118:@vlock line 30:
$string_utils:english_list - #119:tell_exits line 12:
$string_utils:english_list - #133:join line 2:
$string_utils:english_list - #133:help_msg line 1:
$string_utils:english_list - #135:view line 15:
$string_utils:english_list - #138:group_booguns line 32:
$string_utils:english_list - #141:facts line 25:
$string_utils:english_list
Source
1"Prints the argument (must be a list) as an english list, e.g. {1, 2, 3} is printed as \"1, 2, and 3\", and {1, 2} is printed as \"1 and 2\"."; 2"Optional arguments are treated as follows:"; 3" Second argument is the string to use when the empty list is given. The default is \"nothing\"."; 4" Third argument is the string to use in place of \" and \". A typical application might be to use \" or \" instead."; 5" Fourth argument is the string to use instead of a comma (and space). Gary_Severn's deranged mind actually came up with an application for this. You can ask him."; 6" Fifth argument is a string to use after the penultimate element before the \" and \". The default is to have a comma without a space."; 7{things, ?nothingstr = "nothing", ?andstr = " and ", ?commastr = ", ", ?finalcommastr = ","} = args; 8nthings = length(things); 9if (nthings == 0) 10return nothingstr; 11elseif (nthings == 1) 12return tostr(things[1]); 13elseif (nthings == 2) 14return tostr(things[1], andstr, things[2]); 15else 16ret = ""; 17for k in [1..nthings - 1] 18if (k == (nthings - 1)) 19commastr = finalcommastr; 20endif 21ret = tostr(ret, things[k], commastr); 22endfor 23return tostr(ret, andstr, things[nthings]); 24endif
names_of
Referenced by
- #4:@kids line 7:
$string_utils:names_of - #4:@contents line 13:
$string_utils:names_of - #4:@par*ents line 11:
$string_utils:names_of - #4:@location*s line 9:
$string_utils:names_of - #50:lis*t line 11:
$string_utils:names_of - #80:measurement_task_body line 59:
$string_utils:names_of - #80:measurement_task_body line 67:
$string_utils:names_of - #90:names_of line 2:
$string_utils:names_of
Source
1"Return a string of the names and object numbers of the objects in a list."; 2line = ""; 3for item in (args[1]) 4if ((typeof(item) == OBJ) && valid(item)) 5line = (((line + item.name) + "(") + tostr(item)) + ") "; 6endif 7endfor 8return $string_utils:trimr(line);
from_seconds
Referenced by
- #4:@measure line 18:
$string_utils:from_seconds - #6:look_self line 8:
$string_utils:from_seconds - #6:@age line 14:
$string_utils:from_seconds - #6:@age line 25:
$string_utils:from_seconds - #12:last line 42:
$string_utils:from_seconds - #31:boot line 5:
$string_utils:from_seconds - #32:show_who_listing line 71:
su:from_seconds - #32:show_who_listing line 71:
su:from_seconds - #57:@guests line 30:
su:from_seconds - #57:@guests line 30:
su:from_seconds - #59:show_who_listing line 87:
su:from_seconds - #59:show_who_listing line 87:
su:from_seconds - #80:do_summary line 6:
$string_utils:from_seconds - #91:look_self line 10:
$string_utils:from_seconds - #91:look_state line 8:
$string_utils:from_seconds
Source
1":from_seconds(number of seconds) => returns a string containing the rough increment of days, or hours if less than a day, or minutes if less than an hour, or lastly in seconds."; 2":from_seconds(86400) => \"a day\""; 3":from_seconds(7200) => \"two hours\""; 4minute = 60; 5hour = 60 * minute; 6day = 24 * hour; 7secs = args[1]; 8if (secs > day) 9count = secs / day; 10unit = "day"; 11article = "a"; 12elseif (secs > hour) 13count = secs / hour; 14unit = "hour"; 15article = "an"; 16elseif (secs > minute) 17count = secs / minute; 18unit = "minute"; 19article = "a"; 20else 21count = secs; 22unit = "second"; 23article = "a"; 24endif 25if (count == 1) 26time = tostr(article, " ", unit); 27else 28time = tostr(count, " ", unit, "s"); 29endif 30return time;
trim
Referenced by
- #4:@set*prop line 20:
$string_utils:trim - #20:get_say_verb line 22:
this:trim - #40:@@sendmail line 34:
$string_utils:trim - #40:@@sendmail line 41:
$string_utils:trim - #40:@quick*send line 19:
$string_utils:trim - #43:time_sub line 43:
$string_utils:trim - #43:time_sub line 47:
$string_utils:trim - #43:time_sub line 51:
$string_utils:trim - #43:time_sub line 65:
$string_utils:trim - #47:local_editing_info line 1:
$string_utils:trim - #50:lis*t line 40:
$string_utils:trim - #50:ins*ert line 7:
$string_utils:trim - #56:read line 11:
$string_utils:trim - #56:yes_or_no line 9:
$string_utils:trim - #90:internal_at line 2:
$string_utils:trim - #100:@update-reg*istration line 4:
$string_utils:trim - #104:@outdoor*s line 3:
$string_utils:trim - #135:dis_match_object line 3:
$string_utils:trim - #143:get_parsed line 4:
su:trim
Source
1":trim (string [, space]) -- remove leading and trailing spaces"; 2""; 3"`space' should be a character (single-character string); it defaults to \" \". Returns a copy of string with all leading and trailing copies of that character removed. For example, $string_utils:trim(\"***foo***\", \"*\") => \"foo\"."; 4{string, ?space = " "} = args; 5m = match(string, tostr("[^", space, "]%(.*[^", space, "]%)?%|$")); 6return string[m[1]..m[2]];
triml
Referenced by
- #20:words line 7:
$string_utils:triml - #20:prefix_to_value line 4:
this:triml - #20:_tolist line 2:
this:triml - #20:_tolist line 31:
this:triml - #32:@ansi-setup line 65:
$string_utils:triml - #46:__convert_new line 28:
$string_utils:triml - #46:__convert_new line 33:
$string_utils:triml - #46:__convert_new line 35:
$string_utils:triml
Source
1":triml(string [, space]) -- remove leading spaces"; 2""; 3"`space' should be a character (single-character string); it defaults to \" \". Returns a copy of string with all leading copies of that character removed. For example, $string_utils:triml(\"***foo***\", \"*\") => \"foo***\"."; 4{string, ?what = " "} = args; 5m = match(string, tostr("[^", what, "]%|$")); 6return string[m[1]..$];
trimr
Referenced by
- #6:?* line 4:
$string_utils:trimr - #6:?* line 6:
$string_utils:trimr - #20:names_of line 8:
$string_utils:trimr - #56:read_lines_escape line 23:
$string_utils:trimr - #59:callers_text line 29:
su:trimr
Source
1":trimr(string [, space]) -- remove trailing spaces"; 2""; 3"`space' should be a character (single-character string); it defaults to \" \". Returns a copy of string with all trailing copies of that character removed. For example, $string_utils:trimr(\"***foo***\", \"*\") => \"***foo\"."; 4{string, ?what = " "} = args; 5return string[1..rmatch(string, tostr("[^", what, "]%|^"))[2]];
strip_chars
Referenced by
- #20:get_say_verb line 22:
this:strip_chars - #33:from_string line 5:
su:strip_chars - #58:@dump line 55:
$string_utils:strip_chars - #71:exit_alias_builder line 3:
$string_utils:strip_chars - #71:exit_alias_builder line 41:
$string_utils:strip_chars - #71:exit_alias_builder line 47:
$string_utils:strip_chars - #71:exit_alias_builder line 65:
$string_utils:strip_chars - #124:parse line 2:
$string_utils:strip_chars - #124:parse line 3:
$string_utils:strip_chars - #124:parse line 7:
$string_utils:strip_chars - #124:parse line 36:
$string_utils:strip_chars - #125:encrypt line 7:
$string_utils:strip_chars
Source
1":strip_chars(string,chars) => string with chars removed"; 2{subject, stripped} = args; 3for i in [1..length(stripped)] 4subject = strsub(subject, stripped[i], ""); 5endfor 6return subject;
strip_all_but
Referenced by
none
Source
1":strip_all_but(string,keep) => string with chars not in `keep' removed."; 2"`keep' is used in match() so if it includes ], ^, or -,"; 3"] should be first, ^ should be other from first, and - should be last."; 4string = args[1]; 5wanted = ("[" + args[2]) + "]+"; 6output = ""; 7while (m = match(string, wanted)) 8output = output + string[m[1]..m[2]]; 9string = string[m[2] + 1..$]; 10endwhile 11return output;
uppercase lowercase
Referenced by
- #10:? line 10:
$string_utils:uppercase - #32:@ansi-setup line 171:
$string_utils:uppercase - #35:fixpos line 2:
$string_utils:uppercase - #35:fixpos line 5:
$string_utils:lowercase - #61:to_text line 5:
$string_utils:uppercase - #71:exit_alias_builder line 39:
$string_utils:lowercase - #71:exit_alias_builder line 50:
$string_utils:lowercase - #71:exit_alias_builder line 64:
$string_utils:lowercase - #88:_is_funky_case line 2:
$string_utils:uppercase - #88:_is_funky_case line 4:
$string_utils:lowercase - #125:encrypt line 7:
$string_utils:lowercase
Source
1"lowercase(string) -- returns a lowercase version of the string."; 2"uppercase(string) -- returns the uppercase version of the string."; 3string = args[1]; 4from = caps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 5to = lower = "abcdefghijklmnopqrstuvwxyz"; 6if (verb == "uppercase") 7from = lower; 8to = caps; 9endif 10for i in [1..26] 11string = strsub(string, from[i], to[i], 1); 12endfor 13return string;
capitalize capitalise
Referenced by
- #1:titlec line 1:
$string_utils:capitalize - #6:titlec line 1:
$string_utils:capitalize - #6:@mode line 22:
$string_utils:capitalize - #20:title_list*c line 9:
$string_utils:capitalize - #40:@typo line 1:
$string_utils:capitalize - #41:get_conj*ugation line 19:
$string_utils:capitalize - #57:@toad line 53:
$string_utils:capitalize - #62:description line 2:
$string_utils:capitalize - #65:check_replyto line 6:
$string_utils:capitalize - #68:set line 33:
$string_utils:capitalize - #71:exit_alias_builder line 9:
$string_utils:capitalize - #91:tell line 18:
$string_utils:capitalize - #91:my_huh line 3:
$string_utils:capitalize - #91:g*et line 31:
$string_utils:capitalize - #91:dr*op line 50:
$string_utils:capitalize - #91:gi*ve line 25:
$string_utils:capitalize - #104:push line 7:
$string_utils:capitalize - #104:who_do_what line 37:
$string_utils:capitalize - #104:who_do_what line 49:
$string_utils:capitalize - #104:attack line 9:
$string_utils:capitalize - #104:huh line 19:
$string_utils:capitalize - #116:ask line 30:
$string_utils:capitalize - #117:wear_msg line 1:
$string_utils:capitalize - #125:encrypt line 8:
$string_utils:capitalize - #141:facts line 8:
$string_utils:capitalize - #141:facts line 20:
$string_utils:capitalize - #164:pr*ess line 30:
$string_utils:capitalize
Source
1"capitalizes its argument."; 2if ((string = args[1]) && (i = index("abcdefghijklmnopqrstuvwxyz", string[1], 1))) 3string[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i]; 4endif 5return string;
literal_object
Referenced by
- #6:@eject line 15:
$string_utils:literal_object - #10:_match_player line 5:
$string_utils:literal_object - #20:match_object line 6:
this:literal_object - #20:match_player line 27:
$string_utils:literal_object - #30:objectdoc line 2:
$string_utils:literal_object - #46:match line 8:
$string_utils:literal_object - #46:_parse_from line 17:
$string_utils:literal_object - #47:not-to*: line 19:
$string_utils:literal_object - #51:match line 17:
$string_utils:literal_object - #57:@fullprops line 10:
$string_utils:literal_object - #58:@disown line 10:
$string_utils:literal_object - #58:@core line 5:
$string_utils:literal_object - #62:@destroy-demo line 6:
$string_utils:literal_object - #90:last_huh line 6:
$string_utils:literal_object - #90:last_huh line 8:
$string_utils:literal_object - #134:stock line 1:
$string_utils:literal_object
Source
1"Matches args[1] against literal objects: #xxxxx, $variables, *mailing-lists, and username. Returns the object if successful, $failed_match else."; 2string = args[1]; 3if (!string) 4return $nothing; 5elseif ((string[1] == "#") && (E_TYPE != (object = $code_utils:toobj(string)))) 6return object; 7elseif (string[1] == "~") 8return this:match_player(string[2..$], #0); 9elseif ((string[1] == "*") && (length(string) > 1)) 10return $mail_agent:match_recipient(string); 11elseif (string[1] == "$") 12string[1..1] = ""; 13object = #0; 14while (pn = string[1..(dot = index(string, ".")) ? dot - 1 | $]) 15if ((!$object_utils:has_property(object, pn)) || (typeof(object = object.(pn)) != OBJ)) 16return $failed_match; 17endif 18string = string[length(pn) + 2..$]; 19endwhile 20if ((object == #0) || (typeof(object) == ERR)) 21return $failed_match; 22else 23return object; 24endif 25else 26return $failed_match; 27endif
match
Referenced by
- #1:match line 2:
$string_utils:match - #3:match line 2:
$string_utils:match - #3:@remove-entrance line 6:
$string_utils:match - #6:@ungag line 13:
$string_utils:match - #6:@remove-feature line 7:
$string_utils:match - #40:my_match_recipient line 7:
$string_utils:match - #47:not-to*: line 24:
$string_utils:match - #47:not-to*: line 25:
$string_utils:match - #47:not-to*: line 26:
$string_utils:match - #51:match line 19:
$string_utils:match - #51:match line 21:
$string_utils:match - #58:@disown line 16:
$string_utils:match - #91:gi*ve line 35:
$string_utils:match - #91:speak*ing line 16:
$string_utils:match - #116:@addlang*uage line 4:
$string_utils:match - #116:@rmlang*uage line 4:
$string_utils:match - #123:wr*ite line 3:
$string_utils:match
Source
1"$string_utils:match(string [, obj-list, prop-name]*)"; 2"Each obj-list should be a list of objects or a single object, which is treated as if it were a list of that object. Each prop-name should be string naming a property on every object in the corresponding obj-list. The value of that property in each case should be either a string or a list of strings."; 3"The argument string is matched against all of the strings in the property values."; 4"If it exactly matches exactly one of them, the object containing that property is returned. If it exactly matches more than one of them, $ambiguous_match is returned."; 5"If there are no exact matches, then partial matches are considered, ones in which the given string is a prefix of some property string. Again, if exactly one match is found, the object with that property is returned, and if there is more than one match, $ambiguous_match is returned."; 6"Finally, if there are no exact or partial matches, then $failed_match is returned."; 7subject = args[1]; 8if (subject == "") 9return $nothing; 10endif 11no_exact_match = no_partial_match = 1; 12for i in [1..length(args) / 2] 13prop_name = args[(2 * i) + 1]; 14for object in ((typeof(olist = args[2 * i]) == LIST) ? olist | {olist}) 15if (valid(object)) 16if (typeof(str_list = `object.(prop_name) ! E_PERM, E_PROPNF => {}') != LIST) 17str_list = {str_list}; 18endif 19if (subject in str_list) 20if (no_exact_match) 21no_exact_match = object; 22elseif (no_exact_match != object) 23return $ambiguous_match; 24endif 25else 26for string in (str_list) 27if (index(string, subject) != 1) 28elseif (no_partial_match) 29no_partial_match = object; 30elseif (no_partial_match != object) 31no_partial_match = $ambiguous_match; 32endif 33endfor 34endif 35endif 36endfor 37endfor 38return no_exact_match && (no_partial_match && $failed_match);
match_str*ing
Referenced by
none
Source
1"* wildcard matching. Returns a list of what the *s actually matched. Won't cath every match, if there are several ways to parse it."; 2"Example: $string_utils:match_string(\"Jack waves to Jill\",\"* waves to *\") returns {\"Jack\", \"Jill\"}"; 3"Optional arguments: numbers are interpreted as case-sensitivity, strings as alternative wildcards."; 4{what, targ, @rest} = args; 5wild = "*"; 6case = ret = {}; 7what = what + "&^%$"; 8targ = targ + "&^%$"; 9for y in (rest) 10if (typeof(y) == STR) 11wild = y; 12elseif (typeof(y) == INT) 13case = {y}; 14endif 15endfor 16while (targ != "") 17if (z = index(targ, wild)) 18part = targ[1..z - 1]; 19else 20z = length(targ); 21part = targ; 22endif 23n = (part == "") ? 1 | index(what, part, @case); 24if (n) 25ret = listappend(ret, what[1..n - 1]); 26what = what[(z + n) - 1..$]; 27targ = targ[z + 1..$]; 28else 29return 0; 30endif 31endwhile 32if (ret == {}) 33return what == ""; 34elseif (ret == {""}) 35return 1; 36elseif (ret[1] == "") 37return ret[2..$]; 38else 39return 0; 40endif
match_object
Referenced by
- #1:match_object line 3:
$string_utils:match_object - #6:my_match_object line 2:
$string_utils:match_object - #6:@exam*ine line 6:
$string_utils:match_object - #18:get_topic line 5:
$string_utils:match_object - #18:dump_topic line 4:
$string_utils:match_object - #20:parse_command line 27:
$string_utils:match_object - #20:parse_command line 33:
$string_utils:match_object - #30:verbdoc line 3:
$string_utils:match_object - #60:get_topic line 2:
$string_utils:match_object - #60:find_topics line 4:
$string_utils:match_object - #60:dump_topic line 1:
$string_utils:match_object - #63:request line 5:
$string_utils:match_object
Source
1":match_object(string,location[,someone])"; 2"Returns the object matching the given string for someone, on the assumption that s/he is in the given location. `someone' defaults to player."; 3"This first tries :literal_object(string), \"me\"=>someone,\"here\"=>location, then player:match(string) and finally location:match(string) if location is valid."; 4"This is the default algorithm for use by room :match_object() and player :my_match_object() verbs. Player verbs that are calling this directly should probably be calling :my_match_object instead."; 5{string, here, ?who = player} = args; 6if ($failed_match != (object = this:literal_object(string))) 7return object; 8elseif (string == "me") 9return who; 10elseif (string == "here") 11return here; 12elseif ((valid(pobject = who:match(string)) && (string in {@pobject.aliases, pobject.name})) || (!valid(here))) 13"...exact match in player or room is bogus..."; 14return pobject; 15elseif ((valid(hobject = here:match(string)) && (string in {@hobject.aliases, hobject.name})) || (pobject == $failed_match)) 16"...exact match in room or match in player failed completely..."; 17return hobject; 18else 19return pobject; 20endif
match_player
Referenced by
- #4:@quota line 5:
$string_utils:match_player - #4:@audit line 3:
$string_utils:match_player - #4:@count line 3:
$string_utils:match_player - #4:@countDB line 3:
$string_utils:match_player - #4:@location*s line 5:
$string_utils:match_player - #4:@measure line 29:
$string_utils:match_player - #4:@measure line 39:
$string_utils:match_player - #4:@measure line 75:
$string_utils:match_player - #6:@ch*eck-full line 12:
$string_utils:match_player - #6:@ch*eck-full line 14:
$string_utils:match_player - #6:page line 6:
$string_utils:match_player - #6:where*is line 4:
$string_utils:match_player - #6:@who line 4:
$string_utils:match_player - #6:@features line 6:
$string_utils:match_player - #6:@lastlog line 3:
$string_utils:match_player - #6:@age line 4:
$string_utils:match_player - #10:w*ho line 13:
$string_utils:match_player - #20:literal_object line 8:
this:match_player - #20:match_player_or_object line 16:
$string_utils:match_player - #24:do_register line 8:
$string_utils:match_player - #40:@add-notify line 7:
$string_utils:match_player - #40:@add-notify line 20:
$string_utils:match_player - #46:match_recipient line 11:
$string_utils:match_player - #46:match_recipient line 12:
$string_utils:match_player - #47:pri*nt line 3:
$string_utils:match_player - #50:lis*t line 16:
$string_utils:match_player - #57:@chown*# line 12:
$string_utils:match_player - #57:@grant line 13:
$string_utils:match_player - #57:@programmer line 2:
$string_utils:match_player - #57:@toad line 17:
$string_utils:match_player - #57:@quota line 7:
$string_utils:match_player - #57:kill_aux_wizard_parse line 18:
$string_utils:match_player - #57:@net-who line 13:
su:match_player - #57:@newt line 9:
$string_utils:match_player - #57:@unnewt line 8:
$string_utils:match_player - #57:@new-password line 6:
$string_utils:match_player - #57:@temp-newt line 3:
$string_utils:match_player - #57:@deprog*rammer line 26:
$string_utils:match_player - #57:@summon line 3:
$string_utils:match_player - #58:@prop*erty line 41:
$string_utils:match_player - #58:@verb line 47:
$string_utils:match_player - #58:@forked line 17:
$string_utils:match_player - #58:@kill line 21:
$string_utils:match_player - #58:@pros*pectus line 3:
$string_utils:match_player - #58:#* line 20:
$string_utils:match_player - #58:@forked-v*erbose line 17:
$string_utils:match_player - #58:@greprop*s line 11:
$string_utils:match_player - #62:match line 5:
$string_utils:match_player - #90:@join line 6:
$string_utils:match_player - #90:@find line 20:
$string_utils:match_player - #90:internal_at line 13:
$string_utils:match_player - #90:@refusals line 3:
$string_utils:match_player - #90:parse_refuse_arguments line 24:
$string_utils:match_player - #90:@stats line 5:
$string_utils:match_player - #90:@award line 10:
$string_utils:match_player - #91:quickpage line 20:
$string_utils:match_player - #91:quickpage line 39:
$string_utils:match_player - #91:follow line 3:
$string_utils:match_player - #92:@pasteto line 4:
$string_utils:match_player - #95:@who line 8:
$string_utils:match_player - #100:@save line 5:
$string_utils:match_player - #100:@retire*-fully line 4:
$string_utils:match_player - #100:@retire*-fully line 5:
$string_utils:match_player - #143:get_parsed line 23:
su:match_player - #143:pub-ban line 4:
$string_utils:match_player - #164:pr*ess line 6:
$string_utils:match_player - #165:dr*op line 12:
$string_utils:match_player
Source
1"match_player(name,name,...) => {obj,obj,...}"; 2"match_player(name[,meobj]) => obj"; 3"match_player({name,...}[,meobj]) => {obj,...}"; 4"objs returned are either players, $failed_match, $ambiguous_match, or $nothing in the case of an empty string."; 5"meobj (what to return for instances of `me') defaults to player; if given and isn't actually a player, `me' => $failed_match"; 6retstr = 0; 7me = player; 8if ((length(args) < 2) || (typeof(me = args[2]) == OBJ)) 9me = (valid(me) && is_player(me)) ? me | $failed_match; 10if (typeof(args[1]) == STR) 11strings = {args[1]}; 12retstr = 1; 13"return a string, not a list"; 14else 15strings = args[1]; 16endif 17else 18strings = args; 19me = player; 20endif 21found = {}; 22for astr in (strings) 23if (!astr) 24aobj = $nothing; 25elseif (astr == "me") 26aobj = me; 27elseif (valid(aobj = $string_utils:literal_object(astr)) && is_player(aobj)) 28"astr is a valid literal object number of some player, so we are done."; 29else 30aobj = $player_db:find(astr); 31endif 32found = {@found, aobj}; 33endfor 34return retstr ? found[1] | found;
match_player_or_object
Referenced by
- #3:@resident*s line 23:
$string_utils:match_player_or_object - #6:@gag*! line 10:
$string_utils:match_player_or_object
Source
1"Accepts any number of strings, attempts to match those strings first against objects in the room, and if no objects by those names exist, matches against player names (and \"#xxxx\" style strings regardless of location). Returns a list of valid objects so found."; 2"Unlike $string_utils:match_player, does not include in the list the failed and ambiguous matches; instead has built-in error messages for such objects. This should probably be improved. Volunteers?"; 3if (!args) 4return; 5endif 6unknowns = {}; 7objs = {}; 8"We have to do something icky here. Parallel walk the victims and args lists. When it's a valid object, then it's a player. If it's an invalid object, try to get an object match from the room. If *that* fails, complain."; 9for i in [1..length(args)] 10if (valid(o = player.location:match_object(args[i]))) 11objs = {@objs, o}; 12else 13unknowns = {@unknowns, args[i]}; 14endif 15endfor 16victims = $string_utils:match_player(unknowns); 17for i in [1..length(victims)] 18if (!valid(victims[i])) 19player:tell("Could not find ", unknowns[i], " as either an object or a player."); 20else 21objs = {@objs, victims[i]}; 22endif 23endfor 24return objs;
find_prefix
Referenced by
- #6:@last-c*onnection line 8:
$string_utils:find_prefix - #6:@mode line 10:
$string_utils:find_prefix - #6:@features line 13:
$string_utils:find_prefix - #41:set line 7:
$string_utils:find_prefix - #43:from_day line 8:
$string_utils:find_prefix - #43:from_month line 8:
$string_utils:find_prefix - #90:parse_refuse_arguments line 12:
$string_utils:find_prefix - #90:parse_refuse_arguments line 14:
$string_utils:find_prefix
Source
1"find_prefix(prefix, string-list) => list index of something starting with prefix, or 0 or $ambiguous_match."; 2{subject, choices} = args; 3answer = 0; 4for i in [1..length(choices)] 5if (index(choices[i], subject) == 1) 6if (answer == 0) 7answer = i; 8else 9answer = $ambiguous_match; 10endif 11endif 12endfor 13return answer;
index_d*elimited
Referenced by
none
Source
1"index_delimited(string,target[,case_matters]) is just like the corresponding call to the builtin index() but instead only matches on occurences of target delimited by word boundaries (i.e., not preceded or followed by an alphanumeric)"; 2args[2] = ("%(%W%|^%)" + $string_utils:regexp_quote(args[2])) + "%(%W%|$%)"; 3return (m = match(@args)) ? m[3][1][2] + 1 | 0;
is_integer is_numeric
Referenced by
- #10:parse_command line 13:
$string_utils:is_numeric - #33:from_string line 11:
su:is_numeric - #33:from_string line 16:
su:is_numeric - #33:from_string line 24:
su:is_numeric - #43:parse_english_time_interval line 23:
$string_utils:is_numeric
Source
1"Usage: is_numeric(string)"; 2" is_integer(string)"; 3"Is string numeric (composed of one or more digits possibly preceded by a minus sign)? This won't catch floating points."; 4"Return true or false"; 5return match(args[1], "^ *[-+]?[0-9]+ *$"); 6digits = "1234567890"; 7if (!(string = args[1])) 8return 0; 9endif 10if (string[1] == "-") 11string = string[2..length(string)]; 12endif 13for i in [1..length(string)] 14if (!index(digits, string[i])) 15return 0; 16endif 17endfor 18return 1;
ordinal
Referenced by
- #80:measurement_task line 17:
$string_utils:ordinal - #80:measurement_task_nofork line 6:
$string_utils:ordinal
Source
1":short_ordinal(1) => \"1st\",:short_ordinal(2) => \"2nd\",etc..."; 2string = tostr(n = args[1]); 3n = abs(n) % 100; 4if (((n / 10) != 1) && ((n % 10) in {1, 2, 3})) 5return string + {"st", "nd", "rd"}[n % 10]; 6else 7return string + "th"; 8endif
group_number
Referenced by
- #4:@count line 11:
$string_utils:group_number - #4:@measure line 17:
$string_utils:group_number - #4:@measure line 19:
$string_utils:group_number - #6:@memory line 22:
su:group_number - #6:@memory line 22:
su:group_number - #6:@memory line 22:
su:group_number - #6:@memory line 22:
su:group_number - #6:@memory line 30:
su:group_number - #6:@memory line 30:
su:group_number - #6:@memory line 30:
su:group_number - #6:@memory line 30:
su:group_number - #6:@memory line 32:
su:group_number - #21:do_audit line 42:
$string_utils:group_number - #58:@d*isplay line 131:
$string_utils:group_number - #80:display_quota line 23:
$string_utils:group_number - #80:display_quota line 23:
$string_utils:group_number - #80:display_quota_summary line 2:
$string_utils:group_number - #80:display_quota_summary line 3:
$string_utils:group_number - #80:display_quota_summary line 5:
$string_utils:group_number - #80:display_quota_summary line 7:
$string_utils:group_number - #80:do_summary line 5:
$string_utils:group_number - #99:@list-ch*eckpoints line 7:
$string_utils:group_number
Source
1"$string_utils:group_number(n [, sep_char])"; 2""; 3"Converts N to a string, inserting commas (or copies of SEP_CHAR, if given) every three digits, counting from the right. For example, $string_utils:group_number(1234567890) returns the string \"1,234,567,890\"."; 4{n, ?comma = ","} = args; 5result = ""; 6sign = (n < 0) ? "-" | ""; 7n = tostr(abs(n)); 8while (length(n) > 3) 9result = (comma + n[$ - 2..$]) + result; 10n = n[1..$ - 3]; 11endwhile 12return (sign + n) + result;
english_number
Referenced by
- #20:english_ordinal line 6:
this:english_number - #20:english_ordinal line 15:
this:english_number - #20:english_ordinal line 18:
this:english_number - #32:ansi_status line 7:
$string_utils:english_number - #32:ansi_status line 7:
$string_utils:english_number - #32:ansi_status line 7:
$string_utils:english_number - #88:help_msg line 4:
$string_utils:english_number - #88:check_length line 2:
$string_utils:english_number
Source
1"$string_utils:english_number(n) -- convert the integer N into English"; 2""; 3"Produces a string containing the English phrase naming the given integer. For example, $string_utils:english_number(-1234) returns the string `negative one thousand two hundred thirty-four'."; 4numb = toint(args[1]); 5if (numb == 0) 6return "zero"; 7endif 8labels = {"", " thousand", " million", " billion"}; 9numstr = ""; 10mod = abs(numb); 11for n in [1..4] 12div = mod % 1000; 13if (div) 14hun = div / 100; 15ten = div % 100; 16outstr = this:english_tens(ten) + labels[n]; 17if (hun) 18outstr = ((this:english_ones(hun) + " hundred") + (ten ? " " | "")) + outstr; 19endif 20if (numstr) 21numstr = (outstr + " ") + numstr; 22else 23numstr = outstr; 24endif 25endif 26mod = mod / 1000; 27endfor 28return ((numb < 0) ? "negative " | "") + numstr;
english_ordinal
Referenced by
none
Source
1"$string_utils:english_ordinal(n) -- convert the integer N into an english ordinal (1 => \"first\", etc...)"; 2numb = toint(args[1]); 3if (numb == 0) 4return "zeroth"; 5elseif (numb % 100) 6hundreds = (abs(numb) > 100) ? this:english_number((numb / 100) * 100) + " " | ((numb < 0) ? "negative " | ""); 7numb = abs(numb) % 100; 8specials = {1, 2, 3, 5, 8, 9, 12, 20, 30, 40, 50, 60, 70, 80, 90}; 9ordinals = {"first", "second", "third", "fifth", "eighth", "ninth", "twelfth", "twentieth", "thirtieth", "fortieth", "fiftieth", "sixtieth", "seventieth", "eightieth", "ninetieth"}; 10if (i = numb in specials) 11return hundreds + ordinals[i]; 12elseif ((numb > 20) && (i = (numb % 10) in specials)) 13return ((hundreds + this:english_tens((numb / 10) * 10)) + "-") + ordinals[i]; 14else 15return (hundreds + this:english_number(numb)) + "th"; 16endif 17else 18return this:english_number(numb) + "th"; 19endif
english_ones
Referenced by
- #20:english_number line 18:
this:english_ones - #20:english_tens line 5:
this:english_ones - #20:english_tens line 9:
this:english_ones
Source
1numb = args[1]; 2ones = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; 3return ones[numb + 1];
english_tens
Referenced by
- #20:english_number line 16:
this:english_tens - #20:english_ordinal line 13:
this:english_tens
Source
1numb = args[1]; 2teens = {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"}; 3others = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}; 4if (numb < 10) 5return this:english_ones(numb); 6elseif (numb < 20) 7return teens[numb - 9]; 8else 9return (others[(numb / 10) - 1] + ((numb % 10) ? "-" | "")) + this:english_ones(numb % 10); 10endif
subst*itute
Referenced by
none
Source
1"subst(string,{{redex1,repl1},{redex2,repl2},{redex3,repl3}...}[,case])"; 2" => returns string with all instances of the strings redex<n> replaced respectively by the strings repl<n>. If the optional argument `case' is given and nonzero, the search for instances of redex<n> is case sensitive."; 3" Substitutions are done in parallel, i.e., instances of redex<n> that appear in any of the replacement strings are ignored. In the event that two redexes overlap, whichever is leftmost in `string' takes precedence. For two redexes beginning at the same position, the longer one takes precedence."; 4""; 5"subst(\"hoahooaho\",{{\"ho\",\"XhooX\"},{\"hoo\",\"mama\"}}) => \"XhooXamamaaXhooX\""; 6"subst(\"Cc: banana\",{{\"a\",\"b\"},{\"b\",\"c\"},{\"c\",\"a\"}},1) => \"Ca: cbnbnb\""; 7{ostr, subs, ?case = 0} = args; 8if (typeof(ostr) != STR) 9return ostr; 10endif 11len = length(ostr); 12" - - - find the first instance of each substitution - -"; 13indices = {}; 14substs = {}; 15for s in (subs) 16if (i = index(ostr, s[1], case)) 17fi = $list_utils:find_insert(indices, i = i - len) - 1; 18while (fi && ((indices[fi] == i) && (length(substs[fi][1]) < length(s[1])))) 19"...give preference to longer redexes..."; 20fi = fi - 1; 21endwhile 22indices = listappend(indices, i, fi); 23substs = listappend(substs, s, fi); 24endif 25endfor 26"- - - - - perform substitutions - "; 27nstr = ""; 28while (substs) 29ind = len + indices[1]; 30sub = substs[1]; 31indices = listdelete(indices, 1); 32substs = listdelete(substs, 1); 33if (ind > 0) 34nstr = (nstr + ostr[1..ind - 1]) + sub[2]; 35ostr = ostr[ind + length(sub[1])..len]; 36len = length(ostr); 37endif 38if (next = index(ostr, sub[1], case)) 39fi = $list_utils:find_insert(indices, next = next - len) - 1; 40while (fi && ((indices[fi] == next) && (length(substs[fi][1]) < length(sub[1])))) 41"...give preference to longer redexes..."; 42fi = fi - 1; 43endwhile 44indices = listappend(indices, next, fi); 45substs = listappend(substs, sub, fi); 46endif 47endwhile 48return nstr + ostr;
substitute_d*elimited
Referenced by
none
Source
1"subst(string,{{redex1,repl1},{redex2,repl2},{redex3,repl3}...}[,case])"; 2"Just like :substitute() but it uses index_delimited() instead of index()"; 3{ostr, subs, ?case = 0} = args; 4if (typeof(ostr) != STR) 5return ostr; 6endif 7len = length(ostr); 8" - - - find the first instance of each substitution - -"; 9indices = {}; 10substs = {}; 11for s in (subs) 12if (i = this:index_delimited(ostr, s[1], case)) 13fi = $list_utils:find_insert(indices, i = i - len) - 1; 14while (fi && ((indices[fi] == i) && (length(substs[fi][1]) < length(s[1])))) 15"...give preference to longer redexes..."; 16fi = fi - 1; 17endwhile 18indices = listappend(indices, i, fi); 19substs = listappend(substs, s, fi); 20endif 21endfor 22"- - - - - perform substitutions - "; 23nstr = ""; 24while (substs) 25ind = len + indices[1]; 26sub = substs[1]; 27indices = listdelete(indices, 1); 28substs = listdelete(substs, 1); 29if (ind > 0) 30nstr = (nstr + ostr[1..ind - 1]) + sub[2]; 31ostr = ostr[ind + length(sub[1])..len]; 32len = length(ostr); 33endif 34if (next = this:index_delimited(ostr, sub[1], case)) 35fi = $list_utils:find_insert(indices, next = next - len) - 1; 36while (fi && ((indices[fi] == next) && (length(substs[fi][1]) < length(sub[1])))) 37"...give preference to longer redexes..."; 38fi = fi - 1; 39endwhile 40indices = listappend(indices, next, fi); 41substs = listappend(substs, sub, fi); 42endif 43endwhile 44return nstr + ostr;
_cap_property
Referenced by
- #20:_cap_property line 11:
this:_cap_property - #20:pronoun_sub line 72:
$string_utils:_cap_property - #20:alt_pronoun_sub line 71:
$string_utils:_cap_property - #41:pronoun_sub line 49:
$string_utils:_cap_property
Source
1"cap_property(what,prop[,ucase]) returns what.(prop) but capitalized if either ucase is true or the prop name specified is capitalized."; 2"If prop is blank, returns what:title()."; 3"If prop is bogus or otherwise irretrievable, returns the error."; 4"If capitalization is indicated, we return what.(prop+\"c\") if that exists, else we capitalize what.(prop) in the usual fashion. There is a special exception for is_player(what)&&prop==\"name\" where we just return what.name if no .namec is provided --- ie., a player's .name is never capitalized in the usual fashion."; 5"If args[1] is a list, calls itself on each element of the list and returns $string_utils:english_list(those results)."; 6{what, prop, ?ucase = 0} = args; 7set_task_perms(caller_perms()); 8if (typeof(what) == LIST) 9result = {}; 10for who in (what) 11result = {@result, this:_cap_property(who, prop, ucase)}; 12endfor 13return $string_utils:english_list(result); 14endif 15ucase = (prop && (strcmp(prop, "a") < 0)) || ucase; 16if (!prop) 17return valid(what) ? ucase ? what:titlec() | what:title() | ((ucase ? "N" | "n") + "othing"); 18elseif ((!ucase) || (typeof(s = `what.(prop + "c") ! ANY') == ERR)) 19if (prop == "name") 20s = valid(what) ? what.name | "nothing"; 21ucase = ucase && (!is_player(what)); 22else 23s = `$object_utils:has_property(what, prop) ? what.(prop) | $player.(prop) ! ANY'; 24endif 25if (ucase && (s && ((typeof(s) == STR) && (((z = index(this.alphabet, s[1], 1)) < 27) && (z > 0))))) 26s[1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[z]; 27endif 28endif 29return (typeof(s) == ERR) ? s | tostr(s);
pronoun_sub
Referenced by
- #0:bf_recycle line 8:
$string_utils:pronoun_sub - #3:confunc line 4:
$string_utils:pronoun_sub - #3:disfunc line 2:
$string_utils:pronoun_sub - #3:who_location_msg line 1:
$string_utils:pronoun_sub - #5:take_failed_msg line 2:
$string_utils:pronoun_sub - #6:page line 25:
$string_utils:pronoun_sub - #6:page line 30:
$string_utils:pronoun_sub - #6:page_origin_msg line 2:
$string_utils:pronoun_sub - #6:@move line 35:
$string_utils:pronoun_sub - #6:@move line 40:
$string_utils:pronoun_sub - #6:@gender line 4:
$string_utils:pronoun_sub - #6:@gender line 11:
$string_utils:pronoun_sub - #6:@age line 29:
$string_utils:pronoun_sub - #7:leave_msg line 2:
$string_utils:pronoun_sub - #8:oclose_msg line 1:
$string_utils:pronoun_sub - #9:mailme line 10:
$string_utils:pronoun_sub - #20:pronoun_sub_secure line 8:
this:pronoun_sub - #20:pronoun_sub_secure line 9:
this:pronoun_sub - #31:extra_confunc_msg line 1:
$string_utils:pronoun_sub - #35:say_action line 18:
$string_utils:pronoun_sub - #35:say_action line 20:
$string_utils:pronoun_sub - #35:say_action line 25:
$string_utils:pronoun_sub - #35:say_action line 31:
$string_utils:pronoun_sub - #35:say_action2 line 12:
$string_utils:pronoun_sub - #35:say_action2 line 13:
$string_utils:pronoun_sub - #40:mail_forward line 2:
$string_utils:pronoun_sub - #45:mail_forward line 4:
$string_utils:pronoun_sub - #45:moderator_forward line 2:
$string_utils:pronoun_sub - #50:done line 14:
$string_utils:pronoun_sub - #50:suck_in line 10:
$string_utils:pronoun_sub - #50:who_location_msg line 4:
$string_utils:pronoun_sub - #54:burn_succeeded_msg line 1:
$string_utils:pronoun_sub - #57:@programmer line 8:
$string_utils:pronoun_sub - #57:toad_msg line 7:
$string_utils:pronoun_sub - #57:toad_msg line 9:
$string_utils:pronoun_sub - #57:toad_msg line 11:
$string_utils:pronoun_sub - #63:request line 23:
$string_utils:pronoun_sub - #71:look_self line 2:
$string_utils:pronoun_sub - #71:take_away_msg line 1:
$string_utils:pronoun_sub - #90:@join line 30:
$string_utils:pronoun_sub - #90:msg_sub line 4:
$string_utils:pronoun_sub - #90:whisper_refused_msg line 2:
$string_utils:pronoun_sub - #91:die line 22:
$string_utils:pronoun_sub - #91:pass_out line 3:
$string_utils:pronoun_sub - #91:pass_out line 9:
$string_utils:pronoun_sub - #91:freeze line 3:
$string_utils:pronoun_sub - #91:freeze line 9:
$string_utils:pronoun_sub - #104:attack_bypass line 18:
$string_utils:pronoun_sub - #104:attack_bypass line 20:
$string_utils:pronoun_sub - #104:big_news line 6:
$string_utils:pronoun_sub - #104:big_news line 7:
$string_utils:pronoun_sub - #104:big_news line 8:
$string_utils:pronoun_sub - #104:disfunc line 2:
$string_utils:pronoun_sub - #107:eat line 2:
$string_utils:pronoun_sub - #107:wander line 12:
$string_utils:pronoun_sub - #107:wander line 67:
$string_utils:pronoun_sub - #107:wander line 69:
$string_utils:pronoun_sub - #107:birth line 18:
$string_utils:pronoun_sub - #107:die line 20:
$string_utils:pronoun_sub - #107:pass_out line 4:
$string_utils:pronoun_sub - #107:pass_out line 8:
$string_utils:pronoun_sub - #107:pass_out line 16:
$string_utils:pronoun_sub - #107:freeze line 3:
$string_utils:pronoun_sub - #107:freeze line 8:
$string_utils:pronoun_sub - #116:die line 27:
$string_utils:pronoun_sub - #116:die line 30:
$string_utils:pronoun_sub - #116:birth line 10:
$string_utils:pronoun_sub - #116:l*ook line 35:
$string_utils:pronoun_sub - #116:pass_out line 4:
$string_utils:pronoun_sub - #116:pass_out line 8:
$string_utils:pronoun_sub - #116:pass_out line 16:
$string_utils:pronoun_sub - #117:title line 5:
$string_utils:pronoun_sub - #118:defaulting_exit_oleave_msg line 1:
$string_utils:pronoun_sub - #119:player_to_loc line 23:
$string_utils:pronoun_sub - #140:o*ut line 6:
$string_utils:pronoun_sub - #140:enter line 6:
$string_utils:pronoun_sub
Source
1"Pronoun (and other things) substitution. See 'help pronouns' for details."; 2"syntax: $string_utils:pronoun_sub(text[,who[,thing[,location[,dobj[,iobj]]]]])"; 3"%s,%o,%p,%q,%r => <who>'s pronouns. <who> defaults to player."; 4"%n,%d,%i,%t,%l,%% => <who>, dobj, iobj, <thing>, location and %"; 5"<thing> defaults to caller; <location> defaults to who.location"; 6"%S,%O,%P,%Q,%R, %N,%D,%I,%T,%L have corresponding capitalized substitutions."; 7" %[#n], %[#d], ... => <who>, dobj, etc.'s object number"; 8"%(foo) => <who>.foo and %(Foo) => <who>.foo capitalized. %[dfoo] => dobj.foo, etc.."; 9"%<foo> -> whatever <who> does when normal people foo. This is determined by calling :verb_sub() on the <who>."; 10"%<d:foo> -> whatever <dobj> does when normal people foo."; 11{string, ?who = player, ?thing = caller, ?where = $nothing, ?dobject = dobj, ?iobject = iobj} = args; 12where = valid(where) ? where | (valid(who) ? who.location | where); 13set_task_perms($no_one); 14if (typeof(string) == LIST) 15plines = {}; 16for line in (string) 17plines = {@plines, this:(verb)(line, who, thing, where)}; 18endfor 19return plines; 20endif 21old = tostr(string); 22new = ""; 23objspec = "nditl"; 24objects = {who, dobject, iobject, thing, where}; 25prnspec = "sopqrSOPQR"; 26prprops = {"ps", "po", "pp", "pq", "pr", "Ps", "Po", "Pp", "Pq", "Pr"}; 27oldlen = length(old); 28while ((prcnt = index(old, "%")) && (prcnt < oldlen)) 29s = old[k = prcnt + 1]; 30if ((s == "<") && (gt = index(old[k + 2..$], ">"))) 31"handling %<verb> "; 32gt = (gt + k) + 1; 33vb = old[k + 1..gt - 1]; 34vbs = who; 35if ((length(vb) > 2) && (vb[2] == ":")) 36" %<d:verb>"; 37vbs = objects[index(objspec, vb[1]) || 1]; 38vb = vb[3..$]; 39endif 40vb = `vbs:verb_sub(vb) ! E_VERBNF => this:(verb)(vb, vbs)'; 41new = (new + old[1..prcnt - 1]) + vb; 42k = gt; 43else 44cp_args = {}; 45if (brace = index("([", s)) 46if (!(w = index(old[k + 1..oldlen], ")]"[brace]))) 47return new + old; 48else 49p = old[prcnt + 2..(k = k + w) - 1]; 50if (brace == 1) 51"%(property)"; 52cp_args = {who, p}; 53elseif (p[1] == "#") 54"%[#n] => object number"; 55s = (o = index(objspec, p[2])) ? tostr(objects[o]) | (("[" + p) + "]"); 56elseif (!(o = index(objspec, p[1]))) 57s = ("[" + p) + "]"; 58else 59" %[dproperty] "; 60cp_args = {objects[o], p[2..w - 1], strcmp(p[1], "a") < 0}; 61endif 62endif 63elseif (o = index(objspec, s)) 64cp_args = {objects[o], "", strcmp(s, "a") < 0}; 65elseif (w = index(prnspec, s, 1)) 66cp_args = {who, prprops[w]}; 67elseif (s == "#") 68s = tostr(who); 69elseif (s != "%") 70s = "%" + s; 71endif 72new = (new + old[1..prcnt - 1]) + ((!cp_args) ? s | ((typeof(sub = $string_utils:_cap_property(@cp_args)) != ERR) ? sub | (("%(" + tostr(sub)) + ")"))); 73endif 74old = old[k + 1..oldlen]; 75oldlen = oldlen - k; 76(ticks_left() < 4000) && suspend(0); 77endwhile 78return new + old;
pronoun_sub_secure
Referenced by
- #92:@paste line 16:
$string_utils:pronoun_sub_secure - #92:@paste line 21:
$string_utils:pronoun_sub_secure
Source
1"$string_utils:pronoun_sub_secure(string[,who[,thing[,location]]], default)"; 2"Do pronoun_sub on string with the arguments given (see help"; 3"string_utils:pronoun_sub for more information). Return pronoun_subbed"; 4"<default> if the subbed string does not contain <who>.name (<who>"; 5"defaults to player)."; 6who = (length(args) > 2) ? args[2] | player; 7default = args[$]; 8result = this:pronoun_sub(@args[1..$ - 1]); 9return this:index_delimited(result, who.name) ? result | this:pronoun_sub(@{default, @args[2..$ - 1]});
pronoun_quote
Referenced by
- #90:msg_sub line 3:
$string_utils:pronoun_quote
Source
1" pronoun_quote(string) => quoted_string"; 2" pronoun_quote(list of strings) => list of quoted_strings"; 3" pronoun_quote(list of {key,string} pairs) => list of {key,quoted_string} pairs"; 4""; 5"Here `quoted' means quoted in the sense of $string_utils:pronoun_sub, i.e., given a string X, the corresponding `quoted' string Y is such that pronoun_sub(Y) => X. For example, pronoun_quote(\"--%Spam%--\") => \"--%%Spam%%--\". This is for including literal text into a string that will eventually be pronoun_sub'ed, i.e., including it in such a way that the pronoun_sub will not expand anything in the included text."; 6""; 7"The 3rd form above (with {key,string} pairs) is for use with $string_utils:substitute(). If you have your own set of substitutions to be done in parallel with the pronoun substitutions, do"; 8""; 9" msg=$string_utils:substitute(msg,$string_utils:pronoun_quote(your_substs));"; 10" msg=$string_utils:pronoun_sub(msg);"; 11if (typeof(what = args[1]) == STR) 12return strsub(what, "%", "%%"); 13else 14ret = {}; 15for w in (what) 16if (typeof(w) == LIST) 17ret = listappend(ret, listset(w, strsub(w[2], "%", "%%"), 2)); 18else 19ret = listappend(ret, strsub(w, "%", "%%")); 20endif 21endfor 22return ret; 23endif
alt_pronoun_sub
Referenced by
none
Source
1"Pronoun (and other things) substitution. See 'help pronouns' for details."; 2"syntax: $string_utils:pronoun_sub(text[,who[,thing[,location]]])"; 3"%s,%o,%p,%q,%r => <who>'s pronouns. <who> defaults to player."; 4"%n,%d,%i,%t,%l,%% => <who>, dobj, iobj, this, <who>.location and %"; 5"%S,%O,%P,%Q,%R, %N,%D,%I,%T,%L have corresponding capitalized substitutions."; 6" %[#n], %[#d], ... => <who>, dobj, etc.'s object number"; 7"%(foo) => <who>.foo and %(Foo) => <who>.foo capitalized. %[dfoo] => dobj.foo, etc.."; 8"%<foo> -> whatever <who> does when normal people foo. This is determined by calling :verb_sub() on the <who>."; 9"%<d:foo> -> whatever <dobj> does when normal people foo."; 10set_task_perms($no_one); 11{string, ?who = player, ?thing = caller, ?where = $nothing} = args; 12where = valid(who) ? who.location | where; 13if (typeof(string) == LIST) 14plines = {}; 15for line in (string) 16plines = {@plines, this:(verb)(line, who, thing, where)}; 17endfor 18return plines; 19endif 20old = tostr(string); 21new = ""; 22objspec = "nditl"; 23objects = {who, dobj, iobj, thing, where}; 24prnspec = "sopqrSOPQR"; 25prprops = {"ps", "po", "pp", "pq", "pr", "Ps", "Po", "Pp", "Pq", "Pr"}; 26oldlen = length(old); 27while ((prcnt = index(old, "%")) && (prcnt < oldlen)) 28s = old[k = prcnt + 1]; 29if ((s == "<") && (gt = index(old[k + 2..$], ">"))) 30"handling %<verb> "; 31gt = (gt + k) + 1; 32vb = old[k + 1..gt - 1]; 33vbs = who; 34if ((length(vb) > 2) && (vb[2] == ":")) 35" %<d:verb>"; 36vbs = objects[index(objspec, vb[1]) || 1]; 37vb = vb[3..$]; 38endif 39vb = $object_utils:has_verb(vbs, "verb_sub") ? vbs:verb_sub(vb) | this:(verb)(vb, vbs); 40new = (new + old[1..prcnt - 1]) + vb; 41k = gt; 42else 43cp_args = {}; 44if (brace = index("([", s)) 45if (!(w = index(old[k + 1..oldlen], ")]"[brace]))) 46return new + old; 47else 48p = old[prcnt + 2..(k = k + w) - 1]; 49if (brace == 1) 50"%(property)"; 51cp_args = {who, p}; 52elseif (p[1] == "#") 53"%[#n] => object number"; 54s = (o = index(objspec, p[2])) ? tostr(objects[o]) | (("[" + p) + "]"); 55elseif (!(o = index(objspec, p[1]))) 56s = ("[" + p) + "]"; 57else 58" %[dproperty] "; 59cp_args = {objects[o], p[2..w - 1], strcmp(p[1], "a") < 0}; 60endif 61endif 62elseif (o = index(objspec, s)) 63cp_args = {objects[o], "", strcmp(s, "a") < 0}; 64elseif (w = index(prnspec, s, 1)) 65cp_args = {who, prprops[w]}; 66elseif (s == "#") 67s = tostr(who); 68elseif (s != "%") 69s = "%" + s; 70endif 71new = (new + old[1..prcnt - 1]) + ((!cp_args) ? s | ((typeof(sub = $string_utils:_cap_property(@cp_args)) != ERR) ? sub | (("%(" + tostr(sub)) + ")"))); 72endif 73old = old[k + 1..oldlen]; 74oldlen = oldlen - k; 75endwhile 76return new + old;
explode
Referenced by
- #1:examine_verbs line 25:
$string_utils:explode - #4:@dig line 49:
$string_utils:explode - #6:@addalias*# line 45:
$string_utils:explode - #6:@addalias*# line 47:
$string_utils:explode - #6:@addalias*# line 79:
$string_utils:explode - #6:@rmalias*# line 31:
$string_utils:explode - #6:@rmalias*# line 33:
$string_utils:explode - #6:@rmalias*# line 69:
$string_utils:explode - #6:@exam*ine line 68:
$string_utils:explode - #10:? line 8:
$string_utils:explode - #20:get_say_verb line 24:
this:explode - #21:parse_names line 5:
$string_utils:explode - #21:parse_names line 8:
$string_utils:explode - #24:check_player_request line 48:
$string_utils:explode - #30:index line 6:
su:explode - #32:@ansi-setup line 62:
$string_utils:explode - #33:from_string line 5:
su:explode - #40:@quick*send line 15:
$string_utils:explode - #43:day line 9:
$string_utils:explode - #43:month line 10:
$string_utils:explode - #43:ampm line 11:
$string_utils:explode - #43:from_ctime line 2:
$string_utils:explode - #43:from_ctime line 7:
$string_utils:explode - #43:time_sub line 79:
$string_utils:explode - #43:time_sub line 81:
$string_utils:explode - #43:mmddyy line 9:
$string_utils:explode - #46:parse_message_seq line 38:
$string_utils:explode - #46:_parse_from line 15:
$string_utils:explode - #46:_parse_date line 1:
$string_utils:explode - #47:check_answer_flags line 32:
$string_utils:explode - #47:subsc*ribe line 9:
$string_utils:explode - #47:unsubsc*ribe line 7:
$string_utils:explode - #50:s*ubst line 8:
$string_utils:explode - #58:@verb line 18:
$string_utils:explode - #58:@dump line 20:
$string_utils:explode - #59:_fix_preps line 8:
$string_utils:explode - #65:parse_replyto line 3:
$string_utils:explode - #65:parse_expire line 3:
$string_utils:explode - #71:exit_alias_builder line 4:
$string_utils:explode - #71:exit_alias_builder line 5:
$string_utils:explode - #71:exit_alias_builder line 6:
$string_utils:explode - #76:parse_verb_args line 3:
$string_utils:explode - #90:parse_refuse_arguments line 2:
$string_utils:explode - #100:do_reap line 11:
$string_utils:explode - #118:@vdig line 48:
$string_utils:explode - #126:encrypt line 18:
$string_utils:explode
Source
1"$string_utils:explode(subject [, break])"; 2"Return a list of those substrings of subject separated by runs of break[1]."; 3"break defaults to space."; 4{subject, ?breakit = {" "}} = args; 5breakit = breakit[1]; 6subject = subject + breakit; 7parts = {}; 8while (subject) 9if ((i = index(subject, breakit)) > 1) 10parts = {@parts, subject[1..i - 1]}; 11endif 12subject = subject[i + 1..$]; 13endwhile 14return parts;
words
Referenced by
- #4:@audit line 9:
$string_utils:words - #4:@newmess*age line 7:
$string_utils:words - #4:@unmess*age line 4:
$string_utils:words - #20:parse_command line 9:
$string_utils:words - #20:get_say_verb line 12:
$string_utils:words - #43:parse_english_time_interval line 12:
$string_utils:words - #49:parse_invoke line 5:
$string_utils:words - #57:parse_templist_duration line 3:
$string_utils:words - #58:@prop*erty line 30:
$string_utils:words - #58:@pros*pectus line 7:
$string_utils:words - #58:@dump line 37:
$string_utils:words - #59:argstr line 23:
$string_utils:words - #71:exit_alias_builder line 7:
$string_utils:words - #90:parse_out_object line 2:
$string_utils:words - #91:short_desc_matches line 2:
$string_utils:words - #116:ask line 8:
$string_utils:words - #116:ask line 59:
$string_utils:words - #116:ask line 60:
$string_utils:words - #116:ask line 79:
$string_utils:words - #119:@maze*-move line 10:
$string_utils:words - #119:go line 5:
$string_utils:words - #125:encrypt line 7:
$string_utils:words
Source
1"This breaks up the argument string into words, the resulting list being obtained exactly the way the command line parser obtains `args' from `argstr'."; 2rest = args[1]; 3"...trim leading blanks..."; 4if (0) 5rest[1..match(rest, "^ *")[2]] = ""; 6endif 7rest = $string_utils:triml(rest); 8if (!rest) 9return {}; 10endif 11quote = 0; 12toklist = {}; 13token = ""; 14pattern = " +%|\\.?%|\""; 15while (m = match(rest, pattern)) 16"... find the next occurence of a special character, either"; 17"... a block of spaces, a quote or a backslash escape sequence..."; 18char = rest[m[1]]; 19token = token + rest[1..m[1] - 1]; 20if (char == " ") 21toklist = {@toklist, token}; 22token = ""; 23elseif (char == "\"") 24"... beginning or end of quoted string..."; 25"... within a quoted string spaces aren't special..."; 26pattern = (quote = !quote) ? "\\.?%|\"" | " +%|\\.?%|\""; 27elseif (m[1] < m[2]) 28"... char has to be a backslash..."; 29"... include next char literally if there is one"; 30token = token + rest[m[2]]; 31endif 32rest[1..m[2]] = ""; 33endwhile 34return (rest || (char != " ")) ? {@toklist, token + rest} | toklist;
word_start
Referenced by
- #4:@set*prop line 19:
$string_utils:word_start - #40:@quick*send line 20:
$string_utils:word_start - #58:@prop*erty line 24:
$string_utils:word_start - #58:@gethelp line 12:
$string_utils:word_start - #59:argstr line 26:
$string_utils:word_start - #59:argstr line 30:
$string_utils:word_start
Source
1"This breaks up the argument string into words, returning a list of indices into argstr corresponding to the starting points of each of the arguments."; 2rest = args[1]; 3"... find first nonspace..."; 4wstart = match(rest, "[^ ]%|$")[1]; 5wbefore = wstart - 1; 6rest[1..wbefore] = ""; 7if (!rest) 8return {}; 9endif 10quote = 0; 11wslist = {}; 12pattern = " +%|\\.?%|\""; 13while (m = match(rest, pattern)) 14"... find the next occurence of a special character, either"; 15"... a block of spaces, a quote or a backslash escape sequence..."; 16char = rest[m[1]]; 17if (char == " ") 18wslist = {@wslist, {wstart, (wbefore + m[1]) - 1}}; 19wstart = (wbefore + m[2]) + 1; 20elseif (char == "\"") 21"... beginning or end of quoted string..."; 22"... within a quoted string spaces aren't special..."; 23pattern = (quote = !quote) ? "\\.?%|\"" | " +%|\\.?%|\""; 24endif 25rest[1..m[2]] = ""; 26wbefore = wbefore + m[2]; 27endwhile 28return (rest || (char != " ")) ? {@wslist, {wstart, wbefore + length(rest)}} | wslist;
to_value
Referenced by
- #4:@set*prop line 28:
$string_utils:to_value - #32:@ansi-setup line 80:
$string_utils:to_value - #32:@ansi-setup line 93:
$string_utils:to_value
Source
1":to_value(string) tries to parse string as a value (i.e., object, number, string, error, or list thereof)."; 2"Returns {1,value} or {0,error_message} according as the attempt was successful or not."; 3result = this:_tolist(string = args[1] + "}"); 4if (result[1] && (result[1] != $string_utils:space(result[1]))) 5return {0, tostr("after char ", length(string) - result[1], ": ", result[2])}; 6elseif (typeof(result[1]) == INT) 7return {0, "missing } or \""}; 8elseif (length(result[2]) > 1) 9return {0, "comma unexpected."}; 10elseif (result[2]) 11return {1, result[2][1]}; 12else 13return {0, "missing expression"}; 14endif
prefix_to_value
Referenced by
- #58:@prop*erty line 24:
$string_utils:prefix_to_value
Source
1":prefix_to_value(string) tries to parse string as a value (i.e., object, number, string, error, or list thereof)."; 2"Returns {rest-of-string,value} or {0,error_message} according as the attempt was successful or not."; 3alen = length(args[1]); 4slen = length(string = this:triml(args[1])); 5if (!string) 6return {0, "empty string"}; 7elseif (w = index("{\"", string[1])) 8result = this:({"_tolist", "_unquote"}[w])(string[2..slen]); 9if (typeof(result[1]) != INT) 10return result; 11elseif (result[1] == 0) 12return {0, "missing } or \""}; 13else 14return {0, result[2], (alen - result[1]) + 1}; 15endif 16else 17thing = string[1..tlen = index(string + " ", " ") - 1]; 18if (typeof(s = this:_toscalar(thing)) != STR) 19return {string[tlen + 1..slen], s}; 20else 21return {0, s, (alen - slen) + 1}; 22endif 23endif
_tolist
Referenced by
- #20:to_value line 3:
this:_tolist
Source
1"_tolist(string) --- auxiliary for :to_value()"; 2rest = this:triml(args[1]); 3vlist = {}; 4if (!rest) 5return {0, {}}; 6elseif (rest[1] == "}") 7return {rest[2..$], {}}; 8endif 9while (1) 10rlen = length(rest); 11if (w = index("{\"", rest[1])) 12result = this:({"_tolist", "_unquote"}[w])(rest[2..rlen]); 13if (typeof(result[1]) == INT) 14return result; 15endif 16vlist = {@vlist, result[2]}; 17rest = result[1]; 18else 19thing = rest[1..tlen = min(index(rest + ",", ","), index(rest + "}", "}")) - 1]; 20if (typeof(s = this:_toscalar(thing)) == STR) 21return {rlen, s}; 22endif 23vlist = {@vlist, s}; 24rest = rest[tlen + 1..rlen]; 25endif 26if (!rest) 27return {0, vlist}; 28elseif (rest[1] == "}") 29return {rest[2..$], vlist}; 30elseif (rest[1] == ",") 31rest = this:triml(rest[2..$]); 32else 33return {length(rest), ", or } expected"}; 34endif 35endwhile
_unquote
Referenced by
none
Source
1"_unquote(string) (auxiliary for :to_value())"; 2"reads string as if it were preceded by a quote, reading up to the closing quote if any, then returns the corresponding unquoted string."; 3" => {0, string unquoted} if there is no closing quote"; 4" => {original string beyond closing quote, string unquoted} otherwise"; 5rest = args[1]; 6result = ""; 7while (m = match(rest, "\\.?%|\"")) 8"Find the next special character"; 9if (rest[pos = m[1]] == "\"") 10return {rest[pos + 1..$], result + rest[1..pos - 1]}; 11endif 12result = (result + rest[1..pos - 1]) + rest[pos + 1..m[2]]; 13rest = rest[m[2] + 1..$]; 14endwhile 15return {0, result + rest};
_toscalar
Referenced by
- #20:prefix_to_value line 18:
this:_toscalar - #20:_tolist line 20:
this:_toscalar
Source
1":_toscalar(string) --- auxiliary for :tovalue"; 2" => value if string represents a number, object or error"; 3" => string error message otherwise"; 4thing = args[1]; 5if (!thing) 6return "missing value"; 7elseif (match(thing, "^#?[-+]?[0-9]+ *$")) 8return (thing[1] == "#") ? toobj(thing) | toint(thing); 9elseif (match(thing, "^[-+]?%([0-9]+%.[0-9]*%|[0-9]*%.[0-9]+%)%(e[-+]?[0-9]+%)? *$")) 10"matches 2. .2 3.2 3.2e3 .2e-3 3.e3"; 11return `tofloat(thing) ! E_INVARG => tostr("Bad floating point value: ", thing)'; 12elseif (match(thing, "^[-+]?[0-9]+e[-+]?[0-9]+ *$")) 13"matches 345e4. No decimal, but has an e so still a float"; 14return `tofloat(thing) ! E_INVARG => tostr("Bad floating point value: ", thing)'; 15elseif (thing[1] == "E") 16return (e = $code_utils:toerr(thing)) ? tostr("unknown error code `", thing, "'") | e; 17elseif (thing[1] == "#") 18return tostr("bogus objectid `", thing, "'"); 19else 20return tostr("`", thing[1], "' unexpected"); 21endif
parse_command
Referenced by
none
Source
1":parse_command(cmd_line[,player])"; 2" => {verb, {dobj, dobjstr}, {prep, prepstr}, {iobj, iobjstr}, {args, argstr},"; 3" dobjset, prepset, iobjset}"; 4"This mimics the action of the builtin parser, returning what the values of the builtin variables `verb', `dobj', `dobjstr', `prepstr', `iobj', `iobjstr', `args', and `argstr' would be if `player' had typed `cmd_line'. "; 5"`prep' is the shortened version of the preposition found."; 6""; 7"`dobjset' and `iobjset' are subsets of {\"any\",\"none\"} and are used to determine possible matching verbs, i.e., the matching verb must either be on `dobj' and have verb_args[1]==\"this\" or else it has verb_args[1] in `dobjset'; likewise for `iobjset' and verb_args[3]; similarly we must have verb_args[2] in `prepset'."; 8{c, ?who = player} = args; 9y = $string_utils:words(c); 10if (y == {}) 11return {}; 12endif 13vrb = y[1]; 14y = y[2..$]; 15as = (y == {}) ? "" | c[length(vrb) + 2..$]; 16n = 1; 17while ((!(gp = $code_utils:get_prep(@y[n..$]))[1]) && (n < length(y))) 18n = n + 1; 19endwhile 20"...."; 21really = player; 22player = who; 23loc = who.location; 24if (ps = gp[1]) 25ds = $string_utils:from_list(y[1..n - 1], " "); 26is = $string_utils:from_list(listdelete(gp, 1), " "); 27io = valid(loc) ? loc:match_object(is) | $string_utils:match_object(is, loc); 28else 29ds = $string_utils:from_list(y, " "); 30is = ""; 31io = $nothing; 32endif 33do = valid(loc) ? loc:match_object(ds) | $string_utils:match_object(ds, loc); 34player = really; 35"...."; 36dset = {"any", @(ds == "") ? {"none"} | {}}; 37"\"this\" must be handled manually."; 38pset = {"any", @ps ? {$code_utils:full_prep(ps)} | {"none"}}; 39iset = {"any", @(is == "") ? {"none"} | {}}; 40return {vrb, {do, ds}, {$code_utils:short_prep(ps), ps}, {io, is}, {y, as}, {dset, pset, iset}};
from_value
Referenced by
- #6:@rename*# line 70:
$string_utils:from_value - #6:@addalias*# line 94:
$string_utils:from_value - #6:@addalias*# line 110:
$string_utils:from_value - #6:@rmalias*# line 84:
$string_utils:from_value - #6:@rmalias*# line 91:
$string_utils:from_value - #20:from_value line 7:
this:from_value - #20:from_value line 9:
this:from_value - #20:from_value_suspended line 9:
this:from_value - #20:from_value_suspended line 12:
this:from_value - #21:make_exit line 23:
$string_utils:from_value
Source
1"$string_utils:from_value(value [, quote_strings = 0 [, list_depth = 1]])"; 2"Print the given value into a string."; 3{value, ?quote_strings = 0, ?list_depth = 1} = args; 4if (typeof(value) == LIST) 5if (value) 6if (list_depth) 7result = "{" + this:from_value(value[1], quote_strings, list_depth - 1); 8for v in (listdelete(value, 1)) 9result = tostr(result, ", ", this:from_value(v, quote_strings, list_depth - 1)); 10endfor 11return result + "}"; 12else 13return "{...}"; 14endif 15else 16return "{}"; 17endif 18elseif (quote_strings) 19if (typeof(value) == STR) 20result = "\""; 21while (q = index(value, "\"") || index(value, "\\")) 22if (value[q] == "\"") 23q = min(q, index(value + "\\", "\\")); 24endif 25result = ((result + value[1..q - 1]) + "\\") + value[q]; 26value = value[q + 1..$]; 27endwhile 28return (result + value) + "\""; 29elseif (typeof(value) == ERR) 30return $code_utils:error_name(value); 31else 32return tostr(value); 33endif 34else 35return tostr(value); 36endif
print print_suspended
Referenced by
- #4:@set*prop line 38:
$string_utils:print - #6:@mess*ages line 30:
$string_utils:print - #18:dump_topic line 11:
$string_utils:print - #20:print line 7:
this:print - #20:print line 9:
this:print - #32:@ansi-setup line 79:
$string_utils:print - #32:@ansi-setup line 94:
$string_utils:print - #58:@properties* line 11:
$string_utils:print - #59:show_property line 17:
$string_utils:print - #59:set_verb_documentation line 19:
$string_utils:print - #83:help_msg line 10:
$string_utils:print - #99:look_self line 18:
su:print - #99:get_task_display line 29:
su:print
Source
1"$string_utils:print(value)"; 2"Print the given value into a string. == from_value(value,1,-1)"; 3return toliteral(args[1]); 4value = args[1]; 5if (typeof(value) == LIST) 6if (value) 7result = "{" + this:print(value[1]); 8for val in (listdelete(value, 1)) 9result = tostr(result, ", ", this:print(val)); 10endfor 11return result + "}"; 12else 13return "{}"; 14endif 15elseif (typeof(value) == STR) 16return tostr("\"", strsub(strsub(value, "\\", "\\\\"), "\"", "\\\""), "\""); 17elseif (typeof(value) == ERR) 18return $code_utils:error_name(value); 19else 20return tostr(value); 21endif
reverse
Referenced by
- #20:reverse line 5:
this:reverse - #20:reverse line 5:
this:reverse - #88:check_name line 4:
$string_utils:reverse - #125:encrypt line 7:
$string_utils:reverse
Source
1":reverse(string) => \"gnirts\""; 2"An example: :reverse(\"This is a test.\") => \".tset a si sihT\""; 3string = args[1]; 4if ((len = length(string)) > 50) 5return this:reverse(string[($ / 2) + 1..$]) + this:reverse(string[1..$ / 2]); 6endif 7index = len; 8result = ""; 9while (index > 0) 10result = result + string[index]; 11index = index - 1; 12endwhile 13return result;
char_list
Referenced by
- #4:@create line 38:
$string_utils:char_list - #4:@recreate line 36:
$string_utils:char_list - #4:@dig line 27:
$string_utils:char_list - #20:char_list line 4:
this:char_list - #20:char_list line 4:
this:char_list - #21:make_exit line 14:
$string_utils:char_list - #24:set_property_flags line 7:
$string_utils:char_list - #57:@fullprops line 15:
$string_utils:char_list - #57:@fullprops line 35:
$string_utils:char_list - #134:list line 17:
$string_utils:char_list - #134:index_match line 6:
$string_utils:char_list
Source
1":char_list(string) => string as a list of characters."; 2" e.g., :char_list(\"abad\") => {\"a\",\"b\",\"a\",\"d\"}"; 3if (30 < (len = length(string = args[1]))) 4return {@this:char_list(string[1..$ / 2]), @this:char_list(string[($ / 2) + 1..$])}; 5else 6l = {}; 7for c in [1..len] 8l = {@l, string[c]}; 9endfor 10return l; 11endif
regexp_quote
Referenced by
- #20:index_d*elimited line 2:
$string_utils:regexp_quote
Source
1":regexp_quote(string)"; 2" => string with all of the regular expression special characters quoted with %"; 3string = args[1]; 4quoted = ""; 5while (m = rmatch(string, "[][$^.*+?%].*")) 6quoted = ("%" + string[m[1]..m[2]]) + quoted; 7string = string[1..m[1] - 1]; 8endwhile 9return string + quoted;
connection_hostname_bsd
Referenced by
- #20:connection_hostname line 2:
this:connection_hostname_bsd
Source
1"Takes the output from connection_name() and returns just the host string portion of it. Assumes you are using bsd_network style connection names."; 2s = args[1]; 3return (m = `match(args[1], "^.* %(from%|to%) %([^, ]+%)") ! ANY') ? substitute("%2", m) | "";
connection_hostname
Referenced by
- #0:do_login_command line 11:
$string_utils:connection_hostname - #6:@registerme line 11:
$string_utils:connection_hostname - #10:co*nnect line 24:
$string_utils:connection_hostname - #10:co*nnect line 35:
$string_utils:connection_hostname - #10:player_creation_enabled line 4:
$string_utils:connection_hostname - #10:record_connection line 8:
$string_utils:connection_hostname - #10:record_connection line 11:
$string_utils:connection_hostname - #10:request_character line 7:
$string_utils:connection_hostname - #12:find line 10:
$string_utils:connection_hostname - #24:show_netwho_listing line 35:
$string_utils:connection_hostname - #31:defer line 5:
$string_utils:connection_hostname - #31:confunc line 4:
$string_utils:connection_hostname - #31:log_disconnect line 5:
$string_utils:connection_hostname - #31:connection_name_hash line 3:
$string_utils:connection_hostname - #31:connection_name_hash line 5:
$string_utils:connection_hostname - #57:@toad line 43:
$string_utils:connection_hostname - #57:@guests line 30:
$string_utils:connection_hostname
Source
1"This is the function that should actually be called to get the host name from a connection name. The archwizard should change _bsd so as to be calling the verb appropriate for his/her network interface."; 2return this:connection_hostname_bsd(@args);
from_value_suspended
Referenced by
none
Source
1"$string_utils:from_value(value [, quote_strings = 0 [, list_depth = 1]])"; 2"Print the given value into a string."; 3"This verb suspends as necessary for large values."; 4set_task_perms(caller_perms()); 5{value, ?quote_strings = 0, ?list_depth = 1} = args; 6if (typeof(value) == LIST) 7if (value) 8if (list_depth) 9result = "{" + this:from_value(value[1], quote_strings, list_depth - 1); 10for v in (listdelete(value, 1)) 11(ticks_left() < 4000) && suspend(0); 12result = tostr(result, ", ", this:from_value(v, quote_strings, list_depth - 1)); 13endfor 14return result + "}"; 15else 16return "{...}"; 17endif 18else 19return "{}"; 20endif 21elseif (quote_strings) 22if (typeof(value) == STR) 23result = "\""; 24while (q = index(value, "\"") || index(value, "\\")) 25(ticks_left() < 4000) && suspend(0); 26if (value[q] == "\"") 27q = min(q, index(value + "\\", "\\")); 28endif 29result = ((result + value[1..q - 1]) + "\\") + value[q]; 30value = value[q + 1..$]; 31endwhile 32return (result + value) + "\""; 33elseif (typeof(value) == ERR) 34return $code_utils:error_name(value); 35else 36return tostr(value); 37endif 38else 39return tostr(value); 40endif
end_expression
Referenced by
none
Source
1":end_expression(string[,stop_at])"; 2" assumes string starts with an expression; returns the index of the last char in expression or 0 if string appears not to be an expression. Expression ends at any character from stop_at which occurs at top level."; 3{string, ?stop_at = " "} = args; 4gone = 0; 5paren_stack = ""; 6inquote = 0; 7search = top_level_search = ("[][{}()\"" + strsub(stop_at, "]", "")) + "]"; 8paren_search = "[][{}()\"]"; 9while (m = match(string, search)) 10char = string[m[1]]; 11string[1..m[2]] = ""; 12gone = gone + m[2]; 13if (char == "\"") 14"...skip over quoted string..."; 15char = "\\"; 16while (char == "\\") 17if (!(m = match(string, "%(\\.?%|\"%)"))) 18return 0; 19endif 20char = string[m[1]]; 21string[1..m[2]] = ""; 22gone = gone + m[2]; 23endwhile 24elseif (index("([{", char)) 25"... push parenthesis..."; 26paren_stack[1..0] = char; 27search = paren_search; 28elseif (i = index(")]}", char)) 29if (paren_stack && ("([{"[i] == paren_stack[1])) 30"... pop parenthesis..."; 31paren_stack[1..1] = ""; 32search = paren_stack ? paren_search | top_level_search; 33else 34"...parenthesis mismatch..."; 35return 0; 36endif 37else 38"... stop character ..."; 39return gone - 1; 40endif 41endwhile 42return (!paren_stack) && (gone + length(string));
first_word
Referenced by
- #57:@toad line 3:
$string_utils:first_word - #57:@toad line 10:
$string_utils:first_word - #57:@newt line 6:
$string_utils:first_word - #57:@unnewt line 5:
$string_utils:first_word - #57:@blacklist line 14:
$string_utils:first_word - #57:@deprog*rammer line 12:
$string_utils:first_word - #57:parse_templist_duration line 2:
$string_utils:first_word - #90:whois line 8:
$string_utils:first_word - #91:g*et line 14:
$string_utils:first_word - #91:dr*op line 20:
$string_utils:first_word - #116:_force line 2:
$string_utils:first_word - #116:say line 8:
$string_utils:first_word - #116:ask line 23:
$string_utils:first_word - #124:parse line 12:
$string_utils:first_word - #124:parse line 41:
$string_utils:first_word - #134:sell line 6:
$string_utils:first_word - #134:sell_product line 5:
$string_utils:first_word - #143:get_parsed line 22:
su:first_word
Source
1":first_word(string) => {first word, rest of string} or {}"; 2rest = args[1]; 3"...trim leading blanks..."; 4rest[1..match(rest, "^ *")[2]] = ""; 5if (!rest) 6return {}; 7endif 8quote = 0; 9token = ""; 10pattern = " +%|\\.?%|\""; 11while (m = match(rest, pattern)) 12"... find the next occurence of a special character, either"; 13"... a block of spaces, a quote or a backslash escape sequence..."; 14char = rest[m[1]]; 15token = token + rest[1..m[1] - 1]; 16if (char == " ") 17rest[1..m[2]] = ""; 18return {token, rest}; 19elseif (char == "\"") 20"... beginning or end of quoted string..."; 21"... within a quoted string spaces aren't special..."; 22pattern = (quote = !quote) ? "\\.?%|\"" | " +%|\\.?%|\""; 23elseif (m[1] < m[2]) 24"... char has to be a backslash..."; 25"... include next char literally if there is one"; 26token = token + rest[m[2]]; 27endif 28rest[1..m[2]] = ""; 29endwhile 30return {token + rest, ""};
common
Referenced by
- #37:insert line 33:
$string_utils:common - #37:insert line 58:
$string_utils:common
Source
1":common(first,second) => length of longest common prefix"; 2{first, second} = args; 3r = min(length(first), length(second)); 4l = 1; 5while (r >= l) 6h = (r + l) / 2; 7if (first[l..h] == second[l..h]) 8l = h + 1; 9else 10r = h - 1; 11endif 12endwhile 13return r;
title_list*c list_title*c
Referenced by
none
Source
1"wr_utils:title_list/title_listc(<obj-list>[, @<args>)"; 2"Creates an english list out of the titles of the objects in <obj-list>. Optional <args> are passed on to $string_utils:english_list."; 3"title_listc uses :titlec() for the first item."; 4titles = $list_utils:map_verb(args[1], "title"); 5if (verb[length(verb)] == "c") 6if (titles) 7titles[1] = args[1][1]:titlec(); 8elseif (length(args) > 1) 9args[2] = $string_utils:capitalize(args[2]); 10else 11args = listappend(args, "Nothing"); 12endif 13endif 14return $string_utils:english_list(titles, @args[2..$]);
name_and_number nn name_and_number_list nn_list
Referenced by
- #0:handle_uncaught_error line 5:
$string_utils:nn - #3:@exits line 11:
$string_utils:nn - #3:@entrances line 11:
$string_utils:nn - #3:-* line 12:
$string_utils:nn - #4:@dig line 24:
$string_utils:nn - #4:_recycle line 5:
$string_utils:nn - #4:@measure line 17:
$string_utils:nn - #4:@measure line 52:
$string_utils:nn - #4:@measure line 82:
$string_utils:nn - #6:@gag*! line 18:
$string_utils:nn - #6:where*is line 17:
$string_utils:nn - #6:where*is line 17:
$string_utils:nn - #6:@addalias*# line 94:
$string_utils:nn - #6:@addalias*# line 110:
$string_utils:nn - #6:@rmalias*# line 91:
$string_utils:nn - #6:@registerme line 45:
$string_utils:nn - #6:@registerme line 51:
$string_utils:nn - #6:@registerme line 63:
$string_utils:nn - #6:_ping line 9:
$string_utils:nn - #21:make_exit line 11:
$string_utils:nn - #24:verify_owned_objects line 9:
$string_utils:nn - #24:verify_owned_objects line 9:
$string_utils:nn - #24:do_new_password line 9:
$string_utils:nn - #32:@ansi-setup line 22:
$string_utils:nn - #32:@ansi-setup line 34:
$string_utils:nn - #32:@ansi-setup line 37:
$string_utils:nn_list - #40:@add-notify line 15:
$string_utils:nn - #40:@add-notify line 16:
$string_utils:nn - #50:y*ank line 30:
$string_utils:nn - #50:y*ank line 65:
$string_utils:nn - #50:y*ank line 76:
$string_utils:nn - #50:do_flush line 9:
$string_utils:nn - #57:@grant line 39:
$string_utils:nn - #57:@grant line 67:
$string_utils:nn - #57:@corify line 31:
$string_utils:nn - #58:@core line 8:
$string_utils:nn - #58:@core line 17:
$string_utils:nn - #58:@core line 30:
$string_utils:nn - #58:@core line 33:
$string_utils:nn - #58:@core line 39:
$string_utils:nn - #62:keep_clean line 20:
$string_utils:nn - #71:replace line 47:
$string_utils:nn - #71:replace line 47:
$string_utils:nn - #71:replace line 47:
$string_utils:nn - #71:replace line 56:
$string_utils:nn - #71:replace line 56:
$string_utils:nn - #71:fix_object_aliases line 9:
$string_utils:nn - #71:fix_object_aliases line 9:
$string_utils:nn - #71:find_duplicate_verbs line 12:
$string_utils:nn - #71:find_duplicate_verbs line 12:
$string_utils:nn - #90:refusal_origin_to_name line 10:
$string_utils:name_and_number - #90:@sanctuaries line 8:
$string_utils:nn - #90:@sanctuaries line 8:
$string_utils:nn - #90:whois line 33:
$string_utils:nn - #90:whois line 42:
$string_utils:nn - #90:whois line 67:
$string_utils:nn - #90:whois line 67:
$string_utils:nn - #90:whois line 74:
$string_utils:nn - #90:whois line 74:
$string_utils:nn - #91:@send line 41:
$string_utils:nn - #98:@awards line 12:
$string_utils:nn - #98:@awards line 12:
$string_utils:nn - #98:@deadstuff line 8:
$string_utils:nn - #98:@deadstuff line 9:
$string_utils:nn - #98:@deadstuff line 13:
$string_utils:nn - #98:@deadstuff line 14:
$string_utils:nn - #98:@set-sales line 10:
$string_utils:nn - #98:@set-sales line 12:
$string_utils:nn - #98:@set-sales line 13:
$string_utils:nn - #98:@set-sales line 13:
$string_utils:nn - #98:@set-sales line 19:
$string_utils:nn - #99:get_task_display line 34:
su:nn - #99:get_task_display line 38:
su:nn - #100:@save line 8:
$string_utils:nn - #100:@doomed line 4:
$string_utils:nn - #100:@doomed line 6:
$string_utils:nn - #100:@protected line 4:
$string_utils:nn - #100:do_reap line 7:
$string_utils:nn - #100:do_reap line 33:
$string_utils:nn - #100:do_reap line 33:
$string_utils:nn - #100:@harvest line 18:
$string_utils:nn - #100:@update-reg*istration line 39:
$string_utils:nn - #106:list_fertiles line 7:
$string_utils:nn - #116:watch line 2:
$string_utils:nn - #116:watch line 6:
$string_utils:nn - #116:watch line 9:
$string_utils:nn - #116:watch line 14:
$string_utils:nn - #116:watch line 16:
$string_utils:nn - #116:ask line 78:
$string_utils:nn - #118:add_virtual_exit line 9:
$string_utils:nn - #118:add_virtual_exit line 9:
$string_utils:nn - #118:@vways line 7:
$string_utils:nn - #118:@vways line 9:
$string_utils:nn - #118:@vlock line 14:
$string_utils:nn - #118:con*vert-exit line 21:
$string_utils:nn - #118:@add-ventrance line 7:
$string_utils:nn - #118:@remove-ventrance line 7:
$string_utils:nn - #118:@vdig line 24:
$string_utils:nn - #118:@vdig line 60:
$string_utils:nn - #126:@setup line 24:
$string_utils:nn - #134:_clean_inv line 6:
$string_utils:nn - #134:_clean_inv line 6:
$string_utils:nn - #135:reg*ister line 32:
$string_utils:nn - #135:reg*ister line 32:
$string_utils:nn - #135:unregister line 19:
$string_utils:nn - #135:unregister line 19:
$string_utils:nn - #144:link line 10:
$string_utils:nn - #144:bot* line 11:
$string_utils:nn - #144:bot* line 11:
$string_utils:nn - #164:pr*ess line 28:
$string_utils:nn - #165:dr*op line 17:
$string_utils:nn
Source
1"name_and_number(object [,sepr]) => \"ObjectName (#object)\""; 2"Return name and number for OBJECT. Second argument is optional separator (for those who want no space, use \"\"). If OBJECT is a list of objects, this maps the above function over the list and then passes it to $string_utils:english_list."; 3{objs, ?sepr = " "} = args; 4if (typeof(objs) != LIST) 5objs = {objs}; 6endif 7name_list = {}; 8for what in (objs) 9name = valid(what) ? what.name | {"<invalid>", "$nothing", "$ambiguous_match", "$failed_match"}[1 + (what in {#-1, #-2, #-3})]; 10name = tostr(name, sepr, "(", what, ")"); 11name_list = {@name_list, name}; 12endfor 13return $string_utils:english_list(name_list);
columnize_suspended columnise_suspended
Referenced by
- #30:columnize line 5:
$string_utils:columnize_suspended - #63:look_self line 9:
$string_utils:columnize_suspended
Source
1"columnize_suspended (interval, items, n [, width]) - Turn a one-column list of items into an n-column list, suspending for `interval' seconds as necessary. 'width' is the last character position that may be occupied; it defaults to a standard screen width. Example: To tell the player a list of numbers in three columns, do 'player:tell_lines ($string_utils:columnize_suspended(0, {1, 2, 3, 4, 5, 6, 7}, 3));'."; 2{interval, items, n, ?width = 79} = args; 3height = ((length(items) + n) - 1) / n; 4items = {@items, @$list_utils:make((height * n) - length(items), "")}; 5colwidths = {}; 6for col in [1..n - 1] 7colwidths = listappend(colwidths, 1 - (((width + 1) * col) / n)); 8endfor 9result = {}; 10for row in [1..height] 11line = tostr(items[row]); 12for col in [1..n - 1] 13(ticks_left() < 4000) && suspend(interval); 14line = tostr(this:left(line, colwidths[col]), " ", items[row + (col * height)]); 15endfor 16result = listappend(result, line[1..min($, width)]); 17endfor 18return result;
a_or_an
Referenced by
- #141:facts line 8:
$string_utils:a_or_an
Source
1":a_or_an(<noun>) => \"a\" or \"an\""; 2"To accomodate personal variation (e.g., \"an historical book\"), a player can override this by having a personal a_or_an verb. If that verb returns 0 instead of a string, the standard algorithm is used."; 3noun = args[1]; 4if ($object_utils:has_verb(player, "a_or_an") && ((custom_result = player:a_or_an(noun)) != 0)) 5return custom_result; 6endif 7if (noun in this.use_article_a) 8return "a"; 9endif 10if (noun in this.use_article_an) 11return "an"; 12endif 13a_or_an = "a"; 14if (noun != "") 15if (index("aeiou", noun[1])) 16a_or_an = "an"; 17"unicycle, unimplemented, union, united, unimpressed, unique"; 18if ((((noun[1] == "u") && (length(noun) > 2)) && (noun[2] == "n")) && ((index("aeiou", noun[3]) == 0) || (((noun[3] == "i") && (length(noun) > 3)) && (index("aeioubcghqwyz", noun[4]) || ((length(noun) > 4) && index("eiy", noun[5])))))) 19a_or_an = "a"; 20endif 21endif 22endif 23return a_or_an; 24"Ported by Mickey with minor tweaks from a Moo far far away."; 25"Last modified Sun Aug 1 22:53:07 1993 EDT by BabyBriar (#2).";
index_all
Referenced by
none
Source
1"index_all(string,target) -- returns list of positions of target in string."; 2"Usage: $string_utils:index_all(<string,pattern>)"; 3" $string_utils:index_all(\"aaabacadae\",\"a\")"; 4{line, pattern} = args; 5if ((typeof(line) != STR) || (typeof(pattern) != STR)) 6return E_TYPE; 7else 8where = {}; 9place = -1; 10next = 0; 11while ((place = index(line[next + 1..$], pattern)) != 0) 12where = {@where, place + next}; 13next = ((place + next) + length(pattern)) - 1; 14endwhile 15return where; 16endif
match_stringlist match_string_list
Referenced by
- #90:whois line 20:
$string_utils:match_stringlist - #91:@roll line 9:
$string_utils:match_stringlist - #104:find_detail line 2:
$string_utils:match_stringlist - #104:match_fake line 10:
$string_utils:match_stringlist - #104:match_fake line 12:
$string_utils:match_stringlist - #104:match_fake line 14:
$string_utils:match_stringlist - #135:view line 2:
$string_utils:match_stringlist - #135:l*ook line 13:
$string_utils:match_stringlist
Source
1"Copied from Puff (#1449):match_stringlist Tue Oct 19 08:18:13 1993 PDT"; 2"$string_utils:match_stringlist(string, {list of strings})"; 3"The list of strings should be just that, a list of strings. The first string is matched against the list of strings."; 4"If it exactly matches exactly one of them, the index of the match is returned. If it exactly matches more than one of them, $ambiguous_match is returned."; 5"If there are no exact matches, then partial matches are considered, ones in which the given string is a prefix of one of the strings."; 6"Again, if exactly one match is found, the index of that string is returned, and if more than one match is found, $ambiguous match is returned."; 7"Finally, if there are no exact or partial matches, then $failed_match is returned."; 8{subject, stringlist} = args; 9if ((subject == "") || (length(stringlist) < 1)) 10return $nothing; 11endif 12matches = {}; 13"First check for exact matches."; 14for i in [1..length(stringlist)] 15if (subject == stringlist[i]) 16matches = {@matches, i}; 17endif 18endfor 19"Now return a match, or $ambiguous, or check for partial matches."; 20if (length(matches) == 1) 21return matches[1]; 22elseif (length(matches) > 1) 23return $ambiguous_match; 24elseif (length(matches) == 0) 25"Checking for partial matches is almost identical to checking for exact matches, but we use index(list[i], target) instead of list[i] == target to see if they match."; 26for i in [1..length(stringlist)] 27if (index(stringlist[i], subject) == 1) 28matches = {@matches, i}; 29endif 30endfor 31if (length(matches) == 1) 32return matches[1]; 33elseif (length(matches) > 1) 34return $ambiguous_match; 35elseif (length(matches) == 0) 36return $failed_match; 37endif 38endif
from_ASCII
Referenced by
none
Source
1"This converts a ASCII character code in the range [32..126] into the ASCII character with that code, represented as a one-character string."; 2""; 3"Example: $string_utils:from_ASCII(65) => \"A\""; 4code = args[1]; 5return this.ascii[code - 31];
to_ASCII
Referenced by
none
Source
1"Convert a one-character string into the ASCII character code for that character."; 2""; 3"Example: $string_utils:to_ASCII(\"A\") => 65"; 4return (index(this.ascii, args[1], 1) || raise(E_INVARG)) + 31;
abbreviated_value
Referenced by
- #58:@d*isplay line 174:
$string_utils:abbreviated_value - #58:@d*isplay line 187:
$string_utils:abbreviated_value
Source
1"Copied from Mickey (#52413):abbreviated_value Fri Sep 9 08:52:41 1994 PDT"; 2":abbreviated_value(value,max_reslen,max_lstlev,max_lstlen,max_strlen,max_toklen)"; 3""; 4"Gets the printed representation of value, subject to these parameters:"; 5" max_reslen = Maximum desired result string length."; 6" max_lstlev = Maximum list level to show."; 7" max_lstlen = Maximum list length to show."; 8" max_lstlen = Maximum string length to show."; 9" max_lstlen = Maximum token length (e.g., numbers and errors) to show."; 10""; 11"A best attempt is made to get the exact target size, but in some cases the result is not exact."; 12{value, ?max_reslen = $maxint, ?max_lstlev = $maxint, ?max_lstlen = $maxint, ?max_strlen = $maxint, ?max_toklen = $maxint} = args; 13return this:_abbreviated_value(value, max_reslen, max_lstlev, max_lstlen, max_strlen, max_toklen); 14"Originally written by Mickey.";
_abbreviated_value
Referenced by
- #20:abbreviated_value line 13:
this:_abbreviated_value
Source
1"Copied from Mickey (#52413):_abbreviated_value Fri Sep 9 08:52:44 1994 PDT"; 2"Internal to :abbreviated_value. Do not call this directly."; 3{value, max_reslen, max_lstlev, max_lstlen, max_strlen, max_toklen} = args; 4if ((type = typeof(value)) == LIST) 5if (!value) 6return "{}"; 7elseif (max_lstlev == 0) 8return "{...}"; 9else 10n = length(value); 11result = "{"; 12r = max_reslen - 2; 13i = 1; 14eltstr = ""; 15while (((i <= n) && (i <= max_lstlen)) && (r > (x = (i == 1) ? 0 | 2))) 16eltlen = length(eltstr = this:(verb)(value[i], r, max_lstlev - 1, max_lstlen, max_strlen, max_toklen)); 17lastpos = 1; 18if (r >= (eltlen + x)) 19comma = (i == 1) ? "" | ", "; 20result = tostr(result, comma); 21if (r > 4) 22lastpos = length(result); 23endif 24result = tostr(result, eltstr); 25r = (r - eltlen) - x; 26elseif (i == 1) 27return "{...}"; 28elseif (r > 4) 29return tostr(result, ", ...}"); 30else 31return tostr(result[1..lastpos], "...}"); 32endif 33i = i + 1; 34endwhile 35if (i <= n) 36if (i == 1) 37return "{...}"; 38elseif (r > 4) 39return tostr(result, ", ...}"); 40else 41return tostr(result[1..lastpos], "...}"); 42endif 43else 44return tostr(result, "}"); 45endif 46endif 47elseif (type == STR) 48result = "\""; 49while ((q = index(value, "\"")) ? q = min(q, index(value, "\\")) | (q = index(value, "\\"))) 50result = ((result + value[1..q - 1]) + "\\") + value[q]; 51value = value[q + 1..$]; 52endwhile 53result = result + value; 54if ((length(result) + 1) > (z = max(min(max_reslen, max(max_strlen, max_strlen + 2)), 6))) 55z = z - 5; 56k = 0; 57while ((k < z) && (result[z - k] == "\\")) 58k = k + 1; 59endwhile 60return tostr(result[1..z - (k % 2)], "\"+..."); 61else 62return tostr(result, "\""); 63endif 64else 65v = (type == ERR) ? $code_utils:error_name(value) | tostr(value); 66len = max(4, min(max_reslen, max_toklen)); 67return (length(v) > len) ? v[1..len - 3] + "..." | v; 68endif 69"Originally written by Mickey.";
match_suspended
Referenced by
- #134:find_product line 11:
$string_utils:match_suspended
Source
1"$string_utils:match_suspended(string [, obj-list, prop-name]*)"; 2"Each obj-list should be a list of objects or a single object, which is treated as if it were a list of that object. Each prop-name should be string naming a property on every object in the corresponding obj-list. The value of that property in each case should be either a string or a list of strings."; 3"The argument string is matched against all of the strings in the property values."; 4"If it exactly matches exactly one of them, the object containing that property is returned. If it exactly matches more than one of them, $ambiguous_match is returned."; 5"If there are no exact matches, then partial matches are considered, ones in which the given string is a prefix of some property string. Again, if exactly one match is found, the object with that property is returned, and if there is more than one match, $ambiguous_match is returned."; 6"Finally, if there are no exact or partial matches, then $failed_match is returned."; 7"This verb will suspend as needed, and should be used if obj-list is very large."; 8subject = args[1]; 9if (subject == "") 10return $nothing; 11endif 12no_exact_match = no_partial_match = 1; 13for i in [1..length(args) / 2] 14prop_name = args[(2 * i) + 1]; 15for object in ((typeof(olist = args[2 * i]) == LIST) ? olist | {olist}) 16if (valid(object)) 17if (typeof(str_list = `object.(prop_name) ! E_PERM, E_PROPNF => {}') != LIST) 18str_list = {str_list}; 19endif 20if (subject in str_list) 21if (no_exact_match) 22no_exact_match = object; 23elseif (no_exact_match != object) 24return $ambiguous_match; 25endif 26else 27for string in (str_list) 28if (index(string, subject) != 1) 29elseif (no_partial_match) 30no_partial_match = object; 31elseif (no_partial_match != object) 32no_partial_match = $ambiguous_match; 33endif 34endfor 35endif 36endif 37$command_utils:suspend_if_needed(5); 38endfor 39endfor 40return no_exact_match && (no_partial_match && $failed_match);
incr_alpha
Referenced by
- #16:prune line 36:
$string_utils:incr_alpha - #20:incr_alpha line 7:
this:incr_alpha
Source
1"args[1] is a string. 'increments' the string by one. E.g., aaa => aab, aaz => aba. empty string => a, zzz => aaaa."; 2s = args[1]; 3index = length(s); 4if (!s) 5return "a"; 6elseif (s[$] == "z") 7return this:incr_alpha(s[1..index - 1]) + "a"; 8else 9t = index(this.alphabet, s[index]); 10return s[1..index - 1] + this.alphabet[t + 1]; 11endif
is_float
Referenced by
none
Source
1"Usage: is_float(string)"; 2"Is string composed of one or more digits possibly preceded by a minus sign either followed by a decimal or by an exponent?"; 3"Return true or false"; 4return match(args[1], "^ *[-+]?%(%([0-9]+%.[0-9]*%|[0-9]*%.[0-9]+%)%(e[-+]?[0-9]+%)?%)%|%([0-9]+e[-+]?[0-9]+%) *$");
redirect_ansi left right center centre columnize columnise space
Referenced by
- #4:@check-chp*arent line 18:
su:left - #4:@check-chp*arent line 19:
su:left - #4:@check-chp*arent line 21:
su:left - #6:@ch*eck-full line 25:
$string_utils:left - #6:@ch*eck-full line 25:
$string_utils:left - #6:@ch*eck-full line 25:
$string_utils:left - #6:where*is line 17:
$string_utils:left - #6:@features line 19:
$string_utils:left - #6:@features line 20:
$string_utils:left - #6:@features line 22:
$string_utils:left - #6:@features line 24:
$string_utils:left - #6:@memory line 22:
su:left - #6:@memory line 22:
su:right - #6:@memory line 22:
su:right - #6:@memory line 22:
su:right - #6:@memory line 22:
su:right - #6:@memory line 30:
su:left - #6:@memory line 30:
su:right - #6:@memory line 30:
su:right - #6:@memory line 30:
su:right - #6:@memory line 30:
su:right - #12:last line 38:
su:left - #12:last line 38:
su:left - #12:last line 38:
su:left - #12:last line 39:
su:left - #12:last line 39:
su:left - #12:last line 39:
su:left - #12:last line 43:
su:left - #12:last line 43:
su:left - #12:last line 43:
su:right - #14:display_seq_headers line 22:
$string_utils:right - #14:list_rmm line 26:
$string_utils:right - #17:msg_summary_line line 3:
$string_utils:left - #17:msg_summary_line line 9:
$string_utils:left - #20:left(noansi) line 10:
this:space - #20:right(noansi) line 10:
this:space - #20:centre line 10:
this:space - #20:centre line 10:
this:space - #20:columnize line 13:
this:left - #20:to_value line 4:
$string_utils:space - #20:columnize_suspended line 14:
this:left - #21:object_audit_string line 5:
$string_utils:right - #21:object_audit_string line 22:
$string_utils:right - #21:object_audit_string line 87:
$string_utils:right - #21:object_audit_string line 87:
$string_utils:left - #21:do_audit line 42:
$string_utils:left - #21:size_string line 7:
$string_utils:right - #21:size_string line 9:
$string_utils:right - #22:errors line 3:
$string_utils:left - #22:prepositions line 3:
$string_utils:space - #24:show_missing_help line 9:
$string_utils:right - #24:show_missing_help line 9:
$string_utils:right - #24:show_netwho_listing line 50:
su:space - #24:show_netwho_listing line 52:
su:left - #24:show_netwho_listing line 53:
su:left - #24:show_netwho_listing line 53:
su:space - #24:show_netwho_listing line 61:
su:left - #24:show_netwho_from_listing line 30:
su:left - #24:show_netwho_from_listing line 31:
su:left - #24:show_netwho_from_listing line 33:
su:left - #24:show_netwho_from_listing line 39:
su:space - #29:display_seq_headers line 8:
$string_utils:left - #29:display_seq_headers line 10:
$string_utils:right - #29:display_seq_headers line 21:
$string_utils:left - #32:show_who_listing line 54:
su:space - #32:show_who_listing line 56:
su:left - #32:show_who_listing line 57:
su:left - #32:show_who_listing line 57:
su:space - #32:show_who_listing line 78:
su:space - #32:show_who_listing line 83:
su:left - #40:@rn line 24:
$string_utils:left - #40:@mail-all-new*-mail line 16:
$string_utils:left - #40:@mail-all-new*-mail line 25:
$string_utils:left - #40:@read-all-new*-mail line 21:
$string_utils:left - #40:@read-all-new*-mail line 38:
$string_utils:left - #43:time_sub line 79:
$string_utils:right - #46:make_message line 34:
$string_utils:left - #46:display_seq_headers line 15:
$string_utils:right - #46:expunge_rmm line 35:
$string_utils:right - #46:msg_summary_line line 16:
$string_utils:left - #50:list_line line 4:
$string_utils:right - #50:description line 14:
$string_utils:left - #50:description line 22:
$string_utils:left - #50:description line 27:
$string_utils:right - #50:description line 27:
$string_utils:space - #56:read_lines line 13:
$string_utils:space - #56:read_lines line 18:
$string_utils:space - #57:@players line 106:
su:left - #57:@players line 106:
su:right - #57:@players line 106:
su:right - #57:@players line 106:
su:right - #57:@players line 106:
su:right - #57:@players line 106:
su:right - #57:@players line 106:
su:right - #57:@players line 110:
su:left - #57:@players line 110:
su:right - #57:@players line 110:
su:right - #57:@players line 110:
su:right - #57:@players line 110:
su:right - #57:@players line 110:
su:right - #57:@players line 110:
su:right - #57:@players line 111:
su:left - #57:@players line 111:
su:right - #57:@players line 111:
su:right - #57:@players line 111:
su:right - #57:@players line 111:
su:right - #57:@players line 111:
su:right - #57:@players line 111:
su:right - #57:@players line 112:
su:left - #57:@players line 112:
su:right - #57:@players line 112:
su:right - #57:@players line 112:
su:right - #57:@players line 113:
su:left - #57:@players line 113:
su:right - #57:@players line 113:
su:right - #57:@players line 113:
su:right - #57:@guests line 48:
su:space - #57:@guests line 50:
su:left - #57:@guests line 51:
su:left - #57:@guests line 51:
su:space - #57:@guests line 60:
su:left - #58:@forked line 31:
su:left - #58:@forked line 33:
su:left - #58:@forked line 33:
su:left - #58:@forked line 37:
su:left - #58:_kill_task_message line 3:
$string_utils:right - #58:@d*isplay line 144:
$string_utils:left - #58:@d*isplay line 144:
$string_utils:right - #58:@d*isplay line 148:
$string_utils:left - #58:@d*isplay line 154:
$string_utils:left - #58:@d*isplay line 174:
$string_utils:left - #58:@d*isplay line 179:
$string_utils:left - #58:@d*isplay line 187:
$string_utils:left - #58:@d*isplay line 187:
$string_utils:left - #58:@forked-v*erbose line 31:
su:left - #58:@forked-v*erbose line 33:
su:left - #58:@forked-v*erbose line 33:
su:left - #58:@forked-v*erbose line 37:
su:left - #59:show_who_listing line 70:
su:space - #59:show_who_listing line 72:
su:left - #59:show_who_listing line 73:
su:left - #59:show_who_listing line 73:
su:space - #59:show_who_listing line 94:
su:space - #59:show_who_listing line 99:
su:left - #59:verb_usage line 20:
$string_utils:space - #59:callers_text line 16:
su:left - #59:callers_text line 17:
su:space - #59:callers_text line 27:
su:left - #60:index_list line 2:
$string_utils:space - #60:index_list line 6:
$string_utils:left - #60:index_list line 14:
$string_utils:left - #60:wizard_list line 14:
su:left - #60:wizard_list line 14:
su:left - #68:show line 47:
$string_utils:left - #68:show line 49:
$string_utils:space - #71:cleanup_list line 22:
$string_utils:left - #71:cleanup_list line 22:
$string_utils:left - #71:cleanup_list line 24:
$string_utils:left - #71:cleanup_list line 24:
$string_utils:left - #71:cleanup_list line 24:
$string_utils:left - #75:display_cache line 9:
$string_utils:left - #75:display_cache line 10:
$string_utils:right - #75:display_cache line 23:
$string_utils:right - #90:at_item line 5:
su:right - #90:at_item line 9:
su:left - #90:at_item line 15:
su:space - #91:@stats line 2:
$string_utils:space - #91:@stats line 4:
$string_utils:space - #91:@stats line 7:
$string_utils:space - #91:@stats line 10:
$string_utils:space - #91:@stats line 13:
$string_utils:space - #91:@stats line 15:
$string_utils:space - #91:@stats line 23:
$string_utils:space - #91:@stats line 27:
$string_utils:space - #91:@stats line 28:
$string_utils:space - #91:@features line 13:
$string_utils:left - #91:@features line 14:
$string_utils:left - #91:@features line 16:
$string_utils:left - #91:@features line 18:
$string_utils:left - #95:@ansi-t*est line 5:
$string_utils:space - #95:at_item line 5:
su:right - #95:at_item line 6:
su:left - #95:at_item line 10:
su:space - #95:confunc line 10:
$string_utils:space - #95:@ansi-title line 30:
$string_utils:left - #96:ansi_log line 6:
$string_utils:left - #96:ansi_log line 6:
$string_utils:left - #96:ansi_log line 9:
$string_utils:space - #99:look_self line 8:
su:space - #99:look_self line 11:
su:left - #99:look_self line 13:
su:left - #99:look_self line 22:
su:space - #99:get_task_display line 6:
su:space - #99:get_task_display line 11:
su:space - #99:get_task_display line 33:
su:space - #99:get_task_display line 37:
su:space - #99:get_task_display line 40:
su:space - #99:@list-ch*eckpoints line 7:
$string_utils:right - #104:tell_exits line 22:
$string_utils:space - #104:tell_exits line 27:
$string_utils:space - #104:look_self line 5:
$string_utils:space - #104:look_self line 6:
$string_utils:space - #118:@vways line 9:
$string_utils:left - #134:check_stocks line 11:
$string_utils:left - #134:check_stocks line 11:
$string_utils:left - #134:check_stocks line 11:
$string_utils:left - #134:check_stocks line 12:
$string_utils:space - #134:check_stocks line 14:
$string_utils:left - #134:check_stocks line 14:
$string_utils:right - #134:check_stocks line 14:
$string_utils:right - #141:description line 3:
$string_utils:space - #141:description line 13:
$string_utils:space - #141:description line 15:
$string_utils:space - #141:description line 18:
$string_utils:space - #141:description line 21:
$string_utils:space - #141:description line 24:
$string_utils:space - #141:description line 26:
$string_utils:space - #141:description line 30:
$string_utils:space
Source
1"...redirects verbs to $ansi_utils..."; 2if (verb == "redirect_ansi") 3elseif (valid(au = $ansi_utils)) 4return au:(verb)(@args); 5else 6return this:(verb + "(noansi)")(@args); 7endif
get_say_verb_prep
Referenced by
- #3:-* line 5:
$string_utils:get_say_verb_prep - #104:com*mand line 8:
$string_utils:get_say_verb_prep - #116:direct_say line 7:
$string_utils:get_say_verb_prep - #143:get_parsed line 28:
su:get_say_verb_prep
Source
1"USAGE: get_say_verb_prep(STRING) => preposition plus"; 2" leading and trailing spaces for 'say' substitutes."; 3" ie. get_say_verb_prep('complains')"; 4" returns ' to '"; 5sayverb = args[1]; 6if (sayverb == "asks") 7return " "; 8elseif (sayverb in {"exclaims", "adds", "ponders", "complains", "yawns", "yells", "says"}) 9return " to "; 10endif 11return " at ";
get_say_verb
Referenced by
- #3:say line 2:
$string_utils:get_say_verb - #3:-* line 4:
$string_utils:get_say_verb - #91:say line 6:
$string_utils:get_say_verb - #95:say line 5:
$string_utils:get_say_verb - #104:com*mand line 7:
$string_utils:get_say_verb - #116:say line 13:
$string_utils:get_say_verb - #116:direct_say line 6:
$string_utils:get_say_verb - #143:get_parsed line 18:
su:get_say_verb
Source
1"USAGE: get_say_verb(STRING) => 3rd person verb for 'say'"; 2" (ie. return 'asks')"; 3" Parses for ! and ? and ... first, then emoticons."; 4"...<words> adds <words>... ponders"; 5" ! exclaims ? asks :) smiles :} chuckles"; 6":D laughs :> grins :( frowns :[ complains"; 7":P plbbbbbts :/ shrugs :o yawns :0 yells"; 8":| sighs"; 9";) winks ;> smirks ;/ winces ;( grimaces"; 10"OTHERWISE, 'says' is returned."; 11words = args[1]; 12if ((!words) || (!$string_utils:words(words))) 13return "pauses"; 14endif 15if (length(words) > 2) 16if (tostr(words[1..3]) == "...") 17return "adds"; 18elseif (tostr(words[$ - 2..$]) == "...") 19return "ponders"; 20endif 21endif 22cutstring = this:trim(this:strip_chars(words, "^-.")); 23cutstring = this:subst(cutstring, {{"=", ":"}, {"B", ":"}, {"8", ":"}, {"]", ")"}, {"b", "P"}, {"O", "0"}, {"@", "0"}}, 1); 24smiley = this:explode(cutstring)[$]; 25if (smiley[$] == "!") 26return "exclaims"; 27elseif (smiley[$] == "?") 28return "asks"; 29elseif (length(smiley) > 3) 30return "says"; 31elseif (smiley[1] == ";") 32if (smiley[$] == ">") 33return "smirks"; 34elseif (smiley[$] == "/") 35return "winces"; 36elseif (smiley[$] == "(") 37return "grimaces"; 38endif 39return "winks"; 40elseif (smiley == ":)") 41return "smiles"; 42elseif (smiley == ":}") 43return "chuckles"; 44elseif (smiley == ":D") 45return "laughs"; 46elseif (smiley == ":>") 47return "grins"; 48elseif (smiley == ":(") 49return "frowns"; 50elseif (smiley == ":[") 51return "complains"; 52elseif (smiley == ":P") 53return "plbbbbbts"; 54elseif (smiley == ":/") 55return "shrugs"; 56elseif (smiley == ":o") 57return "yawns"; 58elseif (smiley == ":0") 59return "yells"; 60elseif (smiley == ":|") 61return "sighs"; 62else 63return "says"; 64endif