Difference between revisions of "Manual:DIL Manual/pagestring()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bppagestring"></span>
+
= pagestring() =
−
  pathto(buff : string, u : unitptr )
+
'''Procedure.''' Sends a long text to a player, to be shown a page at a time.
−
    buff  : The string that is to be paged to the player.
+
 
−
u : The unitptr the buff is to be paged for.
+
  pagestring(s : string, u : unitptr)
−
    returns: nothing
+
 
−
example:
+
Sends <code>s</code> to the player <code>u</code> marked as paged text (wrapped in
−
pagestring (buff,self);
+
<code>&lt;paged&gt;</code>), so that the player's client can show it a screenful at a time
−
would format the buff string to the player so the buff text doesn't scroll
+
instead of letting it scroll past. Use it for lists and other long output; for short text use
−
off the screen until after the player presses enter.
+
[[Manual:DIL Manual/sendtext()|sendtext()]].
−
<span id="bppagestring"></span>
+
 
−
pathto(buff : string, u : unitptr )
+
== Parameters ==
−
    buff  : The string that is to be paged to the player.
+
{| class="wikitable"
−
u : The unitptr the buff is to be paged for.
+
! Name !! Type !! Meaning
−
    returns: nothing
+
|-
−
example:
+
| s || string || The text, with <code>&lt;br/&gt;</code> between lines.
−
pagestring (buff,self);
+
|-
−
would format the buff string to the player so the buff text doesn't scroll
+
| u || unitptr || The player.
−
off the screen until after the player presses enter.
+
|}
 +
 
 +
== Notes ==
 +
* Only characters: on an object or a room the zone log gets "Type error in not a pc/npc unit" and the program stops. With a null unit nothing is sent, apart from a line in the zone log ("pagestring with no unit").
 +
* An NPC, or a player who isn't connected, gets nothing (unless a player is switched into the NPC).
 +
* A god snooping the player sees the text too.
 +
* An empty string sends nothing.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin list_players();
 +
var
 +
  pc : unitptr;
 +
  s : string;
 +
code
 +
{
 +
  s := "<u>Players in the game</u><br/>";
 +
  pc := pc_head();
 +
  while (pc != null)
 +
  {
 +
      if (pc.type != UNIT_ST_PC)
 +
        break;
 +
      s := s + pc.name + "<br/>";
 +
      pc := pc.gnext;
 +
  }
 +
  pagestring(s, self);
 +
  quit;
 +
}
 +
dilend
 +
</pre>
 +
Lists the players in the game, a page at a time.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/sendtext()|sendtext()]]
 +
* [[Manual:DIL Manual/act()|act()]]
 +
* [[Manual:DIL Manual/textformat()|textformat()]]
 +
* [[Manual:DIL Manual/pc head()|pc_head()]]

Latest revision as of 23:22, 14 November 2026

pagestring()

Procedure. Sends a long text to a player, to be shown a page at a time.

pagestring(s : string, u : unitptr)

Sends s to the player u marked as paged text (wrapped in <paged>), so that the player's client can show it a screenful at a time instead of letting it scroll past. Use it for lists and other long output; for short text use sendtext().

Parameters

Name Type Meaning
s string The text, with <br/> between lines.
u unitptr The player.

Notes

  • Only characters: on an object or a room the zone log gets "Type error in not a pc/npc unit" and the program stops. With a null unit nothing is sent, apart from a line in the zone log ("pagestring with no unit").
  • An NPC, or a player who isn't connected, gets nothing (unless a player is switched into the NPC).
  • A god snooping the player sees the text too.
  • An empty string sends nothing.

Example

dilbegin list_players();
var
   pc : unitptr;
   s : string;
code
{
   s := "<u>Players in the game</u><br/>";
   pc := pc_head();
   while (pc != null)
   {
      if (pc.type != UNIT_ST_PC)
         break;
      s := s + pc.name + "<br/>";
      pc := pc.gnext;
   }
   pagestring(s, self);
   quit;
}
dilend

Lists the players in the game, a page at a time.

See also