Generic Help Database #30

Parent #1Owner #36Flags read, fertileSource RPG Core/rpgcore-patched.db

Aliases: Generic Help Database

12 verbs · 7 properties · 12 children

Verbs

VerbSpecFlagsDefinerLines
find_topicsthis none thisrxd#3043
get_topicthis none thisrxd#3013
sort_topicsthis none thisrxd#3013
columnizethis none thisrxd#307
forward passthis none thisrxd#3021
substthis none thisrxd#3048
indexthis none thisrxd#306
initializethis none thisrxd#305
verbdocthis none thisrxd#309
dump_topicthis none thisrxd#306
objectdocthis none thisrxd#308
find_index_topicsthis none thisrxd#3029

Properties

PropertyDefinerFlagsOwnerValue
index#30rc#36{}
index_cache#30r#36{}
key#1c#36<clear>
aliases#1rc#36{"Generic Help Database"}
description#1rc#36"A help database of the standard form in need of a description. See `help $generic_help'..."
object_size#1r#36{10422, -1090650497}
html#1rc#36<clear>

Ancestry

Ancestors (nearest first): #1 Root Class

Children: #19 Core Utility Help, #22 Programmer Help, #23 Wizard Help, #28 Builtin Function Help, #44 Editor Help, #60 Help Database, #85 Builder Help DB, #86 Mail Commands Help Db, #96 ANSI Help, #105 RPG help, #106 RPG objects help, #139 Frand Help DB

Call graph

calls n30_0 #30:find_topics n52_0 #52:has_property n30_0->n52_0 n52_1 #52:all_properties n30_0->n52_1 n30_1 #30:get_topic n30_1->n52_0 n30_2 #30:sort_topics n55_0 #55:make n30_2->n55_0 n55_6 #55:find_insert n30_2->n55_6 n55_10 #55:append n30_2->n55_10 n30_3 #30:columnize n55_28 #55:longest n30_3->n55_28 n20_60 #20:columnize_suspended n30_3->n20_60 n30_4 #30:forward n30_4->n30_1 n59_33 #59:help_db_search n30_4->n59_33 n30_5 #30:subst n38_2 #38:eval_d n30_5->n38_2 n30_6 #30:index n30_6->n30_0 n30_6->n30_2 n30_6->n30_3 n56_8 #56:suspend_if_needed n30_6->n56_8 n20_5 #20:from_list n30_6->n20_5 n55_4 #55:map_arg n30_6->n55_4 n20_38 #20:explode n30_6->n20_38 n30_7 #30:initialize n1_0 #1:initialize n30_7->n1_0 n42_0 #42:controls n30_7->n42_0 n30_8 #30:verbdoc n20_19 #20:match_object n30_8->n20_19 n52_2 #52:has_verb n30_8->n52_2 n59_11 #59:verb_documentation n30_8->n59_11 n30_9 #30:dump_topic n59_34 #59:corify_object n30_9->n59_34 n56_9 #56:dump_lines n30_9->n56_9 n30_10 #30:objectdoc n30_10->n52_0 n30_10->n52_2 n20_16 #20:literal_object n30_10->n20_16 n59_36 #59:verb_or_property n30_10->n59_36

Source

find_topics

Spec this none thisFlags rxdOwner #2Definer #30

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)
27(ticks_left() < 4000) && suspend(0);
28if (((i = index(strsub(prop, "-", "_"), search)) == 1) || ((i == 2) && index(" @", prop[1])))
29topics = {@topics, (prop[1] == " ") ? prop[2..$] | prop};
30endif
31endfor
32return topics;
33else
34"...return list of all topics...";
35props = setremove(properties(this), "");
36for p in (`$object_utils:all_properties(parent(this)) ! ANY => {}')
37(ticks_left() < 4000) && suspend(0);
38if (i = (" " + p) in props)
39props = {p, @listdelete(props, i)};
40endif
41endfor
42return props;
43endif

get_topic

Spec this none thisFlags rxdOwner #2Definer #30

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 #36Definer #30

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(ticks_left() < 4000) && suspend(0);
12endfor
13return $list_utils:append(@names);

columnize

Spec this none thisFlags rxdOwner #36Definer #30

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 #36Definer #30

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 #36Definer #30

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)))
9(ticks_left() < 4000) && suspend(0);
10new = new + old[1..prcnt - 1];
11code = old[prcnt + 1];
12old = old[prcnt + 2..$];
13if (code == "[")
14prog = "";
15while ((b = index(old + "]", "]")) > (p = index(old + "%", "%")))
16prog = (prog + old[1..p - 1]) + old[p + 1];
17old = old[p + 2..$];
18endwhile
19prog = prog + old[1..b - 1];
20old = old[b + 1..$];
21value = $no_one:eval_d(prog);
22if (value[1])
23new = tostr(new, value[2]);
24else
25new = tostr(new, toliteral(value[2]));
26bomb = 1;
27endif
28elseif ((code != ";") || new)
29new = (new + "%") + code;
30else
31value = $no_one:eval_d(old);
32if (value[1] && (typeof(r = value[2]) == LIST))
33newlines = {@newlines, @r[1..$ - 1]};
34new = tostr(r[$]);
35else
36new = tostr(new, toliteral(value[2]));
37bomb = 1;
38endif
39old = "";
40endif
41endwhile
42if (bomb)
43newlines = {@newlines, new + old, tostr("@@@ Helpfile alert:  Previous line is messed up; notify ", this.owner.wizard ? "" | tostr(this.owner.name, " (", this.owner, ") or "), "a wizard. @@@")};
44else
45newlines = {@newlines, new + old};
46endif
47endfor
48return newlines;

index

Spec this none thisFlags rxdOwner #36Definer #30

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 #2Definer #30

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 #2Definer #30

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 #2Definer #30

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 #36Definer #30

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 #36Definer #30

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
14(ticks_left() < 4000) && suspend(0);
15endfor
16if (!search)
17return this.index_cache;
18endif
19elseif ($generic_help == this)
20return {};
21endif
22itopics = {};
23for p in (properties(this))
24if ((h = `this.(p) ! ANY') && ("*index*" in h))
25itopics = {@itopics, p};
26endif
27endfor
28this.index_cache = itopics;
29return itopics;