====== External Programs Section ======
The ''Xtrn Section'' module provides the "External Programs" (doors) menu for the [[:server:Terminal]] server users, and defaults to ''xtrn_sec.js''. 

The ''Pre Xtrn Prog'' module executes common functionality before any external program is launched. This includes things like setting fonts, displaying ANSI screens, clearing screen, and performing the eval_before_exec option. The module defaults to ''prextrn.js''.

The ''Post Xtrn Prog'' module is like the pre module, except it executes after an external program door is run. It performs the eval_after_exec option and defaults to ''postxtrn.js''

===== Install =====
This module (''xtrn_sec'') should be the default value of SCFG->System->Loadable Modules->Xtrn Section.

===== Invoke  =====

The normally expected usage is just to invoke ''xtrn_sec.js'' with no arguments. If, however, you wish to have the module skip the menu of external program sections and go directly to the menu of available programs within one specific section, pass the internal-code of the desired program section section as an argument to ''xtrn_sec.js''.


==== Baja ====
<code Baja>
exec_bin xtrn_sec games
</code>

However, when installed correctly, this module should run whenever the Baja ''XTRN_SECTION'' function is invoked.


==== JavaScript ====
<code JavaScript>
load('xtrn_sec.js', 'games');
</code>

However, when installed correctly, this module should run whenever the JS ''bbs.xtrn_sec()'' method is invoked.

===== Configure ===== 

The ''xtrn_sec'' module supports the following configuration options in the ''[xtrn_sec]'' section of the ''[[dir:ctrl]]/[[config:modopts.ini]]'' file:

^ Option                 ^ Default ^ Description ^
| center                 | false   | Center single-column program list in the user's terminal screen |
| multicolumn            | true    | Use a multiple-column program list when there are more than ''singlecolumn_height'' items. This will automatically set to false if screen_columns < 80 |
| multicolumn_separator  | " "    | Separator displayed between columns of program names |
| multicolumn_fmt        | text[XtrnProgLstFmt]  | Display format used for multiple program columns |
| multicolumn_section_fmt | "\x01g\x01h%3d: \x01n\x01g%-32.32s " | Display format used for multiple program //section// columns ||
| singlecolumn_fmt       | "\x01h\x01c%3u \xb3 \x01n\x01c%s\x01h "          | Display format used for single column |
| singlecolumn_margin    | 7      | Desired button margin (below program list), in rows |
| singlecolumn_height    | screen_rows - singlecolumn_margin  | The maximum length of a single column list |
| align_prog_list        | false   | Use with ''multi/singlecolumn_fmt'' strings which don't contain padded integer specifiers |
| header_fmt             | text[XtrnProgLstHdr]  | Program list header format |
| titles                 | text[XtrnProgLstTitles]  | Program list titles |
| underline              | text[XtrnProgLstUnderline]  | Underline string under the titles |
| section_header_fmt     | text[SelectItemHdr] | Header format for main section listing |
| section_fmt            | text[SelectItemFmt] | Display format used for section entries in main section listing |
| section_which          | text[SelectItemWhich] | Which prompt for main section listing |
| section_header_title   | External Program Selection | Main section listing header text |
| align_section_list     | false  | Use with ''section_fmt'' string that doesn't contain padded integer specifiers |
| which                  | text[WhichXtrnProg]  | Which prompt |
| sort                   | false  | Re-sort (alphabetically) the list of programs and program sections before displaying to the user |
| autoexec               | false  | Automatically execute a section's program when there is only one program available within that section |
| clear_screen           | true   | Clear the screen before each program list/menu |
| clear_screen_on_exec   | false  | Clear the screen before executing any/all programs |
| eval_before_exec       |        | Evaluate the specified JavaScript expression //before// executing any/all programs |
| eval_after_exec        |        | Evaluate the specified JavaScript expression //after// executing any/all programs |
| restricted_user_msg    | text[R_ExternalPrograms]  | Message displayed users with X-[[access:restrictions]] |
| no_programs_msg        | text[NoXtrnPrograms]      | Message displayed when there are no external programs available |
| prompt_on_info         | false  | Display a yes/no prompt after displaying external program intro file |
| prompt_on_info_fmt     | "\r\n\x01n\x01cDo you wish to continue" | Formatting for prompt_on_info yes/no prompt |


For all options that contain formatting, have the INI entry with a colon such as "name: value". For true/false, you can use the "=" format such as "name=value". 

Formatting options can contain escaped hexadecimal: "\x01" is Ctrl-A.
===== Customize =====

==== Display Files ====

  * The auto-generated external program section list can be replaced by creating the optional file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn_sec.*''.
  * The external program section list can have an optional header displayed by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn_sec_head.*''.
  * The external program section list can have an optional footer displayed by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn_sec_tail.*''.
  * Each program list can have an optional header displayed by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn<sec_num>_head.*'' or ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn<sec_code>_head.*''.
  * You can create a global header across all menus by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn_head.*''
  * Each auto-generated program list can be replaced by creating the optional file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn<sec_num>.*'' or ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn<sec_code>.*''.
  * Each program list can have an optional tail section displayed by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn<sec_num>_tail.*'' or ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn<sec_code>_tail.*''.
  * You can create a global tail across all menus by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn_tail.*''
  * Each external program can have an optional file displayed before execution by creating the file ''[[dir:text]]/[[custom:menu_files|menu]]/xtrn/<code>.*''

==== Fonts ====

This module uses the ''[[custom:javascript:lib:fonts.js]] library'' and ''[[dir:ctrl]]/[[config:fonts.ini]]'' file to optionally load door-specific fonts before executing an external program and restore the default font upon returning from the external program.

<code ini>
; Door Sections
; -------------
; Each BBS external online program (e.g. door game) may have its own desired
; fonts and some programs may even have customized fonts made just for that
; game (e.g. LORE).
; 
; These sections are named with the form: '[xtrn:<code>:<char>]
; where <code> is the external program's Internal Code (as configured in SCFG)
; and <char> is the relevant character height.
;
; Note: you must utilize xtrn_sec.js rev 1.18 or later, or the Pre Xtrn Module for this feature:

[xtrn:lore:16]
normal=lore
high=lore
blink=lore
highblink=lore

[xtrn:lord32:16]
normal=lore

[xtrn:lord32:14]
normal=oldenglish
</code>

===== See Also =====
  * [[:module:|Modules]]
  * [[config:modopts.ini|Module Options]]

{{tag>doors fonts javascript}}
