Generic Help Database #24

Parent #1Owner #29Flags read, fertileSource hellcore/hellcore.db

Aliases: Generic Help Database

12 verbs · 12 properties · 9 children

Verbs

VerbSpecFlagsDefinerLines
find_topicsthis none thisrxd#2441
get_topicthis none thisrxd#2413
sort_topicsthis none thisrxd#2413
columnizethis none thisrxd#247
forward passthis none thisrxd#2421
substthis none thisrxd#2447
indexthis none thisrxd#246
initializethis none thisrxd#245
verbdocthis none thisrxd#249
dump_topicthis none thisrxd#246
objectdocthis none thisrxd#248
find_index_topicsthis none thisrxd#2428

Properties

PropertyDefinerFlagsOwnerValue
index#24rc#29{}
index_cache#24r#29{}
aliases#1rc#29{"Generic Help Database"}
description#1rc#29"A help database of the standard form in need of a description. See `help $generic_help'..."
object_size#1r#29{9729, 1298433815}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #1 root

Children: #14 Core Utility Help, #15 Programmer Help, #16 Wizard Help, #22 Builtin Function Help, #36 Editor Help, #52 Help Database, #78 Builder Help DB, #79 Mail Commands Help Db, #86 Frand Help DB

Call graph

calls n24_0 #24:find_topics n45_0 #45:has_property n24_0->n45_0 n45_1 #45:all_properties n24_0->n45_1 n24_1 #24:get_topic n24_1->n45_0 n24_2 #24:sort_topics n47_0 #47:make n24_2->n47_0 n47_6 #47:find_insert n24_2->n47_6 n48_8 #48:suspend_if_needed n24_2->n48_8 n47_10 #47:append n24_2->n47_10 n24_3 #24:columnize n47_28 #47:longest n24_3->n47_28 n20_60 #20:columnize_suspended n24_3->n20_60 n24_4 #24:forward n24_4->n24_1 n51_33 #51:help_db_search n24_4->n51_33 n24_5 #24:subst n31_2 #31:eval_d n24_5->n31_2 n24_6 #24:index n24_6->n24_0 n24_6->n24_2 n24_6->n48_8 n24_6->n24_3 n20_5 #20:from_list n24_6->n20_5 n20_38 #20:explode n24_6->n20_38 n24_7 #24:initialize n1_0 #1:initialize n24_7->n1_0 n42_0 #42:controls n24_7->n42_0 n24_8 #24:verbdoc n20_19 #20:match_object n24_8->n20_19 n45_2 #45:has_verb n24_8->n45_2 n51_11 #51:verb_documentation n24_8->n51_11 n24_9 #24:dump_topic n51_34 #51:corify_object n24_9->n51_34 n48_9 #48:dump_lines n24_9->n48_9 n24_10 #24:objectdoc n24_10->n45_0 n24_10->n45_2 n20_16 #20:literal_object n24_10->n20_16 n51_36 #51:verb_or_property n24_10->n51_36

Source

find_topics

Spec this none thisFlags rxdOwner #361Definer #24

Referenced by

Source

1"WIZARDLY";
2if (args)
3"...check for an exact match first...";
4search = args[1];
5if (`$object_utils:has_property(parent(this), search) ! ANY')
6if ($object_utils:has_property(this, " " + search))
7return {search};
8endif
9elseif ($object_utils:has_property(this, search))
10return {search};
11endif
12"...search for partial matches, allowing for";
13"...confusion between topics that do and don't start with @, and";
14".. confusion between - and _ characters.";
15props = properties(this);
16topics = {};
17if (search[1] == "@")
18search = search[2..$];
19endif
20search = strsub(search, "-", "_");
21if (!search)
22"...don't try searching for partial matches if the string is empty or @";
23"...we'd get *everything*...";
24return {};
25endif
26for prop in (props)
27if (((i = index(strsub(prop, "-", "_"), search)) == 1) || ((i == 2) && index(" @", prop[1])))
28topics = {@topics, (prop[1] == " ") ? prop[2..$] | prop};
29endif
30endfor
31return topics;
32else
33"...return list of all topics...";
34props = setremove(properties(this), "");
35for p in (`$object_utils:all_properties(parent(this)) ! ANY => {}')
36if (i = (" " + p) in props)
37props = {p, @listdelete(props, i)};
38endif
39endfor
40return props;
41endif

get_topic

Spec this none thisFlags rxdOwner #361Definer #24

Referenced by

Source

1"WIZARDLY";
2{topic, ?dblist = {}} = args;
3if (`$object_utils:has_property(parent(this), topic) ! ANY')
4text = `this.(" " + topic) ! ANY';
5else
6text = `this.(topic) || this.(" " + topic) ! ANY';
7endif
8if (typeof(text) == LIST)
9if (text && (text[1] == (("*" + (vb = strsub(text[1], "*", ""))) + "*")))
10text = `this:(vb)(listdelete(text, 1), dblist) ! ANY';
11endif
12endif
13return text;

sort_topics

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

Source

1":sort_topics(list_of_topics) -- sorts the given list of strings, assuming that they're help-system topic names";
2buckets = "abcdefghijklmnopqrstuvwxyz";
3keys = names = $list_utils:make(length(buckets) + 1, {});
4for name in (setremove(args[1], ""))
5key = index(".@", name[1]) ? name[2..$] + " " | name;
6k = index(buckets, key[1]) + 1;
7bucket = keys[k];
8i = $list_utils:find_insert(bucket, key);
9keys[k] = listinsert(bucket, key, i);
10names[k] = listinsert(names[k], name, i);
11$command_utils:suspend_if_needed(0);
12endfor
13return $list_utils:append(@names);

columnize

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

Source

1":columnize(@list_of_strings) -- prints the given list in a number of columns wide enough to accomodate longest entry. But no more than 4 columns.";
2longest = $list_utils:longest(args);
3for d in ({4, 3, 2, 1})
4if ((79 / d) >= length(longest))
5return $string_utils:columnize_suspended(0, args, d);
6endif
7endfor

forward pass

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

none

Source

1"{\"*forward*\", topic, @rest}  => text for topic from this help db.";
2"{\"*pass*\",    topic, @rest}  => text for topic from next help db.";
3"In both cases the text of @rest is appended.  ";
4"@rest may in turn begin with a *<verb>*";
5{text, ?dblist = {}} = args;
6if (verb == "forward")
7first = this:get_topic(text[1], dblist);
8elseif ((result = $code_utils:help_db_search(text[1], dblist)) && ((db = result[1]) != $ambiguous_match))
9first = db:get_topic(result[2], dblist[(db in dblist) + 1..$]);
10else
11first = {};
12endif
13if (2 <= length(text))
14if (text[2] == (("*" + (vb = strsub(text[2], "*", ""))) + "*"))
15return {@first, @`this:(vb)(text[3..$], dblist) ! ANY => {}'};
16else
17return {@first, @text[2..$]};
18endif
19else
20return first;
21endif

subst

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

none

Source

1"{\"*subst*\", @text} => text with the following substitutions:";
2"  \"...%[expr]....\" => \"...\"+value of expr (assumed to be a string)+\"....\"";
3"  \"%;expr\"         => @(value of expr (assumed to be a list of strings))";
4newlines = {};
5for old in (args[1])
6new = "";
7bomb = 0;
8while ((prcnt = index(old, "%")) && (prcnt < length(old)))
9new = new + old[1..prcnt - 1];
10code = old[prcnt + 1];
11old = old[prcnt + 2..$];
12if (code == "[")
13prog = "";
14while ((b = index(old + "]", "]")) > (p = index(old + "%", "%")))
15prog = (prog + old[1..p - 1]) + old[p + 1];
16old = old[p + 2..$];
17endwhile
18prog = prog + old[1..b - 1];
19old = old[b + 1..$];
20value = $no_one:eval_d(prog);
21if (value[1])
22new = tostr(new, value[2]);
23else
24new = tostr(new, toliteral(value[2]));
25bomb = 1;
26endif
27elseif ((code != ";") || new)
28new = (new + "%") + code;
29else
30value = $no_one:eval_d(old);
31if (value[1] && (typeof(r = value[2]) == LIST))
32newlines = {@newlines, @r[1..$ - 1]};
33new = tostr(r[$]);
34else
35new = tostr(new, toliteral(value[2]));
36bomb = 1;
37endif
38old = "";
39endif
40endwhile
41if (bomb)
42newlines = {@newlines, new + old, tostr("@@@ Helpfile alert:  Previous line is messed up; notify ", this.owner.wizard ? "" | tostr(this.owner.name, " (", this.owner, ") or "), "a wizard. @@@")};
43else
44newlines = {@newlines, new + old};
45endif
46endfor
47return newlines;

index

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

none

Source

1"{\"*index*\" [, title]}";
2"This produces a columnated list of topics in this help db, headed by title.";
3$command_utils:suspend_if_needed(0);
4title = args[1] ? args[1][1] | tostr(this.name, " (", this, ")");
5su = $string_utils;
6return {"", title, su:from_list($list_utils:map_arg(su, "space", su:explode(title), "-"), " "), @this:columnize(@this:sort_topics(this:find_topics()))};

initialize

Spec this none thisFlags rxdOwner #361Definer #24

Referenced by

none

Source

1pass(@args);
2if ($perm_utils:controls(caller_perms(), this))
3this.r = 1;
4this.f = 0;
5endif

verbdoc

Spec this none thisFlags rxdOwner #361Definer #24

Referenced by

none

Source

1"{\"*verbdoc*\", \"object\", \"verbname\"}  use documentation for this verb";
2set_task_perms(this.owner);
3if (!valid(object = $string_utils:match_object(args[1][1], player.location)))
4return E_INVARG;
5elseif (!(hv = $object_utils:has_verb(object, vname = args[1][2])))
6return E_VERBNF;
7else
8return $code_utils:verb_documentation(hv[1], vname);
9endif

dump_topic

Spec this none thisFlags rxdOwner #361Definer #24

Referenced by

Source

1try
2text = this.(fulltopic = args[1]);
3return {tostr(";;", $code_utils:corify_object(this), ".(", toliteral(fulltopic), ") = $command_utils:read_lines()"), @$command_utils:dump_lines(text)};
4except error (ANY)
5return error[1];
6endtry

objectdoc

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

none

Source

1"{\"*objectdoc*\", \"object\"} => text for topic from object:help_msg";
2if (!valid(object = $string_utils:literal_object(args[1][1])))
3return E_INVARG;
4elseif (!($object_utils:has_verb(object, "help_msg") || $object_utils:has_property(object, "help_msg")))
5return E_VERBNF;
6else
7return $code_utils:verb_or_property(object, "help_msg");
8endif

find_index_topics

Spec this none thisFlags rxdOwner #29Definer #24

Referenced by

none

Source

1":find_index_topic([search])";
2"Return the list of index topics of this help DB";
3"(i.e., those which contain an index (list of topics)";
4"this DB, return it, otherwise return false.";
5"If search argument is given and true,";
6"we first remove any cached information concerning index topics.";
7{?search = 0} = args;
8if (this.index_cache && (!search))
9"...make sure every topic listed in .index_cache really is an index topic";
10for p in (this.index_cache)
11if (!("*index*" in `this.(p) ! ANY => {}'))
12search = 1;
13endif
14endfor
15if (!search)
16return this.index_cache;
17endif
18elseif ($generic_help == this)
19return {};
20endif
21itopics = {};
22for p in (properties(this))
23if ((h = `this.(p) ! ANY') && ("*index*" in h))
24itopics = {@itopics, p};
25endif
26endfor
27this.index_cache = itopics;
28return itopics;