( IrvPage Version 2.5.0 )  ( By Irvin' )  ( NewPegasus )  ( 7 Sep 92 )
( Macros Required:                                                   )
( check+ cr datestr exit_name id pmatch+ tell timestr trim_spaces    )
( timedate sps sts                                                   )

var args var args-2 var temp var temp-2 var temp-3
var counter var counter-2 var curr var xformat var me_prop var you_prop
var player var page_format var page_message var room

: check stringcmp not ;

: setup
  "" page_message !
  "" temp-3 !
  "%message" page_format !
  "X" args-2 !
  1 curr !
  0 counter-2 !
  me @ player !
;

: pro_sub
  args-2 @ "X" strcmp not if exit then
  player @ location .id "%toloc" subst
  me @ location .id "%loc" subst
  player @ name "%to" subst
  .timestr "%time" subst
  .datestr "%date" subst
  "%%message" "%message" subst
  "%%mess" "%mess" subst
  me @ swap pronoun_sub
  page_message @ "%message" subst
  temp-3 @ "" check temp-3 @ ":" instr 1 = or temp-3 @ ";" instr 1 = or if
    page_message @
  else
    temp-3 @
  then  
  "%mess" subst
;

: more?
  "More? <y/n>" .tell
  read "n" check if 0 else 1 then
;

: haven?
  dup location "h" flag? swap "h" flag? or
;

: me_own?
  owner me @ dbcmp me @ "w" flag? or
;

: helptitle
  ">> IrvPage Version 2.5.0 by Irvin': HELP! <<" .tell
;

: for_help
  "(Type '" trigger @ .exit_name strcat " -help' for help.)" strcat .tell
;

: fail_priv
  "FATAL ERROR :  Privilege Violation." .tell
  for_help
;

: fail_entry
  "Please enter a database reference number." .tell
;

: fail_own
  "You do not own that object." .tell
;

: fail_room
  "FATAL ERROR :  Unknown Room." .tell
  for_help
  counter-2 @ 1 + counter-2 !
;

: fail_name
  "FATAL ERROR :  Unknown Player." .tell
  for_help
  counter-2 @ 1 + counter-2 !
;

: get_prop
  me @ "_page-propobj" getpropstr dup "" check if
    pop me @
  else
    atoi dbref
  then me_prop !
  player @ "_page-propobj" getpropstr dup "" check if
    pop player @
  else
    atoi dbref
  then you_prop !
;

: show_prop
  get_prop
  "IrvPage properties stored on: " me_prop @ .id strcat .tell
;

: move_prop
  dup dup temp @ swap getpropstr
  me_prop @ rot rot 0 addprop
  temp @ swap remove_prop
;

: set_prop
  show_prop
  me_prop @ temp !
  "Enter new property storage object or 'exit' to abort:" .tell
  read
  dup "exit" check if "Exiting." .tell exit then
  dup "me" check if
    me @
  else
    dup "" "#" subst
    dup number? not if fail_entry set_prop exit then
    atoi dbref
  then
  dup ok? not if fail_entry set_prop exit then
  dup me_own? not if fail_own set_prop exit then
  intostr
  me @ "_page-propobj" rot 0 addprop
  show_prop
  "_page-format" move_prop
  "_emote-format" move_prop
  "_summons-format" move_prop
  "_echo-format" move_prop
  "_prefix-format" move_prop
  "_haven-format" move_prop
  "_store-format" move_prop
  "_store" move_prop
  "_a-store" move_prop
  "_h-store" move_prop
  "_prefix" move_prop
  "_robot" move_prop
  "_page-lastpaged" move_prop
;

: summ_format
  you_prop @ "_robot" getpropstr "yes" check args-2 @ "X" check not and
  me_prop @ "_summons-format" getpropstr "" check or if
    "You sense that %n is looking for you in %loc." page_format !
  else
    me_prop @ "_summons-format" getpropstr page_format !
  then
  page_format @ pro_sub page_format !
;

: echo_format
  me_prop @ "_echo-format" getpropstr dup "" check if pop
    "Message sent to %to." then
  pro_sub .tell
;

: get_format
  page_message @ temp !
  you_prop @ "_robot" getpropstr "yes" check args-2 @ "X" check not and
  me_prop @ "_page-format" getpropstr "" check or if
    "%n pages from %loc: %message" page_format !
  else
    me_prop @ "_page-format" getpropstr page_format !
  then
  page_format @ pro_sub page_format !
  temp @ page_message !
;

: emote_format
  page_message @ temp !
  page_message @ 1 strcut page_message ! pop
  you_prop @ "_robot" getpropstr "yes" check args-2 @ "X" check not and
  me_prop @ "_emote-format" getpropstr "" check or if
    "You sense that %n %message" page_format !
  else
    me_prop @ "_emote-format" getpropstr page_format !
  then
  page_format @ pro_sub page_format !
  temp @ page_message !
;

: pemit_format
  page_message @ temp !
  page_message @ 1 strcut
  ">> " swap strcat
  page_format !
  temp @ page_message !
  pop
;
 
: message_prefix
  you_prop @ "_prefix-format" getpropstr dup
  "" check if pop
    "%time>> %message" then
  pro_sub page_format !
;

: store_format
  you_prop @ "_store-format" getpropstr dup
  "" check if pop
    "Message for %to stored." then
  pro_sub .tell
;

: read_stored
  me_prop @ "message-" curr @ intostr strcat getpropstr dup
  "" check if pop exit then
  .tell
  me_prop @ "message-" curr @ intostr strcat remove_prop
  curr @ 1 + curr !
  read_stored
;

: stored_num
  you_prop @ "message-" curr @ intostr strcat getpropstr
  "" check if exit then
  curr @ 1 + curr !
  stored_num
;

: add_stored
  1 curr !
  stored_num
  you_prop @ "message-" curr @ intostr strcat page_format @ 0 addprop
;

: ask_read
  1 curr !
  "There are stored messages. Read? <y/n>" .tell
  read "n" check if exit else read_stored then
;

: set_store
  1 curr !
  args @ .trim_spaces
  "read" "haven" "asleep"
  3 .check+
  dup "read" check if
    read_stored
    curr @ 1 = if "No stored messages." .tell then
    exit
  then
  dup "haven" check if
    me_prop @ "_h-store" getpropstr "no" check if
      me_prop @ "_h-store" "yes" 0 addprop
      "Messages will be stored while Haven." .tell
    else
      me_prop @ "_h-store" "no" 0 addprop
      "Messages will not be stored while Haven." .tell
      stored_num curr @ 1 = not if ask_read then
    then
    exit
  then
  "asleep" check if
    me_prop @ "_a-store" getpropstr "no" check if
      me_prop @ "_a-store" "yes" 0 addprop
      "Messages will be stored while asleep." .tell
    else
      me_prop @ "_a-store" "no" 0 addprop
      "Messages will not be stored while asleep." .tell
      stored_num curr @ 1 = not if ask_read then
    then
    exit
  then
  me_prop @ "_store" getpropstr "no" check if
    me_prop @ "_store" "yes" 0 addprop
    "Storing incoming messages." .tell
  else
    me_prop @ "_store" "no" 0 addprop
    "Displaying incoming messages." .tell
    stored_num curr @ 1 = not if ask_read then
  then
;

: set_prefix
  me_prop @ "_prefix" getpropstr "yes" check if
    me_prop @ "_prefix" "no" 0 addprop
    "You are no longer in Prefix Mode." .tell
  else
    me_prop @ "_prefix" "yes" 0 addprop
    "You are now in Prefix Mode." .tell
  then
;

: set_robot
  me_prop @ "_robot" getpropstr "yes" check if
    me_prop @ "_robot" "no" 0 addprop
    "Incoming messages will not be reformatted." .tell
  else
    me_prop @ "_robot" "yes" 0 addprop
    "Incoming messages will be reformatted to defaults." .tell
  then
;

: set_haven
  args @ .trim_spaces
  "me" "here" 2 .check+
  dup "here" check if
    loc @ me_own? not if fail_priv exit then
    loc @ "h" flag? if
      loc @ "!h" set
      "This room is no longer set Haven." .tell
    else
      loc @ "h" set
      "This room is now set Haven." .tell
    then
  else
    me @ "h" flag? if
      me @ "!h" set
      "You are no longer set Haven." .tell
    else
      me @ "h" set
      "You are now set Haven." .tell
    then
  then
;

: fail_asleep
  you_prop @ "_asleep-format" getpropstr dup
  "" check if pop
    "%to is not connected." then
  pro_sub .tell
  counter-2 @ 1 + counter-2 !
;

: fail_haven
  you_prop @ "_haven-format" getpropstr dup
  "" check if pop
    "%to does not wish to be disturbed." then
  pro_sub .tell
  counter-2 @ 1 + counter-2 !
;

: page_player
  page_message @ temp-3 !
  player @ "me" check if
    me @ name player !
  then
  player @ "!" check if
    me_prop @ "_page-lastpaged" getpropstr
    dup "" check if fail_name exit then
    player !
  then
  player @ .pmatch+ player !
  player @ ok? not if fail_name exit then
  player @ player? not if fail_name exit then
  get_prop
  me_prop @ "_page-lastpaged" player @ name 0 addprop
  page_message @ "" check if
    summ_format
  else
    page_message @ ":" instr 1 = if
      emote_format
    else
      page_message @ ";" instr 1 = if
        pemit_format
      else
        get_format
      then
    then
  then
  page_format @ page_message !
  you_prop @ "_prefix" getpropstr "yes" check if
    message_prefix
  then
  player @ awake? not player @ haven? or if
    player @ awake? not if
      fail_asleep
      you_prop @ "_a-store" getpropstr "yes" check not if exit then
      counter-2 @ 1 - counter-2 !
    then
    player @ haven? player @ awake? and if
      fail_haven
      you_prop @ "_h-store" getpropstr "yes" check not if exit then
      counter-2 @ 1 - counter-2 !
    then
  else
    echo_format
  then
  you_prop @ "_store" getpropstr "yes" check
  you_prop @ "_a-store" getpropstr "yes" check player @ awake? not and or
  you_prop @ "_h-store" getpropstr "yes" check player @ haven? and or if
    store_format
    add_stored
  else
    player @ page_format @ notify
  then
;

: page_players
  counter @ 1 = if
    temp-2 @ " " instr strcut temp-2 !
  then
  temp-2 @ " " instr strcut player ! temp-2 !
  page_player
  temp-3 @ page_message !
  args @ counter @ = if exit then
  counter @ 1 + counter !
  page_players
;

: page_all_players
  name player !
  page_player
  temp-3 @ page_message !
  counter @ 1 + counter !
  counter @ temp-2 @ = if exit then
  page_all_players
;

: page_room_players
  temp-2 @ #-1 dbcmp if exit then
  temp-2 @ player? not if
    temp-2 @ next temp-2 !
    page_room_players
  then
  temp-2 @ #-1 dbcmp if exit then
  temp-2 @ name player !
  counter @ 1 + counter !
  page_player
  temp-3 @ page_message !
  temp-2 @ next temp-2 !
  page_room_players
;

: page_room
  room @ number? not if fail_room exit then
  room @ atoi dbref room !
  room @ ok? not if fail_room exit then
  room @ room? not if fail_room exit then
  0 counter !
  room @ contents
  dup #-1 dbcmp if
    0 counter !
  else
    temp-2 !
    page_room_players
  then
  counter @ dup intostr swap 1 = if " player " else " players " then
  strcat "in " strcat room @ .id strcat " paged, of which " strcat
  counter-2 @ intostr strcat " failed." strcat .tell
;

: helpscreen
  .cr
  helptitle
  .cr
  "Help topic: General" .tell
  .cr
  "The following commands are available:" .tell
  .cr
  "  " trigger @ .exit_name strcat
  dup " <players> = <msg>        page <players> with <msg>" strcat .tell
  dup " <players> = :<emote>     send <emote> to <players>" strcat .tell
  dup " <players> = ;<pemit>     send <pemit> to <players>" strcat .tell
  dup " <players>                send summons to <players>" strcat .tell
  dup "                          display last-paged player" strcat .tell
  dup " -prefix                  toggle Prefix Mode on/off" strcat .tell
  dup " -store [haven|asleep]    toggle message storing on/off" strcat .tell
  dup " -store read              display stored messages" strcat .tell
  dup " -haven [me|here]         toggle Haven on/off" strcat .tell
  dup " -robot                   toggle robot on/off" strcat .tell
  dup " -list                    display format settings" strcat .tell
  dup " -status                  display message receive status" strcat .tell
  dup " -change                  change property storage object" strcat .tell
  dup " -format [<format>]       change format" strcat .tell
  dup " -help [<topic>]          HELP!" strcat .tell
      " -help topics             display help topics" strcat .tell
  .cr
  "Arguments enclosed in <> are variables; those enclosed in [] are optional." .tell
  more? not if exit then
  show_prop
  .cr
  "Note that the variable <players> may be one or more players. If it is" .tell
  "omitted or equal to '!' the message is sent to the last player paged;" .tell
  me @ "w" flag? if
    "contrariwise, if replaced by '*' the message is sent to all connected" .tell
    "players (WIZ-only). <players> may also be replaced by room <#dbref>." .tell
  else
    "in addition, <players> may be replaced by room <#dbref>." .tell
  then
  .cr
  "PLEASE NOTE: This program is still under development." .tell
  "Any problems/comments/suggestions/etc should be mailed to Irvin'." .tell
;

: subs_help
  .cr
  helptitle
  .cr
  "Help topic: Substitutions" .tell
  .cr
  "IrvPage formats are used to personalize the messages displayed when you" .tell
  "perform certain actions, such as paging another player. In defining your" .tell
  "format strings, normal o-message substitutions are supported. For example," .tell
  "if Irvin' set his page format to be '%N whispers, \"%message\"', and then" .tell
  "paged 'oi!' to another player, the other player would see the message" .tell
  "'Irvin' whispers, \"oi!\"'." .tell
  "Listed below are all substitutions currently available for your use:" .tell
  .cr
  "  %a          absolute pronoun            his, hers, its" .tell
  "  %date       date string                 ex. 08/21" .tell
  "  %loc        location string             ex. Irvin's Office(#333RJ)" .tell
  "  %mess       short message string        ex. oi!" .tell
  "  %message    long message string         ex. Irvin' pages: oi!" .tell
  "  %n          sender name string          ex. Irvin'" .tell
  "  %o          objective pronoun           him, her, it" .tell
  "  %p          possessive pronoun          his, her, its" .tell
  "  %r          reflexive pronoun           himself, herself, itself" .tell
  "  %s          subjective pronoun          he, she, it" .tell
  more? not if exit then
  "  %time       time string                 ex. 22:21:03" .tell
  "  %to         receiver name string        ex. Shadow" .tell
  "  %toloc      receiver location string    ex. Underground Nexus(#493RJ)" .tell
  .cr
  "Related topics: formats" .tell
;

: help_formats
  .cr
  helptitle
  .cr
  "Help topic: Formats" .tell
  .cr
  "The following messages can be personalized:" .tell
  .cr
  "1. Page format -- The message a player sees when you page him/her. The" .tell
  "   default is: '<name> pages from <location>: <message>'" .tell
  "2. Emote format -- The message a player sees you send him/her an emote, or" .tell
  "   pose message. The default is: 'You sense that <name> <message>.'" .tell
  "3. Summons format -- The message a player sees when you send summons to him" .tell
  "   or her. The default is: 'You sense that <name> is looking for you in" .tell
  "   <location>.'" .tell
  "4. Echo format -- The message you see when you successfully page a player." .tell
  "   The default is: 'Message sent to <name>.'" .tell
  "5. Asleep format -- The message a player sees when he/she tries to page you" .tell
  "   at a time when you are not connected to the game. The default is: '<name>" .tell
  "   is not connected.' IrvPage uses the asleep format of the player being" .tell
  "   paged." .tell
  "6. Haven format -- The message a player sees when he/she attempts to page you" .tell
  "   while you are set Haven. The default is: '<name> does not wish to be" .tell
  "   disturbed.' IrvPage uses the haven format of the player being paged." .tell
  more? not if exit then
  "7. Store format -- The message a player sees when he/she pages you while you" .tell
  "   are in message saving mode. The default is: 'Message for <name> stored.'" .tell
  "   IrvPage uses the store format of the player being paged." .tell
  "8. Prefix format -- Incoming messages are formatted according to this string" .tell
  "   while in Prefix Mode. The default is: '<time>>> <message>'." .tell
  .cr
  "Related topics: page, prefix, store" .tell
;

: help_store
  .cr
  helptitle
  .cr
  "Help topic: Message Storing" .tell
  .cr
  "IrvPage allows you to store incoming messages instead of immediately reading" .tell
  "them. This function is available with the '-store' argument. For example," .tell
  "to store any messages you receive while set Haven, type '"
  trigger @ .exit_name strcat " -store haven'." strcat .tell
  "Likewise, typing '"
  trigger @ .exit_name strcat " -store asleep' stores messages you receive while" strcat .tell
  "not connected to the server. Simply using '-store' will store messages you" .tell
  "receive in normal situations (i.e. while connected and not Haven). To read" .tell
  "any previously stored messages, type '"
  trigger @ .exit_name strcat " -store read'. Note that," strcat .tell
  "while storing incoming messages, you are not informed when a message is" .tell
  "stored. The player paging you, however, is notified; this message is" .tell
  "configurable with the command '" trigger @ .exit_name strcat
  " -format store'." strcat .tell
  .cr
  "Related topics: page, formats" .tell
;

: help_robot
  .cr
  helptitle
  .cr
  "Help topic: Robot" .tell
  .cr
  "The robot option forces incoming messages to use the default format strings" .tell
  "as opposed to personalized message formats. For example, with robot turned" .tell
  "on all pages you receive, regardless of the sender's page format string," .tell
  "will be reformatted to conform to the default setting; therefore, all pages" .tell
  "will be displayed in the format: '<name> pages from <location>: <message>'." .tell
  "This applies to emote and summons messages, which will be reformatted to their" .tell
  "respective defaults as well." .tell
  .cr
  "Related topics: page, formats" .tell
;

: help_prefix
  .cr
  helptitle
  .cr
  "Help topic: Prefix Mode" .tell
  .cr
  "The Prefix Mode option formats all incoming messages according to your" .tell
  "prefix format string. This is configurable, but normally displays the time" .tell
  "at which the message was sent. For example, a player in Prefix Mode who" .tell
  "received a page from Irvin' would see '16:53:14>> Irvin' pages: oi!' if" .tell
  "the time was 4:53:14 pm. Comparatively, if the aforementioned player was" .tell
  "not in Prefix Mode, he/she would have simply seen 'Irvin' pages: oi!'. To" .tell
  "change your prefix format, simply type '"
  trigger @ .exit_name strcat " -format prefix'." strcat .tell
  .cr
  "Related topics: page, formats" .tell
;

: help_page
  .cr
  helptitle
  .cr
  "Help topic: Page" .tell
  .cr
  "You may send a message to another player by typing '"
  trigger @ .exit_name strcat " <playername>=" strcat .tell
  "<message>' where <playername> is the name of the person receiving the page," .tell
  "and <message> is the message that he/she will receive. Note that if" .tell
  "<playername> is omitted or replaced by the character '!', your message will" .tell
  "be sent to the last player whom you attempted to page. Typing '"
  trigger @ .exit_name strcat "'" strcat .tell
  "with no arguments displays the name of that player. Emotes, or poses," .tell
  "may also be sent by typing a ':' as the first character in the <message>" .tell
  "string. Your name will be attached automatically. Short messages may be" .tell
  "sent directly to another player by typing a ';' as the first character in" .tell
  "<message>. The player will receive that message exactly as you typed it" .tell
  "on your screen but with '>> ' added. Further, a message may be sent to" .tell
  "multiple players by entering their names, separated by spaces, as the" .tell
  "variable <playername>. If you wish to page all players in a certain room," .tell
  "type the room number in replace of <playername>. If <message> is omitted," .tell
  "your summons are sent to <playername>." .tell
  .cr
  "Related topics: formats, prefix, store, robot" .tell
;

: help
  args @ "" check if helpscreen exit then
  args @ "t" instr 1 = if
    "Help topics available:" .tell
    "general, page, prefix, store, robot, formats, substitutions" .tell
    "Enter topic name or 'exit' to abort:" .tell
    read .trim_spaces args !
  then
  args @
  "exit" "general" "formats" "prefix" "store" "robot" "page" "substitutions"
  8 .check+ args !
  args @ "exit" check if me @ "Exiting." notify exit then
  args @ "general" check if helpscreen exit then
  args @ "formats" check if help_formats exit then
  args @ "prefix" check if help_prefix exit then
  args @ "store" check if help_store exit then
  args @ "page" check if help_page exit then
  args @ "robot" check if help_robot exit then
  args @ "substitutions" check if subs_help exit then
  "Unknown topic name." .tell
;

: set_xformat
  "X" args-2 !
  0 counter-2 !
  "Your " xformat @ strcat " format is currently:" strcat .tell
  xformat @ "page" check if get_format page_format @ .tell then
  xformat @ "emote" check if emote_format page_format @ .tell then
  xformat @ "summons" check if summ_format page_format @ .tell then
  xformat @ "echo" check if echo_format then
  xformat @ "asleep" check if fail_asleep then
  xformat @ "haven" check if fail_haven then
  xformat @ "prefix" check if message_prefix page_format @ .tell then
  xformat @ "store" check if store_format then
  "Enter new format or type 'help' for o-message help; 'exit' to abort:" .tell
  read curr !
  curr @ "help" check if subs_help set_xformat exit then
  curr @ "exit" check if "Format unchanged." .tell exit then
  me_prop @ "_" xformat @ strcat "-format" strcat curr @ 0 addprop
  "Format changed." .tell
;

: set_format
  .cr
  ">> IrvPage Version 2.5.0 by Irvin': Configure Format <<" .tell
  .cr
  args @ xformat !
  xformat @ "" check if
    "Configurable formats:" .tell
    "page, emote, summons, echo, asleep, haven, store, prefix" .tell
    "Enter format name or 'help' for format help; 'exit' to abort:" .tell
    read .trim_spaces xformat !
  then
  xformat @
  "page" "emote" "summons" "echo" "asleep" "haven" "store" "prefix" "help" "exit"
  10 .check+ xformat !
  xformat @ "" check if "Unknown format name." .tell exit then
  xformat @ "help" check if help_formats "" args ! set_format exit then
  xformat @ "exit" check if "Exiting." .tell exit then
  set_xformat
;

: lastpaged
  me_prop @ "_page-lastpaged" getpropstr
  dup "" check if "nobody" then
  "Last player paged: " swap strcat .tell
;

: status
  .cr
  ">> IrvPage Version 2.5.0 by Irvin': Message Receive Status <<" .tell
  .cr
  me @ "h" flag? if
    "* You are set Haven." .tell
  else
    "* You are not set Haven." .tell
  then
  loc @ "h" flag? if
    "* Your current location is set Haven." .tell
  else
    "* Your current location is not set Haven." .tell
  then
  me @ haven? if
    "Players paging you will see the message:" .tell
    fail_haven
  then
  .cr
  me_prop @ "_prefix" getpropstr "yes" check if
    "* You are in Prefix Mode." .tell
    "All messages sent to you will be formatted according to:" .tell
    message_prefix page_format @ .tell
  else
    "* You are not in Prefix Mode." .tell
  then
  .cr
  me_prop @ "_robot" getpropstr "yes" check if
    "* Robot turned on." .tell
    "Incoming messages will be reformatted to defaults." .tell
  else
    "* Robot turned off." .tell
    "Incoming messages will not be reformatted." .tell
  then
  .cr
  me_prop @ "_store" getpropstr "yes" check
  me_prop @ "_a-store" getpropstr "yes" check or
  me_prop @ "_h-store" getpropstr "yes" check or if
    me_prop @ "_store" getpropstr "yes" check if
      "* Storing incoming messages." .tell
    then
    me_prop @ "_a-store" getpropstr "yes" check if
      "* Storing messages while asleep." .tell
    then
    me_prop @ "_h-store" getpropstr "yes" check if
      "* Storing messages while Haven." .tell
    then
  then
  me_prop @ haven? me_prop @ "_h-store" getpropstr "yes" check and
  me_prop @ "_store" getpropstr "yes" check or if
    "Players paging you will see the message:" .tell
    store_format
  else
    "Displaying incoming messages." .tell
  then
;

: settings
  .cr
  ">> IrvPage Version 2.5.0 by Irvin': Format Settings <<" .tell
  .cr
  "Page format:" .tell
  get_format page_format @ .tell
  .cr
  "Emote (pose) format:" .tell
  emote_format page_format @ .tell
  .cr
  "Summons format:" .tell
  summ_format page_format @ .tell
  .cr
  "Echo format:" .tell
  echo_format
  .cr
  "Asleep format:" .tell
  fail_asleep
  .cr
  "Haven format:" .tell
  fail_haven
  .cr
  "Store format:" .tell
  store_format
  .cr
  "Message prefix:" .tell
  message_prefix page_format @ .tell
  .cr
  show_prop
;

: IrvPage_Version_2.5.0
  args !
  args @ .trim_spaces args !
  setup
  get_prop
  args @ "-" instr 1 = if
    args @ .trim_spaces dup " " instr
    dup 0 > if strcut .trim_spaces args ! else "" args ! pop then
    .trim_spaces
    "-help" "-prefix" "-haven" "-list" "-format" "-status" "-store" "-robot" "-change"
    9 .check+
    dup "-help" check if help exit then
    dup "-prefix" check if set_prefix exit then
    dup "-haven" check if set_haven exit then
    dup "-list" check if settings exit then
    dup "-format" check if set_format exit then
    dup "-status" check if status exit then
    dup "-robot" check if set_robot exit then
    dup "-change" check if set_prop exit then
    "-store" check if set_store exit then
    helpscreen
    exit
  then
  "" args-2 !
  args @ "=" instr not if
    args @ .trim_spaces player !
    "" page_message !
  else
    args @ "=" instr 1 = if
      args @ 1 strcut .trim_spaces page_message !
      "!" player !
    else
      args @ dup "=" instr strcut swap
      dup strlen 1 - strcut pop
      .trim_spaces player !
      .trim_spaces page_message !
    then
  then
  player @ "#" instr 1 = player @ "here" instr 1 = or if
    player @ "#" instr 1 = if
      player @ 1 strcut .trim_spaces room !
    else
      me @ location int intostr room !
    then
    page_room
    exit
  then
  player @ "" check if
    lastpaged
    exit
  then
  player @ "*" check if
    me @ "w" flag? not me @ "page-all" getpropstr "yes" stringcmp and if
      fail_priv
      exit
    then
    0 counter !
    online temp-2 !
    page_all_players
    temp-2 @ dup intostr swap 1 = if " player " else " players " then
    strcat "paged, of which " strcat
    counter-2 @ intostr strcat " failed." strcat .tell
    exit
  then
  player @ " " instr if
    player @ temp-2 !
    player @ " " explode args !
    1 counter !
    page_players
    args @ dup intostr swap 1 = if " player " else " players " then
    strcat "paged, of which " strcat
    counter-2 @ intostr strcat " failed." strcat .tell
    exit
  then
  page_player
;