K

=== help kill_task() ================================

Syntax:	kill_task (num <task-id>)   => none

Removes the task with the given <task-id> from the queue of waiting tasks.
If the programmer is not the owner of that task and not a wizard, then `E_PERM' is returned.
If there is no task on the queue with the given <task-id>, then `E_INVARG' is returned.

 L

=== help length() ==================================

Syntax: length (<list or string>)   => num

Returns the number of characters in <list or string>.
	length("foo")       		=>   3
	length("")          		=>   0
	length({1, 2, 3})   	=>   3
	length({})          		=>   0

=== help listappend() ===============================

Syntax:  listinsert (list <list>, <value> [, num <index>])   	=> list
         listappend (list <list>, <value> [, num <index>])   	=> list

These functions return a copy of <list> with <value> added as a new element. `listinsert()' and `listappend()' add <value> before and after (respectively) the existing element with the given <index>, if provided.

The following three expressions always have the same value:

    listinsert(<list>, <element>, <index>)
    listappend(<list>, <element>, <index> - 1)
    {@<list>[1..<index> - 1], <element>, @<list>[<index>..length(<list>)]}
If <index> is not provided, then `listappend()' adds the <value> at the end of the list and `listinsert()' adds it at the beginning; this usage is discouraged, however, since the same intent can be more clearly expressed using the list-construction expression, as shown in the examples below.
    x = {1, 2, 3};
    listappend(x, 4, 2)   	=>   {1, 2, 4, 3}
    listinsert(x, 4, 2)   	=>   {1, 4, 2, 3}
    listappend(x, 4)      	=>   {1, 2, 3, 4}
    listinsert(x, 4)      	=>   {4, 1, 2, 3}
    {@x, 4}               	=>   {1, 2, 3, 4}
    {4, @x}               	=>   {4, 1, 2, 3}

=== help listdelete() ================================

Syntax: listdelete (list <list>, num <index>)   => list

Returns a copy of <list> with the <index>th element removed.
If <index> is not in the range `[1..length(<list>)]', then `E_RANGE' is returned.
    x = {"foo", "bar", "baz"};
    listdelete(x, 2)   =>   {"foo", "baz"}

=== help listen() ==================================

Syntax: listen (OBJ object, point [, print-messages])   => value

Create a new point at which the server will listen for network connections, just as it does normally. <object> is the object whose verbs `do_login_command ', `do_command', `do_out_of_band_command', `user_connected', `user_created', `user_reconnected', `user_disconnected', and `user_client_disconnected' will be called at appropriate points asthese verbs are called on #0 for normal connections.

(See the chapter in the LambdaMOO Programmer's Manual on server assumptions about the database for the complete story on when these functions are called.) <Point> is a network-configuration-specific parameter describing the listening point.
If <print-messages> is provided and true, then the various database-configurable messages (also detailed in the chapter on server assumptions) will be printed on connections received at the new listening point. `Listen()' returns <canon>, a `canonicalized' version of <Point>, with any configuration-specific defaulting or aliasing accounted for.

This raises E_PERM if the programmer is not a wizard, E_INVARG if <object> is invalid or there is already a listening point described by <Point>, and E_QUOTA if some network-configuration-specific error occurred.

For the TCP/IP configurations, <Point> is a TCP port number on which to listen and <canon> is equal to <Point> unless <Point> is zero, in which case <canaon> is a port number assigned by the operating system.

For the local multi-user configurations, <Point> is the UNIX file name to be used as the connection point and <canon> is always equal to <Point>.

In the single-user configuration, there can be only one listening point at a time; <Point> can be any value at all and <canon> is always zero.

=== help listeners() ================================

Syntax: listeners ()  => LIST

Returns a list describing all existing listening points, including the default one set up automatically by the server when it was started (unless that one has since been destroyed by a call to `unlisten()'). Each element of the list has the following form:
  {<object>, <canon>, <print-messages>}
where <object> is the first argument given in the call to `listen()' to create this listening point, <print-messages> is true if the third argument in that call was provided and true, and <canon> was the value returned by that call.
(For the initial listening point, <object> is #0, <canon> is determined by the command-line arguments or a network-configuration-specific default, and <print-messages> is true.)

=== help listinsert() ================================

Syntax: listinsert (list <list>, <value> [, num <index>])   => list
        listappend (list <list>, <value> [, num <index>])   => list

These functions return a copy of <list> with <value> added as a new element. `listinsert()' and `listappend()' add <value> before and after (respectively) the existing element with the given <index>, if provided.

The following three expressions always have the same value:

    listinsert(<list>, <element>, <index>)
    listappend(<list>, <element>, <index> - 1)
    {@<list>[1..<index> - 1], <element>, @<list>[<index>..length(<list>)]}
If <index> is not provided, then `listappend()' adds the <value> at the end of the list and `listinsert()' adds it at the beginning; this usage is discouraged, however, since the same intent can be more clearly expressed using the list-construction expression, as shown in the examples below.
    x = {1, 2, 3};
    listappend(x, 4, 2)   	=>   {1, 2, 4, 3}
    listinsert(x, 4, 2)   	=>   {1, 4, 2, 3}
    listappend(x, 4)      	=>   {1, 2, 3, 4}
    listinsert(x, 4)      	=>   {4, 1, 2, 3}
    {@x, 4}               	=>   {1, 2, 3, 4}
    {4, @x}               	=>   {4, 1, 2, 3}

=== help listset() ==================================

Syntax:	listset (list <list>, <value>, num <index>)   => list

Returns a copy of <list> with the <index>th element replaced by <value>. If <index> is not in the range `[1..length(<list>)]', then `E_RANGE' is returned.
    x = {"foo", "bar", "baz"};
    listset(x, "mumble", 2)   =>   {"foo", "mumble", "baz"}

=== help log() ====================================

Syntax: log (FLOAT x)     => FLOAT
         log10 (FLOAT x)   => FLOAT

Returns the natural or base 10 logarithm of <x>. Raises E_INVARG if <x> is not positive.

M

=== help match() ==================================

Syntax:	match (str <subject>, str <pattern> [, <case-matters>])  => list
        rmatch (str <subject>, str <pattern> [, <case-matters>])  => list

The function `match()' (`rmatch()') searches for the first (last) occurrence of the regular expression <pattern> in the string <subject>.
If <pattern> is syntactically malformed, then `E_INVARG' is returned.
If no match is found, the empty list is returned; otherwise, these functions return a list containing information about the match (see below). By default, the search ignores upper/lower case distinctions.
If <case-matters> is provided and true, then case is treated as significant in all comparisons.

The list that `match()' (`rmatch()') returns contains the details about the match made. The list is in the form:

     {<start>, <end>, <replacements>, <subject>}
where <start> is the index in STRING of the beginning of the match, <end> is the index of the end of the match, <replacements> is a list described below, and <subject> is the same string that was given as the first argument to the `match()' or `rmatch()'.

The <replacements> list is always nine items long, each item itself being a list of two numbers, the start and end indices in <subject> matched by some parenthesized sub-pattern of <pattern>. The first item in <replacements> carries the indices for the first parenthesized sub-pattern, the second item carries those for the second sub-pattern, and so on. If there are fewer than nine parenthesized sub-patterns in <pattern>, or if some sub-pattern was not used in the match, then the corresponding item in <replacements> is the list {0, -1}. See the discussion of `%)' in `help regular-expressions', for more information on parenthesized sub-patterns.

   match("foo", "f*o")          	=>  {1, 2, {{0, -1}, ...}, "foo"}
   match("foo", "fo*")          	=>  {1, 3, {{0, -1}, ...}, "foo"}
   match("foobar", "o*b")       	=>  {2, 4, {{0, -1}, ...}, "foobar"}
   rmatch("foobar", "o*b")      	=>  {4, 4, {{0, -1}, ...}, "foobar"}
   match("foobar", "f%(o*%)b")  	=>  {1, 4, {{2, 3}, {0, -1}, ...}, "foobar"}
See `help regular-expressions' for information on the syntax and semantics of patterns.

=== help max() ===================================

Syntax:	min (num <x>, ...)   => num
       	max (num <x>, ...)   => num

These two functions return the smallest or largest of their arguments, respectively. All of the arguments must be numbers; otherwise `E_TYPE' is returned.

=== help max_object() ==============================

Syntax: max_object ()   => obj

Returns the largest object number yet assigned to a created object. Note that the object with this number may no longer exist; it may have been recycled. The next object created will be assigned the object number one larger than the value of `max_object()'.

=== help memory_usage() ===========================

Syntax:	memory_usage ()   => list

On some versions of the server, this returns statistics concerning the server consumption of system memory. The result is a list of lists, each in the following format:
    {<block-size>, <nused>, <nfree>}
where <block-size> is the size in bytes of a particular class of memory fragments, <nused> is the number of such fragments currently in use in the server, and <nfree> is the number of such fragments that have been reserved for use but are currently free.

On servers for which such statistics are not available, `memory_usage()' returns `{}'. The compilation option `USE_SYSTEM_MALLOC' controls whether or not statistics are available; if the option is provided, statistics are not available.

=== help min() ===================================

Syntax:	min (num <x>, ...)   => num
       	max (num <x>, ...)   => num

These two functions return the smallest or largest of their arguments, respectively. All of the arguments must be numbers; otherwise `E_TYPE' is returned.

=== help move() ==================================

Syntax:	move (obj <what>, obj <where>)   => none

Changes <what>'s location to be <where>. This is a complex process because a number of permissions checks and notifications must be performed. The actual movement takes place as described in the following paragraphs.

<what> should be a valid object and <where> should be either a valid object or `#-1' (denoting a location of 'nowhere'); otherwise `E_INVARG' is returned. The programmer must be either the owner of <what> or a wizard; otherwise, `E_PERM' is returned.

If <where> is a valid object, then the verb-call

    <where>:accept(<what>)
is performed before any movement takes place.
If the verb returns a false value and the programmer is not a wizard, then <where> is considered to have refused entrance to <what>; `move()' returns `E_NACC'.
If <where> does not define an `accept' verb, then it is treated as if it defined one that always returned false.

If moving <what> into <where> would create a loop in the containment hierarchy (i.e., <what> would contain itself, even indirectly), then `E_RECMOVE' is returned instead.

The `location' property of <what> is changed to be <where>, and the `contents' properties of the old and new locations are modified appropriately. Let <old-where> be the location of <what> before it was moved. If <old-where> is a valid object, then the verb-call

    <old-where>:exitfunc(<what>)
is performed and its result is ignored; it is not an error if <old-where> does not define a verb named `exitfunc'. Finally, if <where> and <what> are still valid objects, and <where> is still the location of <what>, then the verb-call
    <where>:enterfunc(<what>)
is performed and its result is ignored; again, it is not an error if <where> does not define a verb named `enterfunc'.

 N

=== help notify() ==================================

Syntax:	notify (obj <player>, str <string>)   => none

Outputs <string> (on a line by itself) to the user connected to the given <player>.
If the programmer is not <player> or a wizard, then `E_PERM' is returned.
If there is no currently-active connection to <player>, then this function does nothing.

Syntax: notify (OBJ conn, STR string [, no-flush]) => 0 or 1

Enqueues <string& for output (on a line by itself) on the connection <conn>.
If the programmer is not <conn> or a wizard, then E_PERM is raised. If <conn> is not a currently-active connection, then this function does nothing. Output is normally written to connections only between tasks, not during execution.

The server will not queue an arbitrary amount of output for a connection; the `MAX_QUEUED_OUTPUT' compilation option (in `options.h') controls the limit. When an attempt is made to enqueue output that would take the server over its limit, it first tries to write as much output as possible to the connection without having to wait for the other end. If that doesn't result in the new output being able to fit in the queue, the server starts throwing away the oldest lines in the queue until the new output will fit. The server remembers how many lines of output it has `flushed' in this way and, when next it can succeed in writing anything to the connection, it first writes a line like `>> Network buffer overflow; X lines of output to you have been lost <<' where <X> is the number of of flushed lines.

If <no-flush is provided and true, then `notify()' never flushes any outputfrom the queue; instead it immediately returns false. `Notify()' otherwise always returns true.

 O

=== help object_bytes ==============================

Syntax: object_bytes (OBJ object)   => INT

Returns the number of bytes of the server's memory required to store the given <object>, including the space used by the values of all its non-clear properties and by the verbs and properties defined directly on the object.
Raises E_INVARG if <object> is not a valid object and E_PERM if the programmer is not a wizard.

=== help open_network_connection() ===================

Syntax:	open_network_connection (<value>, ...)   => obj

Establishes a network connection to the place specified by the arguments and pretends that a new, normal player connection has been established from there. The new connection, as usual, will not be logged in initially and will have a negative object number associated with it for use with `read()', `notify()', and `boot_player()'. This object number is the value returned by this function.

If the programmer is not a wizard or if the `OUTBOUND_NETWORK' compilation option was not used in building the server, then `E_PERM' is returned.
If the network connection cannot be made for some reason, then other errors will be returned, depending upon the particular network implementation in use.

For the BSD UNIX network implementation (the only publicly-available one as of this writing), there must be two arguments, a string naming a host (possibly using the numeric Internet syntax) and a number specifying a TCP port.
If a connection cannot be made because the host does not exist, the port does not exist, the host is not reachable or refused the connection, `E_INVARG' is returned.
If the connection cannot be made for other reasons, including resource limitations, then `E_QUOTA' is returned.

It is worth mentioning a couple of tricky points concerning the use of this function.

Since the server treats the new connection like any other normal player connection, it will naturally try to parse any input from that connection as commands in the usual way. To prevent this treatment, it is necessary to ensure that some task is always suspended using `read()' on the connection whenever the server considers a line of input from it. That way, the line of input will be given to that task instead of being parsed as a command. The only reliable way to ensure this is for the task that opens the connection to enter an infinite loop reading from the connection. One possible structure for such a task is as follows:

	conn = open_network_connection(...);
	read(conn);
	while (1)
	line = read(conn);
	fork (0)
	this:handle_input(line);
	endfork
	endwhile
The first call to `read()' in this example is to discard the null line of input always automatically supplied by the server for new connections; for more details, see the discussion of `#0:do_login_command' in the section on server commands and database assumptions.

The second fine point to be considered is that, unless the new connection eventually `logs in' in the usual way for players, the server will impose its usual five-minute timeout on it, shutting down the connection unless new input arrives at least once every five minutes.

=== help output_delimiters() =========================

Syntax:	output_delimiters (obj <player>)   => list

Returns a list of two strings, the current "output prefix" and "output suffix" for <player>.
If <player> does not have an active network connection, then `E_INVARG' is returned.
If either string is currently undefined, the value `""' is used instead. See the discussion of the `PREFIX' and `SUFFIX' commands in the next chapter for more information about the output prefix and suffix.

 P

=== help parent() =================================

Syntax: parent (obj <object>)     => obj
       	children (obj <object>)   => list

These functions return the parent and a list of the children of <object>, respectively.
If <object> is not valid, then `E_INVARG' is returned.

=== help pass() ===================================

Syntax: pass (<arg>,...)

Often, it is useful for a child object to define a verb that *augments* the behavior of a verb on its parent object. For example, the root object (an ancestor of every other object) defines a :description() verb that simply returns the value of `this.description'; this verb is used by the implementation of the `look' command.
In many cases, a programmer would like the description of some object to include some non-constant part; for example, a sentence about whether or not the object was `awake' or `sleeping'.
This sentence should be added onto the end of the normal description. The programmer would like to have a means of calling the normal `description' verb and then appending the sentence onto the end of that description. The function `pass()' is for exactly such situations.

pass() calls the verb with the same name as the current verb but as defined on the parent of the object that defines the current verb. The arguments given to the called verb are the ones given to pass() and the returned value of the called verb is returned from the call to pass(). The initial value of `this' in the called verb is the same as in the calling verb.

Thus, in the example above, the child-object's :description() verb might have the following implementation:

    return pass(@args) + "  It is " + (this.awake ? "awake." | "sleeping.");
That is, it calls its parent's :description() verb and then appends to the result a sentence whose content is computed based on the value of a property on the object.

In the above example, `pass()' would have worked just as well, since :description() is not normally given any arguements. However, it is a good idea to get into the habit of using `pass(@args)' rather than `pass(args[1])' or `pass()' even if the verb being pass()ed to is already known to take a set number of arguments or none at all.
For one thing, though the args may be irrelevant to the code that you've written, it may be that the corresponding verb on the parent has been rewritten to take additional arguments, in which case you will want your verb to continue to work...

=== help players() =================================

Syntax: players ()   => list

Returns a list of the object numbers of all player objects in the database.

=== help properties() ===============================

Syntax: properties (obj <object>)   => list

Returns a list of the names of the properties defined directly on the given <object>, not inherited from its parent.
If <object> is not valid, then `E_INVARG' is returned.
If the programmer does not have read permission on <object>, then `E_PERM' is returned.

=== help property_info() ============================

Syntax: property_info (obj <object>, str <prop-name>)	=> list
     	set_property_info (obj <object>, str <prop-name>, list <info>)	=> none

These two functions get and set (respectively) the owner and permission bits for the property named <prop-name> on the given <object>.
If <object> is not valid, then `E_INVARG' is returned.
If <object> has no non-built-in property named <prop-name>, then `E_PROPNF' is returned.
If the programmer does not have read (write) permission on the property in question, then `property_info()' (`set_property_info()') returns `E_PERM'. Property info has the following form:
    {<owner>, <perms>}
where <owner> is an object and <perms> is a string containing only characters from the set `r', `w', and `c'. This is the kind of value returned by `property_info()' and expected as the third argument to `set_property_info()'; the latter function returns `E_INVARG' if <owner> is not valid or <perms> contains any illegal characters.

 Q

=== help queue_info ===============================

Syntax: queue_info([obj user])

Returns the number of forked tasks that <user> has at the moment. Since it doesn't say which tasks, security is not a significant issue.
If no argument is given, then gives a list of all users with task queues in the server.
(Essentially all connected players + all open connections + all users with tasks running in the background.)

=== help queued_tasks() ============================

Syntax: queued_tasks ()   => list

Returns information on each of the forked, suspended or reading tasks owned by the programmer (or, if the programmer is a wizard, all queued tasks). The returned value is a list of lists, each of which encodes certain information about a particular queued task in the following format:
    {<task-id>, <start-time>, <ticks>, <clock-id>,
     <programmer>, <verb-loc>, <verb-name>, <line>, <this>}
where <task-id> is a numeric identifier for this queued task, <start-time> is the time after which this task will begin execution (in `time()' format), <ticks> is the number of ticks this task will have when it starts (always 20,000 now), <clock-id> is a number whose value is no longer interesting, <programmer> is the permissions with which this task will begin execution (and also the player who "owns" this task), <verb-loc> is the object on which the verb that forked this task was defined at the time, <verb-name> is that name of that verb, <line> is the number of the first line of the code in that verb that this task will execute, and <this> is the value of the variable `this' in that verb. For reading tasks, <start-time> is `-1'.

The <ticks> and <clock-id> fields are now obsolete and are retained only for backward-compatibility reasons. They may disappear in a future version of the server.