# Resource Variables

- Overview
- Resource Variable Syntax
- Resource Variable Index
  - Variables

## Overview

Resource variables are used to represent dynamic data in MHonArc resources. Take the following LITEMPLATE resource setting for example:

    <LiTemplate>
    <li><strong>$SUBJECT$</strong>
    <ul><li><em>From</em>: $FROM$</li></ul>
    </li>
    </LiTemplate>

The LITEMPLATE resource defines how each message listing is displayed in the main index page. The `$SUBJECT$` and `$FROM$` are resource variables. `$SUBJECT$` will get expanded to the current message's subject, hyperlinked to the message page. `$FROM$` will be replaced with the message's author's name and address.

Some resource variables take arguments. Take the following NEXTLINK resource setting for example:

    <li>Next by Date:
    <strong><a href="$MSG(NEXT)$">$SUBJECT(NEXT)$</a></strong>
    </li>

The resource setting uses two resource variables: `$MSG$` and `$SUBJECT$`. However, an argument is given to each resource variable delimited by `( )`. `$SUBJECT$` will get expanded to the current message's subject[*]. With the "`NEXT`" argument, we are instructing MHonArc to use the next message's subject. `$MSG(NEXT)$` will get expanded to the next message's filename. Therefore, the above resource value is creating a link to the next message in the archive.

* NOTE:

In the two examples given, the replacement value of `$SUBJECT$` is different (excluding the variable argument difference). For compatibility of older versions of MHonArc, when `$SUBJECT$` is used without any arguments, it will be expanded to the current message's subject hyperlinked to the current message page. If an argument is given to `$SUBJECT$`, then the variable will get expanded only to the subject text of the applicable message. NO hyperlink is automatically created.

## Resource Variable Syntax

The syntax of resource variables in resources is as follows:

    $VARIABLE[[:[N][J][M][U]][(arglist)]]$
    	  ^----------^^---------^
             ^-----------------------^

The items in `[]`'s are optional. The "`^---^`" are used to highlight the nested optional groupings.

Definition of each part:

`$`

  The start of a resource variable. Everything (including line breaks) up to the next `$` is part of the resource variable.

`VARIABLE`

  The name of the variable. Variable names are case-sensitive.

`:[N][J][U][M]` (optional)

  The optional grouping starting with a colon are variable modifiers. The definition of each modifier is as follows:

  `N`

  Length specification. MHonArc will clip the expanded text to N if the text length is greater than N.

  NOTE: | Not all resource variables support clipping. If a length specification is given for these variables, then it will be ignored.

  How MHonArc clips text is determined by the TEXTCLIPFUNC resource.

  `J` | Treat the text as a JavaScript string. MHonArc will escape any quote characters so the text can be part of a JavaScript string.
  `M` | Enable mailto linking on expanded string. This modifier is only applicable for the following resource variables: `$MSGHFIELD$`, `$SUBJECT$`, `$SUBJECTNA$`.
  `U` | Treat the text as part of a URL string. MHonArc will escape any characters that are considered special in a URL.

`(arglist)` (optional)
  An optional argument list delimited by parentheses: `( )`. Some resource variables can take arguments which modify how the variable is expanded. If a variable can take more than one argument, each argument will be separated by a semi-colon. For example: `$MSGLOCALDATE(NEXT;%H:%M)$`. In the example, there are two arguments to the `$MSGLOCALDATE$` variable: "`NEXT`" and "`%H:%M`".
`$`

  The end of a resource variable.

If an unrecognized variable is encountered, it gets replaced with an empty string, and a warning is generated. If a literal "`$`" is needed, use "`$$`".

NOTE:

The MAILTOURL and NEWSURL resources have different rules for variable expansion:

- If a variable does not exactly match the set of variables available for each resource, the variable text will be taken literally as part of the element content. Therefore, a single "`$`" can be used to represent a "`$`" character.

- Variables should NOT have "`:NJMU`" modifiers. This will prevent the variables from being recognized. MHonArc automatically treats the replacement value as a part of a URL string, so the "`:U`" modifier is not needed.

## Resource Variable Index

This sections lists all the resource variables supported by MHonArc. Since many resource variables can take arguments, the following notations are used to represent argument values:

`mesg_spec`

  A message specification determines which message the variable's expanded value will be based upon. Possible values are:

  Value - | Meaning
  --- | ---
  `CUR` - | Current message.
  `FIRST` - | First message listed in main index.
  `LAST` - | Last message listed in main index.
  `NEXT` - | Next message by main sort order.
  `PREV` - | Previous message by main sort order.
  `TEND` - | Last message of current discussion thread.
  `TFIRST` - | First message listed in thread index.
  `TLAST` - | Last message listed in thread index.
  `TNEXT` - | Next message by thread.
  `TNEXTIN` - | Next message within current thread. This differs from `TNEXT` in that it does not cross discussion thread boundaries.
  `TNEXTTOP` - | First message of next discussion thread.
  `TPARENT` - | Parent message of current thread.
  `TPREV` - | Previous message by thread.
  `TPREVIN` - | Previous message within current thread. This differs from `TPREV` in that it does not cross discussion thread boundaries.
  `TPREVTOP` - | First message of previous discussion thread.
  `TTOP` - | Top/root message of current discussion thread.

  "`CUR`" is the default if nothing is specified for `mesg_spec`.

`idx_page_spec`

  An index page specification denoting the index page to use when determing the value of the variable. The possible values are:

  Value | - Meaning
  --- | ---
  `FIRST` | - First page of main index.
  `LAST` | - Last page of main index.
  `NEXT` | - Next page of main index.
  `PREV` | - Previous page of main index.
  `TFIRST` | - First page of thread index.
  `TLAST` | - Last page of thread index.
  `TNEXT` | - Next page of thread index.
  `TPREV` | - Previous page of thread index.

  If no value is given for `idx_page_spec`, the resource variable's value is undefined.

`time_fmt_str`

  A time format string specifies how a date/time will be printed for a date/time related variable. The syntax of the format string is the same as the conversion specification as defined in the GMTDATEFMT and LOCALDATEFMT resources.

### Variables

`$A_ATTR$`

  Arguments: | N/A
  Description: | The `NAME` and `HREF` attributes to use in an anchor to link to the archived message. The `NAME` attribute provides a destination location when a message links to the index page. This resource variable is equivalent to "`$A_NAME$ $A_HREF$`".

`$A_HREF$`

  Arguments: | N/A
  Description: | The `HREF` attribute to use in an anchor to link to the archived message. This variable is equivalent to "`href="$MSG$"`".

`$A_NAME$`

  Arguments: | N/A
  Description: | The `NAME` attribute to use in an anchor for messages to link to the index page. This variable is equivalent to "`name="$MSGNUM$"`".

`$ATTACHMENTURL$`

  Arguments: | N/A
  Description: | The value of the ATTACHMENTURL resource.

`$BUTTON$`

  Arguments: | `mesg_spec`

  Description:

  Button markup linking to a message. The value of `$BUTTON$` is determined by the following resources based on `mesg_spec` value: NEXTBUTTON, NEXTBUTTONIA, PREVBUTTON, PREVBUTTONIA, TENDBUTTON, TENDBUTTONIA, TNEXTBUTTON, TNEXTBUTTONIA, TNEXTINBUTTON, TNEXTINBUTTONIA, TNEXTTOPBUTTON, TNEXTTOPBUTTONIA, TPREVBUTTON, TPREVBUTTONIA, TPREVINBUTTON, TPREVINBUTTONIA, TPREVTOPBUTTON, TPREVTOPBUTTONIA, TTOPBUTTON, TTOPBUTTONIA.

`$DATE$`

  Arguments: | `mesg_spec`
  Description: | The (raw) date of the message. This variable will expanded to the date string used within the message itself. If you want to customize the formatting of the date, use `$MSGLOCALDATE$` or `$MSGGMTDATE$` instead.

`$DDMMYYYY$`

  Arguments: | `mesg_spec`
  Description: | Message date (according to local time) in dd/mm/yyyy format.

`$DOCURL$`

  Arguments: | N/A
  Description: | URL to MHonArc documentation. Value of variable set by the DOCURL resource.

`$ENV$`

  Arguments: | `variable_name`
  Description: | The value of the environment variable specified by variable_name. For example, `$ENV(HOME)$` would expand to the value of the HOME environment variable.

`$FROM$`

  Arguments: | `mesg_spec`
  Description: | The complete text in the `From:` field of the message.

`$FROMADDR$`

  Arguments: | `mesg_spec`
  Description: | The full mail address in the `From:` field of the message.

`$FROMADDRNAME$`

  Arguments: | `mesg_spec`
  Description: | The username/local-part of the mail address in the `From:` field of the message. For example, given the address "someuser@example.com", `$FROMADDRNAME$` would equal "someuser".

`$FROMADDRDOMAIN$`

  Arguments: | `mesg_spec`
  Description: | The domain part of the mail address in the `From:` field of the message. For example, given the address "someuser@mhonarc.org", `$FROMADDRDOMAIN$` would equal "mhonarc.org".

`$FROMNAME$`

  Arguments: | `mesg_spec`
  Description: | The human name of the person in the `From:` field of the message. If no human name is found, the local-part specified in the mail address is used.

`$GMTDATE$`

  Arguments: | `time_fmt_str`
  Description: | Current system GMT date. If no time_fmt_str argument is provided, the format specifed by the GMTDATEFMT resource is used.

`$ICON$`

  Arguments: | `mesg_spec`
  Description: | The content-type sensistive icon. The type of icon displayed is determined by the ICONS resource.

`$ICONURL$`

  Arguments: | `mesg_spec`
  Description: | The URL to the content-type sensistive icon. The URL value is determined by the ICONS and ICONURLPREFIX resources.

`$ICONURLPREFIX$`

  Arguments: | N/A
  Description: | Value of the ICONURLPREFIX resource.

`$IDXFNAME$`

  Arguments: | N/A
  Description: | Filename of main index page. The value is set by the IDXFNAME or IDXPREFIX and HTMLEXT resources. If the first page, IDXFNAME is used. For other pages, the filename is IDXPREFIXpage-number`.`HTMLEXT.

`$IDXLABEL$`

  Arguments: | N/A
  Description: | Label for main index page. Value set by the IDXLABEL resource.

`$IDXPREFIX$`

  Arguments: | N/A
  Description: | Prefix of filenames of main index pages. Value set by the IDXPREFIX resource.

`$IDXSIZE$`

  Arguments: | N/A
  Description: | Max number of messages that may be listed in index page. Value set by the IDXSIZE resource.

`$IDXTITLE$`

  Arguments: | N/A
  Description: | The title of the main index page. Value set by the TITLE resource.

`$LINK$`

  Arguments: | `mesg_spec`
  Description: | Link markup linking to a message. The value of `$LINK$` is determined by the following resources based on `mesg_spec` value: NEXTLINK, NEXTLINKIA, PREVLINK, PREVLINKIA, TENDLINK, TENDLINKIA, TNEXTLINK, TNEXTLINKIA, TNEXTINLINK, TNEXTINLINKIA, TNEXTTOPLINK, TNEXTTOPLINKIA, TPREVLINK, TPREVLINKIA, TPREVINLINK, TPREVINLINKIA, TPREVTOPLINK, TPREVTOPLINKIA, TTOPLINK, TTOPLINKIA.

`$LOCALDATE$`

  Arguments: | `time_fmt_str`
  Description: | Current system local date. If no time_fmt_str argument is provided, the format specifed by the LOCALDATEFMT resource is used.

`$MMDDYYYY$`

  Arguments: | `mesg_spec`
  Description: | Message (local) date in mm/dd/yyyy format.

`$MSG$`

  Arguments: | `mesg_spec`
  Description: | Filename of message. Filename of the message is determined by the following resources: HTMLEXT, MSGPREFIX.

`$MSGGMTDATE$`

  Arguments: | `mesg_spec` `mesg_spec;time_fmt_str`
  Description: | GMT date of message. If no time_fmt_str argument is provided, the format specifed by the GMTDATEFMT resource is used.

`$MSGHFIELD$`

  Arguments: | `mesg_spec;field-name`
  Description: | Message header field value as stored by the FIELDSTORE resource. field-name denotes the name of the field value. The following resources are applied to the expanded string: ADDRESSMODIFYCODE, MAILTOURL (if the "`:M`" modifier is specified), and SPAMMODE apply.

`$MSGID$`

  Arguments: | `mesg_spec`
  Description: | The message-id of the message.

`$MSGLOCALDATE$`

  Arguments: | `mesg_spec` `mesg_spec;time_fmt_str`
  Description: | Local date of message. If no time_fmt_str argument is provided, the format specifed by the LOCALDATEFMT resource is used.

`$MSGNUM$`

  Arguments: | `mesg_spec`
  Description: | The message number assigned to the message by MHonArc. The number is at least 5 digits wide, padded with leading zeros if actual number is less than 5 digits. For example, message 45 would be `00045`.

`$MSGPREFIX$`

  Arguments: | N/A
  Description: | Filename prefix for message files. Value set by the MSGPREFIX resource.

`$MSGTORDNUM$`

  Arguments: | `mesg_spec`

  Description:

  The ordinal message number of the current discussion thread. Numbering starts with the first top/root message of a thread and ends with the last message of the thread, spanning in sub-threads. The following illustrates how the numbering works:

        1. top/root message
          2. first follow-up to 1
            3. first follow-up to 2
            4. second follow-up to 2
          5. second follow-up to 1
            6. first follow-up to 5
              7. first follow-up to 6
          8. third follow-up to 1

  The above contains 8 total message in the discussion thread, so numbering goes from 1 to 8.

`$NEWSGROUP$`

  Arguments: | N/A
  Description: | Newsgroup name. This variable is only applicable for use in NEWSURL.

`$NOTE$`

  Arguments: | `mesg_spec`
  Description: | Message annotation. If annotation text exists for the message, the NOTE resource determines the value of $NOTE$. When no annotation text is defined, NOTEIA is used.

`$NOTETEXT$`

  Arguments: | `mesg_spec`
  Description: | Base text of message annotation. Variable should be used only within the NOTE resource.

`$NUMFOLUP$`

  Arguments: | `mesg_spec`
  Description: | Number of explicit follow-ups to the message. This number does NOT include subject-based follow-ups.

`$NUMOFIDXMSG$`

  Arguments: | N/A
  Description: | Number of message listed on the current index page.

`$NUMOFMSG$`

  Arguments: | N/A
  Description: | Total number of messages in the archive.

`$NUMOFPAGES$`

  Arguments: | N/A
  Description: | Total number of index pages for a given index type.

`$ORDNUM$`

  Arguments: | `mesg_spec`
  Description: | The current listing number of the message. Number starts at 1.

`$OUTDIR$`

  Arguments: | N/A
  Description: | Pathname of archive. Value set by the OUTDIR resource.

`$PAGENUM$`

  Arguments: | N/A
  Description: | Current index page number.

`$PG$`

  Arguments: | `idx_page_spec`
  Description: | Filename of an index page. Value determined by the HTMLEXT, IDXFNAME, IDXPREFIX, TIDXFNAME, and TIDXPREFIX resources. Which resources are in effect depends on the current context.

`$PGLINK$`

  Arguments: | `idx_page_spec`
  Description: | Markup linking to a main index page. Value determined by the FIRSTPGLINK, LASTPGLINK, NEXTPGLINK, NEXTPGLINKIA, PREVPGLINK, PREVPGLINKIA, TFIRSTPGLINK, TLASTPGLINK, TNEXTPGLINK, TNEXTPGLINKIA, TPREVPGLINK, and TPREVPGLINKIA, resources. The resource used depends on idx_page_spec and context.

`$PGLINKLIST$`

  Arguments: | `num;num`

  Description:

  Markup linking to a list of index pages. `$PGLINKLIST$` takes two arguments: the first is the number of pages before the current page to create links to; the second is the number of pages after the current page to create links to. If either number argument is prefixed with a '`T`', then the list of links apply to the thread index. Examples: `$PGLINKLIST(3;3)$`, `$PGLINKLIST(T2;T3)$`. The link text for a given page is the page number, with the current page not linked. For example, if the current index page is 5, `$PGLINKLIST$` would expand to something like the following:

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

  If no arguments are provided to `$PGLINKLIST$`, then the links to all index pages will be printed. To get the entire list for a thread index, use `$PGLINKLIST(T)$`.

`$PROG$`

  Arguments: | N/A
  Description: | Program name. Generally, it will be "`mhonarc`", but it can vary if MHonArc is called via a custom front-end or installed under a different name.

`$SUBJECT$`

  Arguments: | `mesg_spec`
  Description: | The subject text of the message, and if no arguments, wrapped in an anchor element that hyperlinks to the message. This behavior exists for backwards capatibility to provide a simple way to link to the current message using the subject as the link text. The no argument version is equivalent to: "`<a $A_ATTR$>$SUBJECTNA$</a>`".

`$SUBJECTNA$`

  Arguments: | `mesg_spec`
  Description: | The subject text of the message without the anchor element.

`$TIDXFNAME$`

  Arguments: | N/A
  Description: | Filename of thread index page. The value is set by the TIDXFNAME or TIDXPREFIX and HTMLEXT resources. If the first page, TIDXFNAME is used. For other pages, the filename is TIDXPREFIXpage-number`.`HTMLEXT.

`$TIDXLABEL$`

  Arguments: | N/A
  Description: | Label for thread index page. Value set by the TIDXLABEL resource.

`$TIDXPREFIX$`

  Arguments: | N/A
  Description: | Prefix of filenames of thread index pages. Value set by the TIDXPREFIX resource.

`$TIDXTITLE$`

  Arguments: | N/A
  Description: | The title of the thread index page. Value set by the TTITLE resource.

`$TLEVEL$`

  Arguments: | `mesg_spec`
  Description: | Numeric level of message in current thread, starting with zero.

`$TO$`

  Arguments: | N/A
  Description: | The mail address. This variable is only applicable for use in the MAILTOURL.

`$TOADDRNAME$`

  Arguments: | N/A
  Description: | The username/local-part of the e-mail address. For example, given the address "someuser@example.com", `$TOADDRNAME$` would equal "someuser". This variable is only applicable for use in the MAILTOURL.

`$TOADDRDOMAIN$`

  Arguments: | N/A
  Description: | The domain part of the e-mail address. For example, given the address "someuser@example.com", `$TOADDRDOMAIN$` would equal "example.com". This variable is only applicable for use in the MAILTOURL.

`$TSLICE$`

  Arguments: | `number;number;flag`

  Description:

  A slice of the thread listing relative to the current message. Size of slice is determined by the TSLICE resource, or explicitly by the arguments provided. The first argument is the number of maximum messages to list before the current message. The second argument is the number of maximum message messages to list after the current message. The third argument is a flag, `0` or `1`, denoting if slice should cross discussion thread boundaries or not. If any of the arguments are blank, the value defined in the TSLICE resource will be used.

  Layout appearance of `$TSLICE$` is determined by TSLICEBEG, TSLICECONTBEG, TSLICECONTEND, TSLICEEND, TSLICEINDENTBEG, TSLICEINDENTEND, TSLICELIEND, TSLICELIENDCUR, TSLICELINONE, TSLICELINONEEND, TSLICELITXT, TSLICELITXTCUR, TSLICESINGLETXT, TSLICESINGLETXTCUR, TSLICESUBJECTBEG, TSLICESUBJECTEND, TSLICESUBLISTBEG, TSLICESUBLISTEND, TSLICETOPBEG, TSLICETOPBEGCUR, TSLICETOPEND, and TSLICETOPENDCUR resources.

`$VERSION$`

  Arguments: | N/A
  Description: | Program version.

`$YYYYMMDD$`

  Arguments: | N/A
  Description: | Message (local) date in yyyy/mm/dd format.