Annotation of freem/doc/freem.texi, revision 1.27

1.1       snw         1: \input texinfo
                      2: @paragraphindent 0
                      3: @setfilename freem.info
                      4: @settitle The FreeM Manual
                      5: 
                      6: @copying
1.21      snw         7: This manual is for FreeM, (version 0.64.0-rc0), which is a free and open-source implementation of the M programming language.
1.1       snw         8: 
                      9: 
1.5       snw        10: Copyright @copyright{} 2014-2025 Coherent Logic Development LLC
1.1       snw        11: 
                     12: @quotation
                     13: Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover texts, and with no Back-Cover Texts.
                     14: @end quotation
                     15: @end copying
                     16: 
                     17: @titlepage
                     18: 
                     19: @title The FreeM Manual
                     20: @subtitle @sc{The Official Manual of FreeM}
1.21      snw        21: @subtitle Version 0.64.0-rc0
1.1       snw        22: @c@vskip 10pt
                     23: @c@center @image{freem-logo-sm,,,,.png}
                     24: @author Serena Willis
                     25: @page
                     26: @vskip 0pt plus 1filll
                     27: @insertcopying
                     28: @end titlepage
                     29: @contents
                     30: 
                     31: @ifnottex
                     32: @node Top
                     33: @top The FreeM Manual
                     34: 
                     35: This is the official manual for the FreeM programming language.
                     36: @end ifnottex
                     37: 
                     38: @dircategory The FreeM Manual
                     39: @direntry
                     40: * FreeM: (freem).                       The FreeM M programming language.
                     41: @end direntry
                     42: 
                     43: @menu
                     44: * Introduction::                        About the FreeM Project, its history, and its goals.
                     45: * FreeM Invocation::                    How to invoke FreeM from the command line.
1.22      snw        46: * The FreeM Environment Daemon::        Managing shared resources in the FreeM environment.
1.1       snw        47: * The FreeM Direct-Mode Environment::   Executing M programs interactively.
                     48: 
                     49: * Directives::                          Per-Routine Language Directives.
                     50: * Intrinsic Special Variables::         Intrinsic Special Variables.
                     51: * Intrinsic Functions::                 Intrinsic Functions.
                     52: * OBJECT Methods::                      Methods for OBJECT variables.
                     53: * STRING Methods::                      Methods for STRING variables.
                     54: * Commands::                            Commands.
                     55: * Structured System Variables::         Structured System Variables.
                     56: * Operators::                           FreeM Operators.
                     57: 
                     58: * Routines::                            The units of M code in FreeM.
                     59: * Types::                               FreeM data types.
                     60: * Globals::                             FreeM persistent sparse arrays.
                     61: * Concurrency Control::                 @code{LOCK}ing and transaction processing.
                     62: * Local Variables::                     In-memory variables.
                     63: * Scoping::                             Scoping in FreeM.
                     64: * Decision Constructs::                 @code{IF}, @code{THEN}, @code{ELSE}, @code{$SELECT}, and postconditionals.
                     65: * Branch Constructs::                   Labels, @code{GOTO}, @code{DO}, and @code{JOB}.
                     66: * Loop Constructs::                     The @code{FOR} loop.
                     67: * Modular Programming::                 Extrinsic functions and subroutines.
                     68: * Object-Oriented Programming::         Classes and objects in FreeM.
                     69: * Libraries::                           System and user libraries.
                     70: * Sequential I/O::                      Processing sequential files in FreeM.
                     71: * Network I/O::                         Handling network sockets in FreeM.
                     72: * Extended Global References::          Accessing globals in non-default namespaces.
                     73: * Global Aliasing::                     Defining alternate names for globals.
                     74: * Global Mappings::                     Mapping global names to non-default namespaces.
                     75: 
                     76: * Transaction Processing::              Transactions in FreeM.
                     77: * Asynchronous Event Handling::         Handling asynchronous events in FreeM.
                     78: * Global Triggers::                     Responding to global accesses in M code.
                     79: * Synchronous Event Handling::          Synchronous events in FreeM.
                     80: 
                     81: 
                     82: * GUI Programming with MWAPI::          Creating graphical interfaces in FreeM.
                     83: 
                     84: * User-Defined Z Commands::             Adding your own Z commands to FreeM.
                     85: * User-Defined Z Functions::            Adding your own Z functions to FreeM.
                     86: * User-Defined SSVNs::                  Adding your own SSVNs to FreeM.
                     87: 
                     88: * Language Dialects::                   Controlling FreeM standards compliance.
                     89: 
                     90: * System Library Routines::             FreeM built-in library of M routines.
                     91: 
                     92: * Interrupt Handling::                  How FreeM handles interrupts.
                     93: * Error Processing::                    How to handle errors in M program code.
                     94: * FreeM Error Codes::                   Explanations of each FreeM error code.
                     95: * Debugging::                           The program development cycle of FreeM.
                     96: 
                     97: * System Configuration::                Configuring your FreeM installation.
                     98: * Accessing FreeM from C Programs::     How to use the mlib interface.
                     99: 
                    100: * FreeM Administrator::                 The fmadm system manager tool.
                    101: * FreeM Legacy Utilities::              FreeM legacy system manager utilities.
                    102: * FreeM VIEW Commands and Functions::   Getting and setting info about FreeM internals.
                    103: * Implementation Limits::               FreeM limitations.
                    104: * US-ASCII Character Set::              The US-ASCII character set.
                    105: * FreeM Project Coding Standards::      How to write code for submission to the FreeM project.
                    106: 
                    107: * Index::               Complete index.
                    108: @end menu
                    109: 
                    110: @node Introduction
                    111: @unnumbered Introduction
                    112: 
                    113: FreeM started its life as @emph{FreeMUMPS}, written for MS-DOS and ported to SCO UNIX by a mysterious individual going by the name of "Shalom ha-Ashkenaz". It was released to MUG Deutschland in 1998. In 1999, Ronald L. Fox ported FreeM to the Red Hat Linux 5 of the GNU/Linux operating system. Thereafter, maintenance was taken over by the Generic Universal M Project, which changed its name first to Public Standard MUMPS and then by popular request to FreeM.
                    114: 
                    115: When GT.M was open-sourced in late 1999, FreeM and GUMP were essentially abandoned. L.D. Landis, the owner of the original GUMP SourceForge project, and one of FreeM's significant contributors, passed maintenance of FreeM and ownership of its SourceForge project to Serena Willis in 2014. At this point, FreeM would not compile or run on modern Linux systems, so steps were taken to remedy the most pressing issues in the codebase. Limitations on the terminal size (previously hard-coded to 80x25) were lifted, and new @code{$VIEW} functions were added to retrieve the terminal size information. @code{$X} and @code{$Y} intrinsic special variables were updated to support arbitrary terminal sizes, and FreeM was once again able to build and run.
                    116: 
                    117: In February of 2020, work began in earnest to build a development and support infrastructure for FreeM and begin the careful process of refining it into a more stable and robust product.
                    118: 
                    119: @section Production Readiness
                    120: 
                    121: FreeM is not yet production-ready. There are several show-stopping bugs that preclude a general release for public use:
                    122: 
                    123: @itemize @bullet
                    124: 
                    125: @item
                    126: @code{@ref{VIEW}} commands and @code{@ref{$VIEW()}} functions are used extensively to configure and inspect the run-time behavior of FreeM, rather than the "canonical" SSVN-based approach.
                    127: 
                    128: @item
                    129: Server sockets are not yet implemented.
                    130: 
                    131: @item
                    132: There are some situations that can result in segmentation faults and/or lock-ups.
                    133: 
                    134: @item
                    135: In spite of our best efforts, this manual is not yet complete.
                    136: 
                    137: @end itemize
                    138: 
                    139: @section Contributors
                    140: Current contributors denoted with a @emph{+} following their name and role.
                    141: @cindex contributors, ha-Ashkenaz, Shalom
                    142: @cindex contributors, Best, John
                    143: @cindex contributors, Diamond, Jon
                    144: @cindex contributors, Fox, Ronald L.
                    145: @cindex contributors, Gerum, Winfried
                    146: @cindex contributors, Kreis, Greg
                    147: @cindex contributors, Landis, Larry
                    148: @cindex contributors, Milligan, Lloyd
                    149: @cindex contributors, Morris, Steve
                    150: @cindex contributors, Murray, John
                    151: @cindex contributors, Pastoors, Wilhelm
                    152: @cindex contributors, Schell, Kate
                    153: @cindex contributors, Schofield, Lyle
                    154: @cindex contributors, Stefanik, Jim
                    155: @cindex contributors, Trocha, Axel
                    156: @cindex contributors, Walters, Dick
                    157: @cindex contributors, Whitten, David
                    158: @cindex contributors, Wicksell, David
                    159: @cindex contributors, Willis, Serena
                    160: @cindex contributors, Zeck, Steve
                    161: 
                    162: @itemize @bullet
                    163: 
                    164: @item
                    165: Shalom ha-Ashkenaz (Original Implementer)
                    166: 
                    167: @item
                    168: John Best (IBM i and OS/400)
                    169: 
                    170: @item
                    171: Jon Diamond (Library, Utilities, Conformance)
                    172: 
                    173: @item
                    174: Ronald L. Fox (Initial port to Red Hat 5/libc-6)
                    175: 
                    176: @item
                    177: Winfried Gerum (Code, Advice, MTA coordination)
                    178: 
                    179: @item
                    180: Greg Kreis (Hardhats coordination, Dependencies)
                    181: 
                    182: @item
                    183: Larry Landis (Coordination, Code, Documentation)
                    184: 
                    185: @item
                    186: Rick Marshall (Testing, MDC Conformance) @emph{+}
                    187: 
                    188: @item
                    189: Lloyd Milligan (Code, Testing, Documentation)
                    190: 
                    191: @item
                    192: Steve Morris (Code, Microsoft)
                    193: 
                    194: @item
                    195: John Murray (Code, Conformance)
                    196: 
                    197: @item
                    198: Wilhelm Pastoors (Testing, Documentation)
                    199: 
                    200: @item
                    201: Kate Schell (Coordination, Conformance, MTA, MDC, Advice)
                    202: 
                    203: @item
                    204: Lyle Schofield (Advice, Prioritization, Tracking, Project Management)
                    205: 
                    206: @item
                    207: Jim Stefanik (GNU/Linux on s390x, IBM AIX, IBM z/OS)
                    208: 
                    209: @item
                    210: Axel Trocha (Code, Utilities)
                    211: 
                    212: @item
                    213: Dick Walters (Project Lead, Chief Coordinator, MTA)
                    214: 
                    215: @item
                    216: David Whitten (QA Test Suite, MDC, Advice) @emph{+}
                    217: 
                    218: @item
                    219: David Wicksell (Debugging, Code, Testing) @emph{+}
                    220: 
                    221: @item
                    222: Serena Willis (Current Maintainer and Project Lead) @emph{+}
                    223: 
                    224: @item
                    225: Steve Zeck (Code)
                    226: 
                    227: @end itemize
                    228: @node FreeM Invocation
                    229: @chapter FreeM Invocation
                    230: @cindex invocation, command-line
                    231: @cindex options, command-line
                    232: 
                    233: @section Synopsis
                    234: @example
                    235: $ @command{./freem} [@emph{OPTIONS}...] [[-r <entryref>] | [--routine=<entryref>]]
                    236: @end example
                    237: 
                    238: When FreeM loads, it searches the @code{SYSTEM} namespace for the @code{^%SYSINIT} routine, and begins executing it.
                    239: 
1.22      snw       240: When @code{-r} or @code{--routine} are passed on the command line, FreeM will load and run the specified routine after running @code{^%SYSINIT}. Beginning with FreeM 0.1.7, routines invoked in this manner are no longer required to perform their own namespace setup with @code{VIEW} commands.
                    241: 
                    242: @section %SYSINIT Routine
                    243: 
                    244: The @code{^%SYSINIT} routine runs every time a FreeM interpreter process starts. This routine defines some useful constants, enables handling of @code{TRIGGER} events, and handles the execution of code passed via the @code{-x\--execute} or routines passed via @code{-r|--routine}.
                    245: 
                    246: Do not modify the supplied @code{^%SYSINIT} routine to add site-specific startup items. Instead, create a @code{^LCLINIT} routine in the @code{USER} namespace of one or more environments. @code{^%SYSINIT} will automatically run @code{^LCLINIT} each time it starts.
1.1       snw       247: 
                    248: @section Command-Line Options
1.22      snw       249: @cindex options, command-line
1.1       snw       250: 
                    251: @table @asis
                    252: 
                    253: @item @option{-d}, @option{--daemon}
1.22      snw       254: Starts the FreeM environment daemon, exactly one of which must be running at all times in order for FreeM interpreter and fmadm processes to function.
1.1       snw       255: 
                    256: @item @option{-e}, @option{--environment}
                    257: Selects the environment to be used. If no environment is specified, @code{DEFAULT} is used.
                    258: 
                    259: @item @option{-k}, @option{--nofork}
1.22      snw       260: When used with @option{-d} or @option{--daemon}, causes the FreeM environment daemon to run instead in the foreground. Useful for debugging.
1.1       snw       261: 
                    262: @item @option{-S}, @option{--shmsize}
                    263: When used with @option{-d} or @option{--daemon}, specifies the number of bytes of shared memory FreeM will allocate for the @code{LOCK} table, job table, and IPC table. This will determine the maximum number of concurrent FreeM processes and @code{LOCK}s available in this environment. 
                    264: 
                    265: @item @option{-c}, @option{--config}
                    266: Specify a configuration file other than @code{$PREFIX/etc/freem.conf}.
                    267: 
                    268: @item @option{-h}, @option{--help}
                    269: Display a help message showing valid FreeM options.
                    270: 
                    271: @item @option{-i}, @option{--import}
                    272: Causes your UNIX environment variables to be imported into FreeM's local symbol table.
                    273: 
                    274: @item @option{-f}, @option{--filter}
                    275: Allows your M routines to be used as UNIX filters.
                    276: 
                    277: @item @option{-n @emph{<namespace-name>}}, @option{--namespace=@emph{<namespace-name>}}
1.22      snw       278: Selects the FreeM namespace to be entered on startup. Must be defined in @file{/etc/<environment>/freem.conf}.
1.1       snw       279: 
                    280: @item @option{-r @emph{<entryref>}}, @option{--routine=@emph{<entryref>}}
                    281: Causes @code{<entryref>} to be executed at load, instead of @code{^%SYSINIT}.
                    282: 
                    283: @item @option{--standard=@emph{<standard>}}
                    284: Sets the default FreeM dialect to use for new routine buffers.
                    285: 
                    286: Valid values for @code{@emph{<standard>}} are as follows:
                    287: 
                    288: @table @code
                    289: @item @code{M77}
                    290: Restricts FreeM to use only features specified by the 1977 M standard.
                    291: @item @code{M84}
                    292: Restricts FreeM to use only features specified by the 1984 M standard.
                    293: @item @code{M90}
                    294: Restricts FreeM to use only features specified by the 1990 M standard.
                    295: @item @code{M95}
                    296: Restricts FreeM to use only features specified by the 1995 M standard.
                    297: @item @code{MDS}
                    298: Restricts FreeM to use only features proposed by the Millennium Draft Standard.
                    299: @item @code{M5}
                    300: Restricts FreeM to use only features proposed by the upcoming M5 standard.
                    301: @item @code{FREEM}, @code{EXTENDED}
                    302: Removes all standards-based restrictions and allows full access to all FreeM features. This is the default value of @code{$DIALECT}.
                    303: @end table
                    304: 
                    305: Please note that FreeM is not entirely standards-compliant, regardless of the value of @code{@emph{<standard>}}.
                    306: 
                    307: @item @option{-v}, @option{--version}
                    308: Displays FreeM version information.
                    309: 
                    310: @item @option{-x @emph{<mcode>}}, @option{--execute=@emph{<mcode>}}
1.22      snw       311: Executes M code @code{<mcode>} at startup.
1.1       snw       312: 
                    313: @end table
                    314: 
                    315: @section Using FreeM for Shell Scripting
                    316: @cindex routines, as shell scripts
                    317: @cindex shebang line
                    318: @cindex shell scripting
                    319: 
                    320: FreeM M routines can be used as shell scripts by providing a @emph{shebang} line beginning with @code{#!/path/to/freem} as the first line of the routine.
                    321: The following example presumes that FreeM is installed at @file{/usr/local/bin/freem} and uses the @code{USER} namespace:
                    322: 
                    323: @example
                    324: #!/usr/local/bin/freem
                    325: MYSCRIPT ;
                    326:  SET ^$JOB($JOB,"NAMESPACE")="USER"
                    327:  WRITE "This is output from an M routine used as a shell script.",!
                    328:  Q
                    329: @end example
                    330: 
                    331: Currently, the script needs to have a @file{.m} file extension. You will also need to select an appropriate namespace in your script using the @code{SET ^$JOB($JOB,"NAMESPACE")="@emph{<namespace>}"} command before attempting to call other routines or access globals.
                    332: 
                    333: You will also need to set the script's permissions to @emph{executable} in order for this to work:
                    334: 
                    335: @example
                    336: $ chmod +x @emph{myscript.m}
                    337: @end example
                    338: 
1.22      snw       339: @node The FreeM Environment Daemon
                    340: @chapter The FreeM Environment Daemon
1.1       snw       341: @cindex daemon, freem
                    342: 
1.22      snw       343: The FreeM environment daemon manages shared resources for a given FreeM environment. These include the lock table, job table, inter-process communication, and concurrency control for transaction processing. Unlike some M implementations, the FreeM environment daemon does @emph{not} function as a write daemon for global storage.
                    344: 
                    345: One daemon process is required per FreeM environment, and can be started in the following ways, in order of preference:
1.1       snw       346: 
1.22      snw       347: @example
                    348: $ sudo fmadm start environment [-e=<environment-name>]
                    349: @end example
1.1       snw       350: 
                    351: @example
1.22      snw       352: $ freem --daemon [--nofork] [--environment=<environment-name>] [--shmsize=<bytes>]
1.1       snw       353: @end example
                    354: 
                    355: If the daemon is started with @option{--nofork}, it will run in the foreground and its output will be reflected on the terminal. Otherwise, the daemon will run as a child process in the background and immediately return terminal control to the shell. The latter option is recommended in most cases.
                    356: 
                    357: The @option{--environment} option will start the daemon for the specified @emph{environment-name}. The default environment, if unspecified, is called @code{DEFAULT}. If using an environment other than @code{DEFAULT}, interpreter processes that wish to also connect to the same environment must also use the @option{--environment} option when starting, and @code{libfreem} clients must also pass the environment name as the first argument to the @code{freem_init()} function. Environments allow you to run multiple, isolated instances of FreeM on the same machine, whose globals and routines are distinct and unique.
                    358: 
                    359: The @option{--shmsize} option specifies the size in bytes of the FreeM shared memory segment. The default is 4194304 bytes. Increasing the size of the FreeM shared memory segment will, at the cost of increased memory usage, increase the number of concurrent jobs and lock table entries available to the environment; decreasing the size of the segment will have the expected opposite effect. Note that you must also pass @option{--shmsize} with the same number of bytes to any interpreter process to be used with an environment whose daemon uses a non-default shared memory segment size.
                    360: 
                    361: Attempting to start a FreeM interpreter process without a daemon running with the same environment name will result in an error.
                    362: 
                    363: @node The FreeM Direct-Mode Environment
                    364: @chapter The FreeM Direct-Mode Environment
                    365: @cindex command line interface
                    366: @cindex direct mode
                    367: @cindex execution, interactive
                    368: @cindex modes, programmer
                    369: 
                    370: 
                    371: The FreeM direct-mode environment is the mode entered when FreeM is invoked without the use of @option{-r @emph{<entryref>}} or @option{--routine=@emph{<entryref>}}:
                    372: 
                    373: @example
1.21      snw       374: Coherent Logic Development FreeM version 0.64.0-rc0 (x86_64-pc-linux-gnu)
1.1       snw       375: Copyright (C) 2014, 2020, 2021 Coherent Logic Development LLC
                    376: 
                    377: 
                    378: USER>
                    379: @end example
                    380: 
1.25      snw       381: The prompt (@code{DEFAULT.USER>}) displays the current environment and namespace, @code{DEFAULT} and @code{USER}, respsectively. If any uncommitted direct-mode transactions have been started, the prompt will change to reflect the current value of @code{@ref{$TLEVEL}}:
1.1       snw       382: 
                    383: @example
1.22      snw       384: TL1:DEFAULT.USER>
1.1       snw       385: @end example
                    386: 
                    387: In the above example, @code{TL1} indicates that @code{@ref{$TLEVEL}} is currently @emph{1}.
                    388: 
                    389: @section Direct-Mode Commands
                    390: 
                    391: When you are in direct mode, in addition to M commands, a number of internal commands are available to help developers be more productive:
                    392: 
                    393: @table @asis
                    394: 
                    395: @item @command{?}
                    396: Accesses FreeM online help. Requires GNU @command{info(1)} to be installed on your local system.
                    397: 
                    398: @item @command{events}
                    399: Writes a list of @emph{event classes} and their @code{ABLOCK} counts:
                    400: 
                    401: @example
1.22      snw       402: DEFAULT.USER> events
1.1       snw       403:  
                    404: Event Class          Processing Mode ABLOCK Count
                    405: -----------          --------------- ------------
                    406: COMM                 Disabled        0
                    407: HALT                 Disabled        0
                    408: IPC                  Disabled        0
                    409: INTERRUPT            Disabled        0
                    410: POWER                Disabled        0
                    411: TIMER                Disabled        0
                    412: USER                 Disabled        0
                    413: WAPI                 Disabled        0
                    414: TRIGGER              Disabled        0
                    415: @end example
                    416: 
                    417: 
                    418: @anchor{trantab}
                    419: @item @command{trantab}
                    420: Displays information about any uncommitted transactions currently in-flight for this process.
                    421: 
1.22      snw       422: @anchor{glstat}
                    423: @item @command{trantab}
                    424: Displays statistics about globals that have been opened in the current FreeM process.
                    425: 
1.1       snw       426: @anchor{jobtab}
                    427: @item @command{jobtab}
                    428: Displays a summary of the FreeM job table.
                    429: 
                    430: @anchor{locktab}
                    431: @item @command{locktab}
                    432: Displays a list of @code{LOCK}s held in the current environment.
                    433: 
                    434: @anchor{rbuf}
                    435: @item @command{rbuf}
                    436: Lists the status of all FreeM routine buffers.
                    437: 
                    438: @anchor{dbstats}
                    439: @item @command{dbstats}
                    440: Shows statistics for the BerkeleyDB global handler.
                    441: 
                    442: @anchor{wh}
                    443: @item @command{wh}
                    444: Forces an immediate flush of this process's @code{readline} history buffer to disk.
                    445: 
                    446: @anchor{shmstat}
                    447: @item @command{shmstat}
                    448: Displays the configuration of FreeM shared memory. Intended only for advanced debugging of the FreeM environment.
                    449: 
                    450: @anchor{shmpages}
                    451: @item @command{shmpages}
                    452: Lists the status of each FreeM shared memory page. Intended only for advanced debugging of the FreeM environment.
                    453: 
                    454: @anchor{history}
                    455: @item @command{history}
                    456: Prints a list of all the direct-mode commands you have entered across all sessions.
                    457: 
                    458: @anchor{rcl}
                    459: @item @command{rcl @emph{<history-index>}}
                    460: Allows you to recall command number @emph{<history-index>} and run it again. Obtain the value for @emph{<history-index>} from the output of the @command{history} command.
                    461: 
                    462: @item @command{!!}
                    463: Launches a subshell within the FreeM direct mode, allowing the user to run operating system commands.
                    464: 
                    465: @example
1.22      snw       466: DEFAULT.USER> !!
1.1       snw       467: 
                    468: Type Ctrl-D to exit from the shell
                    469: $ uname -a
                    470: Linux hesperos 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
                    471: $ exit
                    472: 
1.22      snw       473: DEFAULT.USER> 
1.1       snw       474: @end example
                    475: 
                    476: @item @command{!@emph{<external-command>}}
                    477: Invokes a shell to run @emph{<external-command>} from within FreeM. This temporarily disables @command{SIGALRM} handling in FreeM, which may interrupt the use of event-driven M programming commands including @command{ESTART} and @command{ESTOP}.
                    478: 
                    479: If the @command{>} character is supplied immediately preceding @emph{<external-command>}, FreeM will append the contents of an M local or global variable referenced in @code{^$JOB($JOB,"PIPE_GLVN")} to the standard input stream of @emph{<external-command>}.
                    480: 
                    481: If the @command{<} character is supplied immediately preceding @emph{<external-command>}, FreeM will take the standard output stream of @emph{<external-command>} and store it in M local or global variable referenced by @code{^$JOB($JOB,"PIPE_GLVN")}.
                    482: 
                    483: The data value in the unsubscripted M local or global contains the number of lines in the input or output. Subscripts @code{(1)..(@emph{n})} contain the data for lines 1-@emph{n}.
                    484: 
                    485: @end table
                    486: 
                    487: @cindex HALT, in direct-mode
                    488: If you issue a @code{@ref{HALT}} command at the direct-mode prompt, you will exit out of FreeM. However, if you issue a @code{@ref{HALT}} command when @code{@ref{$TLEVEL}} is greater than zero, you will be given the opportunity to commit or rollback any pending transactions:
                    489: 
                    490: @example
1.22      snw       491: DEFAULT.USER> TSTART
1.1       snw       492:  
                    493: 
1.22      snw       494: TL1:DEFAULT.USER> SET ^MYGLOBAL=1
1.1       snw       495:  
                    496:  
1.22      snw       497: TL1:DEFAULT.USER> HALT
1.1       snw       498:  
                    499: UNCOMMITTED TRANSACTIONS EXIST:
                    500:  
                    501:  $TLEVEL 1*
                    502:   Operations for Transaction ID: k8xj1de
                    503:   1:   action = 0  key = ^MYGLOBAL  data = 1
                    504:  
                    505: Would you like to c)ommit or r)ollback the above transactions and their operations? ($TLEVEL = 1) r
                    506: 
                    507: 
                    508: Transactions have been rolled back.
                    509: @end example
                    510: 
                    511: In the above example, the user selected @code{r} to rollback the single pending transaction.
                    512: 
                    513: @section REPL Functionality
                    514: @cindex REPL, direct-mode
                    515: 
                    516: FreeM direct mode allows you to enter M expressions directly from the direct-mode prompt, as long as they begin with a number:
                    517: 
                    518: @example
1.22      snw       519: DEFAULT.USER> S DENOM=10
1.1       snw       520:  
                    521:  
1.22      snw       522: DEFAULT.USER> 100/DENOM
1.1       snw       523:  
                    524: 10
1.22      snw       525: DEFAULT.USER> 
1.1       snw       526: @end example
                    527: 
                    528: Such expressions will be immediately evaluated, and the result printed on @code{@ref{$IO}}.
                    529: 
                    530: @node Directives
                    531: @chapter Directives
                    532: @cindex directives
                    533: 
                    534: In FreeM, a directive is an instruction embedded in an M comment, and passed to the interpreter to affect a change that is specific to the current routine only.
                    535: 
                    536: The format of a directive is @code{;%@emph{<directive-name>}}, where @code{@emph{<directive-name>}} is one of the directives listed below.
                    537: 
                    538: @menu
                    539: * %DIALECT::            Sets the M dialect in effect.
                    540: @end menu
                    541: 
                    542: @anchor{%DIALECT}
                    543: @section %DIALECT
                    544: @cindex %DIALECT
                    545: @cindex directives, %DIALECT
                    546: 
                    547: Sets the M dialect in effect for the current routine buffer; also sets the @code{$DIALECT} special variable to match. See also @ref{$DIALECT}.
                    548: 
                    549: @emph{Syntax}
                    550: 
                    551: @example
                    552: ;%DIALECT @emph{<dialect>}
                    553: @end example
                    554: 
                    555: Valid values for @code{@emph{<dialect>}} are as follows:
                    556: 
                    557: @table @code
                    558: @item @code{M77}
                    559: Restricts FreeM to use only features specified by the 1977 M standard.
                    560: @item @code{M84}
                    561: Restricts FreeM to use only features specified by the 1984 M standard.
                    562: @item @code{M90}
                    563: Restricts FreeM to use only features specified by the 1990 M standard.
                    564: @item @code{M95}
                    565: Restricts FreeM to use only features specified by the 1995 M standard.
                    566: @item @code{MDS}
                    567: Restricts FreeM to use only features proposed by the Millennium Draft Standard.
                    568: @item @code{M5}
                    569: Restricts FreeM to use only features proposed by the upcoming M5 standard.
                    570: @item @code{FREEM}, @code{EXTENDED}
                    571: Removes all standards-based restrictions and allows full access to all FreeM features. This is the default value of @code{%DIALECT}.
                    572: @end table
                    573: 
                    574: Please note that FreeM is not entirely standards-compliant, regardless of the value of @code{%DIALECT}.
                    575: 
                    576: 
                    577: @node Intrinsic Special Variables
                    578: @chapter Intrinsic Special Variables
                    579: @cindex variables, intrinsic special
                    580: 
                    581: @menu
                    582: * $DEVICE::                  $IO device status.
                    583: * $DIALECT::                 Current M dialect.
                    584: * $ECODE::                   Latest M error code.
                    585: * $ESTACK::                  Error stack info.
                    586: * $ETRAP::                   Standard error handler code.
                    587: * $HOROLOG::                 Current date and time.
                    588: * $IO::                      Current I/O device.
                    589: * $JOB::                     PID of current process.
                    590: * $KEY::                     Characters terminating last @code{READ} command.
                    591: * $PDISPLAY::                Current primary MWAPI display.
                    592: * $PRINCIPAL::               I/O channel of terminal.
                    593: * $REFERENCE::               Most recent global reference.
                    594: * $QUIT::                    Whether a @code{QUIT} command requires an argument in the current execution context.
                    595: * $STACK::                   Current program execution stack level.
                    596: * $STORAGE::                 Number of bytes available in the heap.
                    597: * $SYSTEM::                  MDC system ID of FreeM.
                    598: * $TEST::                    Truth value of last conditional expression or result of certain @code{LOCK} operations.
                    599: * $TLEVEL::                  Current level of transaction nesting.
                    600: * $WITH::                    Current variable prefix set by @code{WITH} command.
                    601: * $X::                       Current horizontal screen position.
                    602: * $Y::                       Current vertical screen position.
                    603: * $ZA::                      Current position of file on @code{$IO}.
                    604: * $ZB::                      Most recent keystroke.
                    605: * $ZCONTROLC::               Control-C handling flag.
                    606: * $ZDATE::                   Current date in locale-specific representation.
                    607: * $ZERROR::                  Last error message.
                    608: * $ZHOROLOG::                Date and time, including milliseconds.
                    609: * $ZINRPT::                  State of the interrupt enable/disable flag.
                    610: * $ZJOB::                    PID of parent process, if applicable.
                    611: * $ZLOCAL::                  Last local variable reference.
                    612: * $ZNAME::                   Name of current M routine.
                    613: * $ZPRECISION::              Digits of arithmetical precision.
                    614: * $ZREFERENCE::              Last gvn referenced.
                    615: * $ZSYSTEM::                 Return value of last external command.
                    616: * $ZTIME::                   Current time in locale-specific representation.
                    617: * $ZTRAP::                   Entryref to be executed on error condition.
                    618: * $ZUT::                     Microseconds since the UNIX epoch.
                    619: * $ZVERSION::                Version of FreeM and GNU host triplet.
                    620: @end menu 
                    621: 
                    622: @node $DEVICE
                    623: @section $DEVICE
                    624: @cindex $DEVICE
                    625: @cindex intrinsic special variables, $DEVICE
                    626: 
                    627: Returns the status of the device currently in use.
                    628: 
                    629: If @code{$DEVICE} returns @emph{1}, an error condition exists on the current device. In this case, there will be two additional fields separated by commas, indicating the internal FreeM error code representing the error present on the device and a text explanation of the error.
                    630: 
                    631: @node $DIALECT
                    632: @section $DIALECT
                    633: @cindex $DIALECT
                    634: @cindex intrinsic special variables, $DIALECT
                    635: 
                    636: Returns or sets the language dialect of the current routine.
                    637: 
                    638: Valid values for @code{$DIALECT} are as follows:
                    639: 
                    640: @table @code
                    641: @item @code{M77}
                    642: Restricts FreeM to use only features specified by the 1977 M standard.
                    643: @item @code{M84}
                    644: Restricts FreeM to use only features specified by the 1984 M standard.
                    645: @item @code{M90}
                    646: Restricts FreeM to use only features specified by the 1990 M standard.
                    647: @item @code{M95}
                    648: Restricts FreeM to use only features specified by the 1995 M standard.
                    649: @item @code{MDS}
                    650: Restricts FreeM to use only features proposed by the Millennium Draft Standard.
                    651: @item @code{M5}
                    652: Restricts FreeM to use only features proposed by the upcoming M5 standard.
                    653: @item @code{FREEM}, @code{EXTENDED}
                    654: Removes all standards-based restrictions and allows full access to all FreeM features. This is the default value of @code{$DIALECT}.
                    655: @end table
                    656: 
                    657: Please note that FreeM is not entirely standards-compliant, regardless of the value of @code{$DIALECT}.
                    658: 
                    659: @node $ECODE
                    660: @section $ECODE
                    661: @cindex $ECODE
                    662: @cindex intrinsic special variables, $ECODE
                    663: 
                    664: Returns a comma-delimited list of error conditions currently present, and is writable. An empty @code{$ECODE} indicates no errors.
                    665: 
                    666: @node $ESTACK
                    667: @section $ESTACK
                    668: @cindex $ESTACK
                    669: @cindex intrinsic special variables, $ESTACK
                    670: 
                    671: Returns the depth of the program execution stack since the last time @code{$ESTACK} was @code{NEW}ed. @code{NEW}-able, but not @code{SET}-able. Differs from the @code{@ref{$STACK}} ISV in that it is @code{@ref{NEW}}-able, and resets to a value of 0 when @code{@ref{NEW}}ed.
                    672: 
                    673: @node $ETRAP
                    674: @section $ETRAP
                    675: @cindex $ETRAP
                    676: @cindex intrinsic special variables, $ETRAP
                    677: 
                    678: Sets or retrieves the M code that is run when an error is encountered or @code{@ref{$ECODE}} is set to a non-blank value. @code{$ETRAP} code executes when @code{$ECODE} becomes non-blank.
                    679: 
                    680: 
                    681: @node $HOROLOG
                    682: @section $HOROLOG
                    683: @cindex $HOROLOG
                    684: @cindex intrinsic special variables, $HOROLOG
                    685: 
                    686: Returns a string containing the current date and time as @code{<days>,<seconds>}, where @code{<days>} represents the number of days since the M epoch (midnight on 31 December 1840),
                    687: and @code{<seconds>} represents the number of seconds since the most recent midnight.
                    688: 
                    689: @cartouche
                    690: @quotation
                    691: @emph{FreeM Extension}
                    692: 
                    693: In FreeM, @code{$HOROLOG} is @code{@ref{SET}}table. Setting @code{$HOROLOG} will set the system clock if your user account has the appropriate permissions. If your user account does not have permissions to modify the system clock, FreeM will raise a @code{ZPROTECT} error.
                    694: @end quotation
                    695: @end cartouche
                    696: 
                    697: @node $IO
                    698: @section $IO
                    699: @cindex $IO
                    700: @cindex intrinsic special variables, $IO
                    701: 
                    702: Represents the current input/output device. Read-only.
                    703: 
                    704: @node $JOB
                    705: @section $JOB
                    706: @cindex $JOB
                    707: @cindex intrinsic special variables, $JOB
                    708: 
                    709: Represents the process ID of the FreeM instance currently in use.
                    710: 
                    711: @node $KEY
                    712: @section $KEY
                    713: @cindex $KEY
                    714: @cindex intrinsic special variables, $KEY
                    715: 
                    716: Represents the sequence of control characters that terminated the last @code{@ref{READ}} command on @code{@ref{$IO}}.
                    717: 
                    718: @node $PDISPLAY
                    719: @section $PDISPLAY
                    720: @cindex $PDISPLAY
                    721: @cindex intrinsic special variables, $PDISPLAY
                    722: 
                    723: Represents the current principal display for M Windowing API operations. Commonly used as an index into the @code{@ref{^$DISPLAY}} structured system variable.
                    724: 
                    725: @node $PRINCIPAL
                    726: @section $PRINCIPAL
                    727: @cindex $PRINCIPAL
                    728: @cindex intrinsic special variables, $PRINCIPAL
                    729: 
                    730: Represents the primary input/output device. Usually a terminal or virtual terminal.
                    731: 
                    732: @node $REFERENCE
                    733: @section $REFERENCE
                    734: @cindex $REFERENCE
                    735: @cindex intrinsic special variables, $REFERENCE
                    736: 
                    737: Returns the last @emph{glvn} referenced. Can be @code{@ref{SET}}, and also stacked with @code{@ref{NEW}}.
                    738: 
                    739: @node $QUIT
                    740: @section $QUIT
                    741: @cindex $QUIT
                    742: @cindex intrinsic special variables, $QUIT
                    743: 
                    744: If the current execution context was invoked as an extrinsic function, @code{$QUIT} returns @emph{1}. Otherwise, returns @emph{0}.
                    745: 
                    746: When @code{$QUIT} returns @emph{1}, a subsequent @code{@ref{QUIT}} command must have an argument.
                    747: 
                    748: @node $STACK
                    749: @section $STACK
                    750: @cindex $STACK
                    751: @cindex intrinsic special variables, $STACK
                    752: 
                    753: Represents the current stack level.
                    754: 
                    755: @node $STORAGE
                    756: @section $STORAGE
                    757: @cindex $STORAGE
                    758: @cindex intrinsic special variables, $STORAGE
                    759: 
                    760: Represents the number of bytes of free space available in FreeM's heap.
                    761: 
                    762: @node $SYSTEM
                    763: @section $SYSTEM
                    764: @cindex $SYSTEM
                    765: @cindex intrinsic special variables, $SYSTEM
                    766: 
                    767: Returns the MDC system ID of FreeM, as well as the environment ID of the current environment.
                    768: 
                    769: @node $TEST
                    770: @section $TEST
                    771: @cindex $TEST
                    772: @cindex intrinsic special variables, $TEST
                    773: 
                    774: @code{$TEST} is a writable, @code{@ref{NEW}}-able ISV that is @emph{1} if the most recently evaluated expression was @emph{true}. Otherwise, returns @emph{0}.
                    775: 
                    776: @code{$TEST} is implicitly @code{NEW}ed when entering a new stack frame for extrinsic functions and argumentless @code{@ref{DO}}. @code{$TEST}
                    777: is @emph{not} implicitly @code{NEW}ed when a new stack frame is entered with an argumented @code{DO}.
                    778: 
                    779: For single-line @code{@ref{IF}} or @code{@ref{ELSE}} expressions, you may use @code{@ref{THEN}} to stack @code{$TEST} until the end of the line. All new code should employ @code{THEN} in this manner, as stacking @code{$TEST} prevents a wide range of coding errors that can be very challenging to detect and eliminate.
                    780: 
                    781: @node $TLEVEL
                    782: @section $TLEVEL
                    783: @cindex $TLEVEL
                    784: @cindex intrinsic special variables, $TLEVEL
                    785: 
                    786: Returns a numeric value indicating the current level of transaction nesting in the process. When @code{$TLEVEL} is greater than @emph{0},
                    787: uncommitted transactions exist.
                    788: 
                    789: @node $WITH
                    790: @section $WITH
                    791: @cindex $WITH
                    792: @cindex intrinsic special variables, $WITH
                    793: 
                    794: Returns the variable prefix set by the @code{@ref{WITH}} command.
                    795: 
                    796: @node $X
                    797: @section $X
                    798: @cindex $X
                    799: @cindex intrinsic special variables, $X
                    800: 
                    801: Represents the current column position of the FreeM cursor.
                    802: 
                    803: @cartouche
                    804: @quotation
                    805: In FreeM, setting @code{$X} will move the FreeM cursor.
                    806: @end quotation
                    807: @end cartouche
                    808: 
                    809: 
                    810: @node $Y
                    811: @section $Y
                    812: @cindex $Y
                    813: @cindex intrinsic special variables, $Y
                    814: 
                    815: Represents the current row position of the FreeM cursor.
                    816: 
                    817: @cartouche
                    818: @quotation
                    819: In FreeM, setting @code{$Y} will move the FreeM cursor.
                    820: @end quotation
                    821: @end cartouche
                    822: 
                    823: 
                    824: @node $ZA
                    825: @section $ZA
                    826: @cindex $ZA
                    827: @cindex intrinsic special variables, $ZA
                    828: @cindex intrinsic special variables, implementation-specific
                    829: 
                    830: On the @code{HOME} device, always @code{0}. On other devices, returns the current position of the file opened on I/O channel @code{@ref{$IO}}.
                    831: 
                    832: @node $ZB
                    833: @section $ZB
                    834: @cindex $ZB
                    835: @cindex intrinsic special variables, $ZB
                    836: @cindex intrinsic special variables, implementation-specific
                    837: 
                    838: Represents the last keystroke.
                    839: 
                    840: @node $ZCONTROLC
                    841: @section $ZCONTROLC
                    842: @cindex $ZCONTROLC
                    843: @cindex intrinsic special variables, $ZCONTROLC
                    844: @cindex intrinsic special variables, implementation-specific
                    845: 
                    846: Returns the status of the Ctrl-C flag and resets it to @emph{false}.
                    847: 
                    848: @node $ZDATE
                    849: @section $ZDATE
                    850: @cindex $ZDATE
                    851: @cindex intrinsic special variables, $ZDATE
                    852: @cindex intrinsic special variables, implementation-specific
                    853: 
                    854: Returns the current date, in the preferred representation for the current system locale.
                    855: 
                    856: @node $ZERROR
                    857: @section $ZERROR
                    858: @cindex $ZERROR
                    859: @cindex intrinsic special variables, $ZERROR
                    860: @cindex intrinsic special variables, implementation-specific
                    861: 
                    862: Returns the last error message.
                    863: 
                    864: @node $ZHOROLOG
                    865: @section $ZHOROLOG
                    866: @cindex $ZHOROLOG
                    867: @cindex intrinsic special variables, $ZHOROLOG
                    868: @cindex intrinsic special variables, implementation-specific
                    869: 
                    870: Output @code{@ref{$HOROLOG}}-style time, with the addition of milliseconds.
                    871: 
                    872: @node $ZINRPT
                    873: @section $ZINRPT
                    874: @cindex $ZINRPT
                    875: @cindex intrinsic special variables, $ZINRPT
                    876: @cindex intrinsic special variables, implementation-specific
                    877: 
                    878: Gets or sets the interrupt enable/disable flag.
                    879: 
                    880: @node $ZJOB
                    881: @section $ZJOB
                    882: @cindex $ZJOB
                    883: @cindex intrinsic special variables, $ZJOB
                    884: @cindex intrinsic special variables, implementation-specific
                    885: 
                    886: Returns the @code{@ref{$JOB}} value of the parent process if the current process was started by a @code{@ref{JOB}} command. Otherwise, returns an empty string.
                    887: 
                    888: @node $ZLOCAL
                    889: @section $ZLOCAL
                    890: @cindex $ZLOCAL
                    891: @cindex intrinsic special variables, $ZLOCAL
                    892: @cindex intrinsic special variables, implementation-specific
                    893: 
                    894: Returns the last local variable referenced.
                    895: 
                    896: @node $ZNAME
                    897: @section $ZNAME
                    898: @cindex $ZNAME
                    899: @cindex intrinsic special variables, $ZNAME
                    900: @cindex intrinsic special variables, implementation-specific
                    901: 
                    902: Returns the name of the current routine.
                    903: 
                    904: @node $ZPRECISION
                    905: @section $ZPRECISION
                    906: @cindex $ZPRECISION
                    907: @cindex intrinsic special variables, $ZPRECISION
                    908: @cindex intrinsic special variables, implementation-specific
                    909: 
                    910: Gets or sets the number of digits of numeric precision used for fixed-point decimal arithmetic. If @code{^$JOB($JOB,"MATH")} is @code{IEEE754}, @code{$ZPRECISION} defaults to 16 digits, with a maximum of 16 digits. If @code{^$JOB($JOB,"MATH")} is @code{FIXED}, @code{$ZPRECISION} defaults to 100 digits, with a maximum of 20,000 digits.
                    911: 
                    912: @xref{^$JOB}.
                    913: 
                    914: @node $ZREFERENCE
                    915: @section $ZREFERENCE
                    916: @cindex $ZREFERENCE
                    917: @cindex intrinsic special variables, $ZREFERENCE
                    918: @cindex intrinsic special variables, implementation-specific
                    919: 
                    920: Returns the last @emph{gvn} referenced.
                    921: 
                    922: @node $ZSYSTEM
                    923: @section $ZSYSTEM
                    924: @cindex $ZSYSTEM
                    925: @cindex intrinsic special variables, $ZSYSTEM
                    926: @cindex intrinsic special variables, implementation-specific
                    927: 
                    928: Represents the return value of the last external command run with @code{!}.
                    929: 
                    930: @node $ZTIME
                    931: @section $ZTIME
                    932: @cindex $ZTIME
                    933: @cindex intrinsic special variables, $ZTIME
                    934: @cindex intrinsic special variables, implementation-specific
                    935: 
                    936: Returns the system time in the preferred representation for the current system locale.
                    937: 
                    938: @node $ZTRAP
                    939: @section $ZTRAP
                    940: @cindex $ZTRAP
                    941: @cindex intrinsic special variables, $ZTRAP
                    942: @cindex intrinsic special variables, implementation-specific
                    943: 
                    944: Sets or retrieves the entryref to be executed when an M program execution error occurs under FreeM-style or DSM 2.0-style error processing.
                    945: 
                    946: In FreeM-style error processing, @code{$ZTRAP} is specific to each program execution stack level.
                    947: 
                    948: In DSM 2.0-style error processing, @code{$ZTRAP} is the same for all program execution stack levels.
                    949: 
                    950: When FreeM encounters an error, if @code{$ZTRAP} is nonempty and @code{$ETRAP} is empty, FreeM will perform an implicit @code{@ref{GOTO}} to the entryref indicated in @code{$ZTRAP}.
                    951: 
                    952: If @code{$ETRAP} is nonempty when FreeM encounters an error, the value of @code{$ZTRAP} is ignored, whether FreeM-style or DSM 2.0-style error processing is enabled.
                    953: 
                    954: @node $ZUT
                    955: @section $ZUT
                    956: @cindex $ZUT
                    957: @cindex intrinsic special variables, $ZUT
                    958: @cindex intrinsic special variables, implementation-specific
                    959: 
                    960: Returns the number of microseconds elapsed since the UNIX epoch (Jan 1, 1970 0:00:00).
                    961: 
                    962: @node $ZVERSION
                    963: @section $ZVERSION
                    964: @cindex $ZVERSION
                    965: @cindex intrinsic special variables, $ZVERSION
                    966: @cindex intrinsic special variables, implementation-specific
                    967: 
                    968: Returns the version of FreeM in use, as well as the GNU host triplet for the current FreeM build.
                    969: 
                    970: See @emph{https://wiki.osdev.org/Target_Triplet}.
                    971: 
                    972: @node Intrinsic Functions
                    973: @chapter Intrinsic Functions
                    974: 
                    975: @menu
                    976: * $ASCII()::                            Return ASCII code for character in string.
                    977: * $CHAR()::                             Return character for one or more ASCII codes.
                    978: * $DATA()::                             Retrieve definition and characteristics of array node.
                    979: * $EXTRACT()::                          Return a substring of a string.
                    980: * $FIND()::                             Find position of substring within string.
                    981: * $FNUMBER()::                          Format a number according to formatting codes.
                    982: * $GET()::                              Return value of glvn or a default if undefined.
                    983: * $INSTANCEOF()::                       Determine if lvn is an instance of a class.
                    984: * $JUSTIFY()::                          Right-justify a string based on specified length.
                    985: * $LENGTH()::                           Return length or delimiter-based piece count of string.
                    986: * $NAME()::                             Return canonical name from string representation of glvn.
                    987: * $NEXT()::                             Return next numeric subscript following given glvn.
                    988: * $ORDER()::                            Return next subscript at same level of specified glvn.
                    989: * $PIECE()::                            Return one or more delimited pieces of a string.
                    990: * $QLENGTH()::                          Return subscript count of glvn.
                    991: * $QSUBSCRIPT()::                       Return a specified subscript from glvn.
                    992: * $QUERY()::                            Return next subscript of specified glvn.
                    993: * $RANDOM()::                           Return pseudorandom integer up to a maximum value.
                    994: * $REVERSE()::                          Reverse a string.
                    995: * $SELECT()::                           Return value from first true condition in list of expressions.
                    996: * $STACK()::                            Return information about the program stack.
                    997: * $TEXT()::                             Return line of code from a routine.
                    998: * $TRANSLATE()::                        Substitute specified characters in a string.
                    999: * $TYPE()::                             Return class of the specified lvn.
                   1000: * $VIEW()::                             Retrieve implementation-specific information.
                   1001: * $ZBOOLEAN()::                         Perform boolean operations on numeric arguments.
                   1002: * $ZCALL()::                            Unknown.
                   1003: * $ZCRC()::                             Generate checksum of a string argument.
                   1004: * $ZDATA()::                            Unknown.
                   1005: * $ZDATE()::                            Convert @code{@ref{$HOROLOG}} string into human-readable date.
                   1006: * $ZEDIT()::                            Unknown.
                   1007: * $ZHOROLOG()::                         Convert date/time values to @code{@ref{$HOROLOG}} format.
                   1008: * $ZKEY()::                             Unknown.
                   1009: * $ZLENGTH()::                          Unknown.
                   1010: * $ZLSD()::                             Compute Levenshtein distance between two arguments.
                   1011: * $ZM()::                               Unknown.
                   1012: * $ZNAME()::                            Unknown.
                   1013: * $ZNEXT()::                            Unknown.
                   1014: * $ZORDER()::                           Unknown.
                   1015: * $ZPIECE()::                           Unknown.
                   1016: * $ZPREVIOUS()::                        Unknown.
                   1017: * $ZREPLACE()::                         Replace all instances of a substring within a string.
                   1018: * $ZSYNTAX()::                          Perform syntax check on string argument.
                   1019: * $ZTIME()::                            Convert a @code{@ref{$HOROLOG}} string into human-readable time.
                   1020: @end menu
                   1021: 
                   1022: @node $ASCII()
                   1023: @section $ASCII
                   1024: @cindex $ASCII
                   1025: @cindex intrinsic functions, $ASCII
                   1026: 
                   1027: Returns the ASCII code (in decimal) for one character in a string.
                   1028: 
                   1029: @example
                   1030: SET RESULT=$ASCII(@emph{<string>}[,@emph{<index>}])
                   1031: @end example
                   1032: 
                   1033: 
                   1034: If @emph{<index>} is not supplied, @code{$ASCII} will return the ASCII code of the first character. Otherwise, returns the ASCII code of the character at position @emph{<index>}.
                   1035: 
                   1036: @node $CHAR()
                   1037: @section $CHAR
                   1038: @cindex $CHAR
                   1039: @cindex intrinsic functions, $CHAR
                   1040: 
                   1041: Returns a string of characters corresponding to a list of ASCII codes.
                   1042: 
                   1043: @example
                   1044: SET RESULT=$CHAR(@emph{<ascii-code>}[,@emph{<ascii-code>},...])
                   1045: @end example
                   1046: 
                   1047: @node $DATA()
                   1048: @section $DATA
                   1049: @cindex $DATA
                   1050: @cindex intrinsic functions, $DATA
                   1051: 
                   1052: Returns a numeric value 0, 1, 10, or 11, depending on whether a referenced node is defined, has data, or has children:
                   1053: 
                   1054: @example
                   1055: SET RESULT=$DATA(@emph{<node>})
                   1056: @end example
                   1057: 
                   1058: The return values are as follows:
                   1059: 
                   1060: @example
                   1061: 0: @emph{<node>} is undefined
                   1062: 1: @emph{<node>} has data but no children
                   1063: 10: @emph{<node>} has children but no data
                   1064: 11: @emph{<node>} has children and data
                   1065: @end example
                   1066: 
                   1067: @node $EXTRACT()
                   1068: @section $EXTRACT
                   1069: @cindex $EXTRACT
                   1070: @cindex intrinsic functions, $EXTRACT
                   1071: 
                   1072: Extracts a substring of a string.
                   1073: 
                   1074: The first argument is the source string.
                   1075: 
                   1076: The optional second argument specifies the starting position of the substring to extract, and defaults to @code{1}.
                   1077: 
                   1078: The optional third argument specifies the ending position of the substring to extract, and defaults to the value of the second argument, or @code{1}.
                   1079: 
                   1080: This example will extract the string @emph{FreeM} into the local variable @code{M}.
                   1081: 
                   1082: @example
                   1083: SET NAME="FreeM is the best!"
                   1084: SET M=$EXTRACT(NAME,1,5)
                   1085: @end example
                   1086: 
                   1087: It is also possible to use @code{$EXTRACT} on the left-hand side of a @code{SET} assignment in order to modify a substring:
                   1088: 
                   1089: @example
1.22      snw      1090: DEFAULT.USER> SET FOO="ABCDEFG"
1.1       snw      1091: 
                   1092: 
1.22      snw      1093: DEFAULT.USER> SET $EXTRACT(FOO,1,3)="XYZ"
1.1       snw      1094: 
                   1095: 
1.22      snw      1096: DEFAULT.USER> WRITE FOO
1.1       snw      1097: 
                   1098: XYZDEFG
                   1099: @end example
                   1100: 
                   1101: @node $FIND()
                   1102: @section $FIND
                   1103: @cindex $FIND
                   1104: @cindex intrinsic functions, $FIND
                   1105: 
                   1106: Finds the character immediately following the first occurence of a substring within a string.
                   1107: 
                   1108: The first argument is the source string.
                   1109: 
                   1110: The second argument is the substring to be located.
                   1111: 
                   1112: The optional third argument indicates the position within the source string at which to begin searching.
                   1113: 
                   1114: @node $FNUMBER()
                   1115: @section $FNUMBER
                   1116: @cindex $FNUMBER
                   1117: @cindex intrinsic functions, $FNUMBER
                   1118: 
                   1119: Formats a number according to a particular set of formatting codes.
                   1120: 
                   1121: The first argument is the number to format.
                   1122: 
1.22      snw      1123: The second argument is the series of formatting codes:
                   1124: 
                   1125: @table @asis
                   1126: @item 'P' or 'p'
                   1127: Will display negative numbers within parentheses instead of showing a minus sign.
                   1128: @item , (comma)
                   1129: Will add commas as thousands separators.
                   1130: @item +
                   1131: Will include a plus sign for positive numbers. Not compatible with 'P' or 'p'.
                   1132: @item -
                   1133: Will remove the minus sign from negative numbers. Not compatible with 'p' or 'P'.
                   1134: @item 't' or 'T'
                   1135: Will place the sign after the number instead of before the number.
1.23      snw      1136: @end table
1.22      snw      1137: 
                   1138: The optional third argument is a number indicating how many digits to which the fractional part of the number will be zero-padded.
1.1       snw      1139: 
                   1140: @node $GET()
                   1141: @section $GET
                   1142: @cindex $GET
                   1143: @cindex intrinsic functions, $GET
                   1144: 
                   1145: Returns the value of a local, global, or SSVN if the specified item is defined, or a default value otherwise.
                   1146: 
                   1147: The first argument is the local, global, or SSVN to be examined.
                   1148: 
                   1149: The optional second argument is the default value to be returned if the referenced item is undefined, and defaults to the empty string.
                   1150: 
                   1151: @node $INSTANCEOF()
                   1152: @section $INSTANCEOF
                   1153: @cindex $INSTANCEOF
                   1154: @cindex intrinsic functions, $INSTANCEOF
                   1155: @cindex object functions, $INSTANCEOF
                   1156: 
                   1157: Returns @code{1} if the specified @emph{lvn} is an instance of class @emph{class}, or @code{0} otherwise.
                   1158: 
                   1159: The first argument is a string representing a valid FreeM local variable.
                   1160: 
                   1161: The second argument is a string representing a valid FreeM class.
                   1162: 
                   1163: @example
1.22      snw      1164: DEFAULT.USER> N STR=$$^%STRING
1.1       snw      1165: 
1.22      snw      1166: DEFAULT.USER> W $INSTANCEOF("STR","^%STRING")
1.1       snw      1167: 1
                   1168: @end example
                   1169: 
                   1170: @node $JUSTIFY()
                   1171: @section $JUSTIFY
                   1172: @cindex $JUSTIFY
                   1173: @cindex intrinsic functions, $JUSTIFY
                   1174: 
                   1175: Right-justifies a string based on a specified fixed length.
                   1176: 
                   1177: The first argument is the source string.
                   1178: 
                   1179: The second argument is the character length of the output.
                   1180: 
                   1181: The optional third argument controls the number of fractional digits to be included in the output, and defaults to the number of digits specified in the first argument.
                   1182: 
                   1183: @node $LENGTH()
                   1184: @section $LENGTH
                   1185: @cindex $LENGTH
                   1186: @cindex intrinsic functions, $LENGTH
                   1187: 
                   1188: Returns the length of a string, or the number of items in a list delimited by a specified character (as used by @code{@ref{$PIECE()}}).
                   1189: 
                   1190: The first argument is the source string.
                   1191: 
                   1192: The optional second argument is the list delimiter to be used. When this argument is omitted, the length of the string in characters is returned.
                   1193: 
                   1194: @node $NAME()
                   1195: @section $NAME
                   1196: @cindex $NAME
                   1197: @cindex intrinsic functions, $NAME
                   1198: 
                   1199: Returns the canonical name reference along with some or all of its subscripts.
                   1200: 
                   1201: The first argument is the source name.
                   1202: 
                   1203: The optional second argument indicates the maximum subscript count to be returned, and defaults to the subscript count of the source name.
                   1204: 
                   1205: @node $NEXT()
                   1206: @section $NEXT
                   1207: @cindex $NEXT
                   1208: @cindex intrinsic functions, $NEXT
                   1209: 
1.25      snw      1210: Deprecated. Use @code{$ORDER} instead.
                   1211: 
1.1       snw      1212: @node $ORDER()
                   1213: @section $ORDER
                   1214: @cindex $ORDER
                   1215: @cindex intrinsic functions, $ORDER
                   1216: 
1.25      snw      1217: Returns the previous subscript or next subscript in a local, global, or a subset of structured system variables.
                   1218: 
                   1219: The first argument is the subscripted local, global, or SSVN.
                   1220: 
                   1221: The optional second argument can be @code{1} to retrieve the next subscript, or @code{-1} to return the previous.
                   1222: 
1.1       snw      1223: @node $PIECE()
                   1224: @section $PIECE
                   1225: @cindex $PIECE
                   1226: @cindex intrinsic functions, $PIECE
                   1227: 
                   1228: @emph{Syntax}
                   1229: 
                   1230: @code{$PIECE(@emph{s},@emph{d}[,@emph{n}[,@emph{end}]])}
                   1231: 
                   1232: Accesses the @code{n}th through @code{end} @code{d}-delimited pieces of string @code{s}.
                   1233: 
                   1234: The first argument is the string to be evaluated.
                   1235: 
                   1236: The second argument is the delimiter to be used.
                   1237: 
                   1238: The optional third argument is the first @code{d}-delimited piece to access, and defaults to @code{1}.
                   1239: 
                   1240: The optional fourth argument is the final @code{d}-delimited piece to access, and defaults to the value of the third argument (@code{n}).
                   1241: 
                   1242: Can be used on the left-hand side of an expression in order to @code{@ref{SET}} a value into a @code{d}-delimited piece of @code{s}, as in:
                   1243: 
                   1244: @example
                   1245: ; ^jpw="this^is^a^piece"
                   1246: SET $PIECE(^jpw,"^",2)="isn't" ; => "this^isn't^a^piece"
                   1247: @end example
                   1248: 
                   1249: @node $QLENGTH()
                   1250: @section $QLENGTH
                   1251: @cindex $QLENGTH
                   1252: @cindex intrinsic functions, $QLENGTH
                   1253: 
                   1254: @emph{Syntax}
                   1255: 
                   1256: @example
                   1257: @code{$QLENGTH(@emph{expr V glvn})}
                   1258: @end example
                   1259: 
                   1260: Returns the number of subscripts in @emph{glvn}.
                   1261: 
                   1262: @emph{Example}
                   1263: @example
                   1264: @code{SET SUBCT=$QLENGTH("^GBL(1,2,3)") ; => 3}
                   1265: @end example
                   1266: 
                   1267: @node $QSUBSCRIPT()
                   1268: @section $QSUBSCRIPT
                   1269: @cindex $QSUBSCRIPT
                   1270: @cindex intrinsic functions, $QSUBSCRIPT
                   1271: 
                   1272: @emph{Syntax}
                   1273: 
                   1274: @example
                   1275: @code{$QSUBSCRIPT(@emph{expr V glvn},@emph{expr V n})}
                   1276: @end example
                   1277: 
                   1278: Returns the @emph{n}th subscript of @emph{glvn}.
                   1279: 
                   1280: @emph{Example}
                   1281: 
                   1282: @example
                   1283: @code{SET SUB=$QSUBSCRIPT("^GBL(1,2,3)",2) ; => 2}
                   1284: @end example
                   1285: 
                   1286: @node $QUERY()
                   1287: @section $QUERY
                   1288: @cindex $QUERY
                   1289: @cindex intrinsic functions, $QUERY
                   1290: 
                   1291: Returns the next subscripted reference in a global.
                   1292: 
                   1293: @emph{Syntax}
                   1294: 
                   1295: @example
                   1296: @code{$QUERY(@emph{glvn})}
                   1297: @end example
                   1298: 
                   1299: @emph{Example}
                   1300: 
                   1301: We will assume the following data structure exists:
                   1302: @example
                   1303: ^jpw(1)=1
                   1304: ^jpw(1,2)="foo"
                   1305: ^jpw(2)=3
                   1306: ^jpw(3)=""
                   1307: @end example
                   1308: 
                   1309: The following code will retrieve the next subscripted name after @code{^jpw(1)}:
                   1310: 
                   1311: @example
                   1312: @code{SET NEXTNAM=$QUERY(^jpw(1)) ; => ^jpw(1,2)}
                   1313: @end example
                   1314: 
                   1315: @node $RANDOM()
                   1316: @section $RANDOM
                   1317: @cindex $RANDOM
                   1318: @cindex intrinsic functions, $RANDOM
                   1319: 
                   1320: @emph{Syntax}
                   1321: 
                   1322: @example
                   1323: $RANDOM(@emph{max})
                   1324: @end example
                   1325: 
                   1326: Returns a pseudo-random integer in the range of @code{0..@emph{max} - 1} 
                   1327: 
                   1328: @node $REVERSE()
                   1329: @section $REVERSE
                   1330: @cindex $REVERSE
                   1331: @cindex intrinsic functions, $REVERSE
                   1332: 
                   1333: @emph{Syntax}
                   1334: 
                   1335: @example
                   1336: $REVERSE(@emph{s})
                   1337: @end example
                   1338: 
                   1339: Returns the reverse of string @emph{s}.
                   1340: 
                   1341: @emph{Example}
                   1342: 
                   1343: @example
                   1344: SET FOO=$REVERSE("ABC") ; => CBA
                   1345: @end example
                   1346: 
                   1347: @node $SELECT()
                   1348: @section $SELECT
                   1349: @cindex $SELECT
                   1350: @cindex intrinsic functions, $SELECT
                   1351: 
                   1352: Returns a value corresponding to the first true condition in a list of conditional expressions. Each argument is an expression, followed by a colon, followed by an expression whose value will be returned if the first expression is true. If no expressions are true, error condition @code{M4} is raised.
                   1353: 
                   1354: @emph{Example}
                   1355: 
                   1356: @example
                   1357: SET FOO=$SELECT(1=2:"math is broken",1=1:"the world makes sense") ; => "the world makes sense"
                   1358: @end example
                   1359: 
                   1360: @node $STACK()
                   1361: @section $STACK
                   1362: @cindex $STACK
                   1363: @cindex intrinsic functions, $STACK
                   1364: 
                   1365: Returns information about the program execution stack. The @code{$STACK} intrinsic function has both a one-argument form and a two-argument form.
                   1366: 
                   1367: @emph{Syntax (One-Argument)}
                   1368: 
                   1369: @example
                   1370:  $STACK(@emph{<num>})
                   1371: @end example
                   1372: 
                   1373: If @emph{num} is @code{0}, returns the command with which this FreeM instance was invoked.
                   1374: 
                   1375: If @emph{num} is @code{-1}, returns the current program execution stack level.
                   1376: 
                   1377: If @emph{num} represents a valid program execution stack depth above @code{0}, returns one of the following values indicating the reason for which the referenced program execution stack level was created:
                   1378: 
                   1379: @table @asis
                   1380: 
                   1381: @item @code{$$}
                   1382: If @code{$STACK(@emph{<num>})="$$"}, program execution stack level @code{num} was created as the result of an extrinsic function call
                   1383: 
                   1384: @item @emph{<m-command>}
                   1385: If @code{$STACK(@emph{<num>})} returns a valid M command, the referenced program execution stack level was created as a result of the @emph{m-command} command.
                   1386: 
                   1387: @end table
                   1388: 
                   1389: @emph{Syntax (Two-Argument})
                   1390: 
                   1391: @example
                   1392:  $STACK(@emph{<num>},"[ECODE|MCODE|PLACE]")
                   1393: @end example
                   1394: 
                   1395: Returns the error codes, M program code, or entryref applicable to the action that created program execution stack level @emph{num}.
                   1396: 
                   1397: @node $TEXT()
                   1398: @section $TEXT
                   1399: @cindex $TEXT
                   1400: @cindex intrinsic functions, $TEXT
                   1401: 
                   1402: Returns a line of code from a routine.
                   1403: 
                   1404: @node $TRANSLATE()
                   1405: @section $TRANSLATE
                   1406: @cindex $TRANSLATE
                   1407: @cindex intrinsic functions, $TRANSLATE
                   1408: 
1.25      snw      1409: Replaces characters in a string.
                   1410: 
                   1411: The first argument is a string expression representing the text to be changed.
                   1412: 
                   1413: The second argument is a list of characters to replace.
                   1414: 
                   1415: The third argument is a list of characters to use as the replacements for the characters in the second argument.
                   1416: 
                   1417: @emph{Example}
                   1418: 
                   1419: @example
                   1420:  DEFAULT.USER> W $TRANSLATE("twig","wt","rb")
                   1421:  brig
                   1422: @end example
                   1423: 
1.1       snw      1424: @node $TYPE()
                   1425: @section $TYPE
                   1426: @cindex $TYPE
                   1427: @cindex intrinsic functions, $TYPE
                   1428: @cindex object functions, $TYPE
                   1429: 
                   1430: Returns a string giving the class of the object specified in the parameter.
                   1431: 
                   1432: @xref{Object-Oriented Programming}
                   1433: 
                   1434: @node $VIEW()
                   1435: @section $VIEW
                   1436: @cindex $VIEW
                   1437: @cindex intrinsic functions, $VIEW
                   1438: 
                   1439: @node $ZBOOLEAN()
                   1440: @section $ZBOOLEAN
                   1441: @cindex $ZBOOLEAN
                   1442: @cindex intrinsic functions, $ZBOOLEAN
                   1443: @cindex intrinsic functions, implementation-specific
                   1444: 
                   1445: 
                   1446: Performs @emph{boolean-operation} on numeric arguments @emph{A} and @emph{B}.
                   1447: 
                   1448: @emph{Syntax}
                   1449: 
                   1450: @example
                   1451: SET RESULT=$ZBOOLEAN(@emph{A},@emph{B},@emph{boolean-operation})
                   1452: @end example
                   1453: 
                   1454: @code{$ZBOOLEAN} Operations (@emph{boolean-operation} values)
                   1455: 
                   1456: @table @code
                   1457: @item 0
                   1458: Always @emph{false}
                   1459: @item 1
                   1460: @code{A AND B}
                   1461: @item 2
                   1462: @code{A AND NOT B}
                   1463: @item 3
                   1464: @code{A}
                   1465: @item 4
                   1466: @code{NOT A AND B}
                   1467: @item 5
                   1468: @code{B}
                   1469: @item 6
                   1470: @code{A XOR B}
                   1471: @item 7
                   1472: @code{A OR B}
                   1473: @item 8
                   1474: @code{A NOR B}
                   1475: @item 9
                   1476: @code{A EQUALS B}
                   1477: @item 10
                   1478: @code{NOT B}
                   1479: @item 11
                   1480: @code{A OR NOT B}
                   1481: @item 12
                   1482: @code{NOT A}
                   1483: @item 13
                   1484: @code{NOT A OR B}
                   1485: @item 14
                   1486: @code{A NAND B}
                   1487: @item 15
                   1488: Always @emph{true}
                   1489: @end table
                   1490: 
                   1491: @node $ZCALL()
                   1492: @section $ZCALL
                   1493: @cindex $ZCALL
                   1494: @cindex intrinsic functions, $ZCALL
                   1495: @cindex intrinsic functions, implementation-specific
                   1496: 
1.26      snw      1497: Purpose unknown.
                   1498: 
1.1       snw      1499: @node $ZCRC()
                   1500: @section $ZCRC
                   1501: @cindex $ZCRC
                   1502: @cindex intrinsic functions, $ZCRC
                   1503: @cindex intrinsic functions, implementation-specific
                   1504: 
                   1505: Returns a checksum of @code{arg1}.
                   1506: 
                   1507: @emph{Syntax}
                   1508: 
                   1509: @code{$ZCRC(@emph{arg1})}
                   1510: 
                   1511: @code{SET VAR=$ZCRC("MUMPS") ; => 86}
                   1512: 
                   1513: @node $ZDATA()
                   1514: @section $ZDATA
                   1515: @cindex $ZDATA
                   1516: @cindex intrinsic functions, $ZDATA
                   1517: @cindex intrinsic functions, implementation-specific
                   1518: 
1.26      snw      1519: Purpose unknown.
                   1520: 
1.1       snw      1521: @node $ZDATE()
                   1522: @section $ZDATE
                   1523: @cindex $ZDATE
                   1524: @cindex intrinsic functions, $ZDATE
                   1525: @cindex intrinsic functions, implementation-specific
                   1526: 
                   1527: Converts a @code{@ref{$HOROLOG}} string into a human-readable date.
                   1528: 
                   1529: @emph{Syntax}
                   1530: 
                   1531: @example
                   1532: SET VAR=$ZDATE($H[,@emph{<format-string>}])
                   1533: @end example
                   1534: 
                   1535: The optional @emph{<format-string>} follows the same rules as the UNIX @code{strftime} function. If @emph{<format-string>} is omitted, the value of @code{^$SYSTEM("ZDATE_FORMAT")} is used (typically @code{%x}).
                   1536: 
                   1537: @xref{^$SYSTEM}
                   1538: 
                   1539: @node $ZEDIT()
                   1540: @section $ZEDIT
                   1541: @cindex $ZEDIT
                   1542: @cindex intrinsic functions, $ZEDIT
                   1543: @cindex intrinsic functions, implementation-specific
                   1544: 
1.26      snw      1545: Purpose unknown.
                   1546: 
1.1       snw      1547: @node $ZHOROLOG()
                   1548: @section $ZHOROLOG
                   1549: @cindex $ZHOROLOG
                   1550: @cindex intrinsic functions, $ZHOROLOG
                   1551: @cindex intrinsic functions, implementation-specific
                   1552: 
                   1553: Converts date and/or time values producible by @code{@ref{$ZDATE()}} or @code{@ref{$ZTIME()}} to @code{@ref{$HOROLOG}} format.
                   1554: 
                   1555: @emph{Syntax}
                   1556: 
                   1557: @example
                   1558: $ZHOROLOG(@emph{<date-value>},@emph{<format-string>})
                   1559: @end example
                   1560: 
                   1561: @emph{<date-value>} is a date or time string compatible with the formats from @code{@ref{$ZDATE()}} or @code{@ref{$ZTIME}}.
                   1562: 
                   1563: @emph{<format-string>} is a format string of the same format as used by the @code{strptime(3)} UNIX function.
                   1564: 
                   1565: @node $ZKEY()
                   1566: @section $ZKEY
                   1567: @cindex $ZKEY
                   1568: @cindex intrinsic functions, $ZKEY
                   1569: @cindex intrinsic functions, implementation-specific
                   1570: 
1.26      snw      1571: Purpose unknown.
                   1572: 
1.1       snw      1573: @node $ZLENGTH()
                   1574: @section $ZLENGTH
                   1575: @cindex $ZLENGTH
                   1576: @cindex intrinsic functions, $ZLENGTH
                   1577: @cindex intrinsic functions, implementation-specific
                   1578: 
1.26      snw      1579: Purpose unknown.
                   1580: 
1.1       snw      1581: @node $ZLSD()
                   1582: @section $ZLSD
                   1583: @cindex $ZLSD
                   1584: @cindex intrinsic functions, $ZLSD
                   1585: @cindex intrinsic functions, implementation-specific
                   1586: 
                   1587: Returns the Levenshtein distance between two arguments. The Levenshtein distance represents the minimum number of edits needed to change the first argument into the second argument.
                   1588: 
                   1589: @emph{Syntax}
                   1590: 
                   1591: @code{SET VAR=$ZLSD(@emph{arg1},@emph{arg2})}
                   1592: 
                   1593: @emph{Example}
                   1594: 
                   1595: @code{SET VAR=$ZLSD("KITTENS","MITTENS") ; => 1}
                   1596: 
                   1597: @node $ZM()
                   1598: @section $ZM
                   1599: @cindex $ZM
                   1600: @cindex intrinsic functions, $ZM
                   1601: @cindex intrinsic functions, implementation-specific
                   1602: 
                   1603: @node $ZNAME()
                   1604: @section $ZNAME
                   1605: @cindex $ZNAME
                   1606: @cindex intrinsic functions, $ZNAME
                   1607: @cindex intrinsic functions, implementation-specific
                   1608: 
1.26      snw      1609: Purpose unknown.
                   1610: 
1.1       snw      1611: @node $ZNEXT()
                   1612: @section $ZNEXT
                   1613: @cindex $ZNEXT
                   1614: @cindex intrinsic functions, $ZNEXT
                   1615: @cindex intrinsic functions, implementation-specific
                   1616: 
1.26      snw      1617: Purpose unknown.
                   1618: 
1.1       snw      1619: @node $ZORDER()
                   1620: @section $ZORDER
                   1621: @cindex $ZORDER
                   1622: @cindex intrinsic functions, $ZORDER
                   1623: @cindex intrinsic functions, implementation-specific
                   1624: 
1.26      snw      1625: Purpose unknown.
                   1626: 
1.1       snw      1627: @node $ZPIECE()
                   1628: @section $ZPIECE
                   1629: @cindex $ZPIECE
                   1630: @cindex intrinsic functions, $ZPIECE
                   1631: @cindex intrinsic functions, implementation-specific
                   1632: 
1.26      snw      1633: Purpose unknown.
                   1634: 
1.1       snw      1635: @node $ZPREVIOUS()
                   1636: @section $ZPREVIOUS
                   1637: @cindex $ZPREVIOUS
                   1638: @cindex intrinsic functions, $ZPREVIOUS
                   1639: @cindex intrinsic functions, implementation-specific
                   1640: 
1.26      snw      1641: Purpose unknown.
                   1642: 
1.1       snw      1643: @node $ZREPLACE()
                   1644: @section $ZREPLACE
                   1645: @cindex $ZREPLACE
                   1646: @cindex intrinsic functions, $ZREPLACE
                   1647: @cindex intrinsic functions, implementation-specific
                   1648: 
                   1649: Replaces all instances of @code{arg2} with @code{arg3} in string @code{arg1}.
                   1650: 
                   1651: @emph{Syntax}
                   1652: @code{$ZREPLACE(@emph{arg1},@emph{arg2},@emph{arg3})}
                   1653: 
                   1654: @emph{Example}
                   1655: 
                   1656: @code{SET VAR=$ZREPLACE("CAT","C","B") ; => BAT}
                   1657: 
                   1658: @node $ZSYNTAX()
                   1659: @section $ZSYNTAX
                   1660: @cindex $ZSYNTAX
                   1661: @cindex intrinsic functions, $ZSYNTAX
                   1662: @cindex intrinsic functions, implementation-specific
                   1663: 
                   1664: @code{$ZSYNTAX} performs a very basic syntax check on @emph{expr V mcode}. Checks only for illegal commands, mismatched brackets, mismatched quotes, missing or surplus arguments, or surplus commas.
                   1665: 
                   1666: @emph{Syntax}
                   1667: @example
                   1668: $ZSYNTAX(@emph{expr V mcode})
                   1669: @end example
                   1670: 
                   1671: If no syntax error is found, returns the empty string.
                   1672: 
                   1673: If a syntax error is found, returns a number indicating the position in @emph{expr V mcode} at which the error was found, followed by a comma, and the FreeM error code that was found.
                   1674: 
                   1675: @node $ZTIME()
                   1676: @section $ZTIME
                   1677: @cindex $ZTIME
                   1678: @cindex intrinsic functions, $ZTIME
                   1679: @cindex intrinsic functions, implementation-specific
                   1680: 
                   1681: Converts a @code{@ref{$HOROLOG}} string into a human-readable time.
                   1682: 
                   1683: @emph{Syntax}
                   1684: 
                   1685: @example
                   1686: SET VAR=$ZTIME($H[,@emph{<format-string>}])
                   1687: @end example
                   1688: 
                   1689: The optional @emph{<format-string>} follows the same rules as the UNIX @code{strftime(3)} function. If @emph{<format-string>} is omitted, the value of @code{^$SYSTEM("ZTIME_FORMAT")} is used (typically @code{%X}).
                   1690: 
                   1691: @node OBJECT Methods
                   1692: @chapter OBJECT Methods
                   1693: 
                   1694: These methods are part of the @code{^%OBJECT} class, from which all FreeM objects ultimately inherit.
                   1695: 
                   1696: Please note that classes may override @code{^%OBJECT} methods (or methods of any class) in order to provide results more fitting to the class's abstraction goals.
                   1697: 
                   1698: @menu
                   1699: * $$TONUMBER::          Returns the canonical numeric representation of the object.
                   1700: * $$TYPE::              Returns the fully-qualified class name of the object.
                   1701: * $$VALUE::             Returns the value of the object.
                   1702: @end menu
                   1703: 
                   1704: @node $$TONUMBER
                   1705: @section $$TONUMBER
                   1706: 
                   1707: Returns (when applicable) a canonical numeric representation of the referenced object.
                   1708: 
                   1709: @emph{Syntax}
                   1710: 
                   1711: @example
                   1712: W $$MYOBJECT.TONUMBER(),!
                   1713: @end example
                   1714: 
                   1715: If no canonical numeric representation of the object is possible, will return the empty string.
                   1716: 
                   1717: @node $$TYPE
                   1718: @section $$TYPE
                   1719: 
                   1720: Returns the fully-qualified class of the referenced object.
                   1721: 
                   1722: @emph{Syntax}
                   1723: 
                   1724: @example
                   1725: W $$MYOBJECT.TYPE()
                   1726: @end example
                   1727: 
                   1728: Note that M variables that are created by non-object-oriented means will be objects of the @code{^%STRING} class.
                   1729: 
                   1730: @node $$VALUE
                   1731: @section $$VALUE
                   1732: 
                   1733: Returns the value of the referenced object.
                   1734: 
                   1735: @emph{Syntax}
                   1736: 
                   1737: @example
                   1738: W $$MYOBJECT.VALUE()
                   1739: @end example
                   1740: 
                   1741: @node STRING Methods
                   1742: @chapter STRING Methods
                   1743: 
                   1744: These are methods inherent to the @code{^%STRING} class, which is the default class for M variables created without specifying a class.
                   1745: 
                   1746: @menu
                   1747: * $$ASCII::             Return the ASCII code of a character within the string.
                   1748: * $$DATA::              Return tree characteristics of the string.
                   1749: * $$DISTANCE::          Determine Levenstein distance between this string and another.
                   1750: * $$EXTRACT::           Return a substring of the string.
                   1751: * $$FIND::              Find the position of a substring within the string.
                   1752: * $$FNUMBER::           Format numbers.
                   1753: * $$JUSTIFY::           Pad the string to specific positions.
                   1754: * $$LENGTH::            Return the length of the string.
                   1755: * $$PIECECOUNT::        Return the count of pieces existing between instances of a delimiter.
                   1756: * $$PIECE::             Return a delimited subset of the string.
                   1757: * $$REPLACE::           Replace instances of a substring within the string.
                   1758: * $$REVERSE::           Reverse the order of characters in the string.
                   1759: * $$TOLOWER::           Return a lowercase version of the string.
                   1760: * $$TOUPPER::           Return an uppercase version of the string.
                   1761: * $$TRANSLATE::         Replace individual characters within the string.
                   1762: @end menu
                   1763: 
                   1764: @node $$ASCII
                   1765: @section $$ASCII
                   1766: 
                   1767: Returns the ASCII code of a character within the string. See @ref{$ASCII()}.
                   1768: 
                   1769: @emph{Syntax}
                   1770: 
                   1771: @example
                   1772: W $$MYOBJECT.ASCII(3)
                   1773: @end example
                   1774: 
                   1775: The above example returns the ASCII code in position 3 of string object @code{MYOBJECT}.
                   1776: 
                   1777: @node $$DATA
                   1778: @section $$DATA
                   1779: 
                   1780: Returns the value of the @code{$DATA} intrinsic function as performed on the value of the object. See @ref{$DATA()}.
                   1781: 
                   1782: @emph{Syntax}
                   1783: 
                   1784: @example
                   1785: W $$MYOBJECT.DATA()
                   1786: @end example
                   1787: 
                   1788: @node $$DISTANCE
                   1789: @section $$DISTANCE
                   1790: 
                   1791: Returns the Levenstein distance between the string and another string. See @ref{$ZLSD()}.
                   1792: 
                   1793: @emph{Syntax}
                   1794: 
                   1795: @example
                   1796: W $$MYOBJECT.DISTANCE("someString")
                   1797: @end example
                   1798: 
                   1799: @node $$EXTRACT
                   1800: @section $$EXTRACT
                   1801: 
                   1802: Returns a substring of the string. See @ref{$EXTRACT()}.
                   1803: 
                   1804: @emph{Syntax}
                   1805: 
                   1806: @example
                   1807: $$<objectName>.EXTRACT(<start>,<end>)
                   1808: @end example
                   1809: 
                   1810: 
                   1811: @node $$FIND
                   1812: @section $$FIND
                   1813: 
1.25      snw      1814: Finds the character immediately following the first occurence of a substring within a string.
                   1815: 
                   1816: The first argument is the substring to be located.
                   1817: 
                   1818: The second argument is the position within the string at which to begin searching.
                   1819: 
                   1820: See @ref{$FIND()}.
                   1821: 
1.1       snw      1822: @node $$FNUMBER
                   1823: @section $$FNUMBER
                   1824: 
1.25      snw      1825: Formats a number according to a set of formatting codes.
                   1826: 
                   1827: The argument is a series of formatting codes. See @ref{$FNUMBER()} for details.
                   1828: 
1.1       snw      1829: @node $$JUSTIFY
                   1830: @section $$JUSTIFY
                   1831: 
1.25      snw      1832: Right-justifies a string based on a specified fixed length.
                   1833: 
                   1834: The first argument is the character length of the output.
                   1835: 
                   1836: The second argument controls the number of fractional digits to be included in the output, and defaults to the number of digits specified in the first argument.
                   1837: 
                   1838: See @ref{$JUSTIFY()} for details.
                   1839: 
1.1       snw      1840: @node $$LENGTH
                   1841: @section $$LENGTH
                   1842: 
1.25      snw      1843: Returns the length of the string.
                   1844: 
1.1       snw      1845: @node $$PIECECOUNT
                   1846: @section $$PIECECOUNT
                   1847: 
1.25      snw      1848: Returns the number of items in a list delimited by the character specified in the argument.
                   1849: 
1.1       snw      1850: @node $$PIECE
                   1851: @section $$PIECE
                   1852: 
1.25      snw      1853: @emph{Syntax}
                   1854: 
                   1855: @code{$PIECE(@emph{d}[,@emph{n}[,@emph{end}]])}
                   1856: 
                   1857: Accesses the @code{n}th through @code{end} @code{d}-delimited pieces of the string.
                   1858: 
                   1859: The first argument is the delimiter to be used.
                   1860: 
                   1861: The optional second argument is the first @code{d}-delimited piece to access, and defaults to @code{1}.
                   1862: 
                   1863: The optional third argument is the final @code{d}-delimited piece to access, and defaults to the value of the third argument (@code{n}).
                   1864: 
                   1865: 
1.1       snw      1866: @node $$REPLACE
                   1867: @section $$REPLACE
                   1868: 
1.25      snw      1869: @emph{Syntax}
                   1870: @code{myString.$$REPLACE(@emph{arg1},@emph{arg2})}
                   1871: 
                   1872: Replaces all instances of @code{arg2} with @code{arg3} in @code{myString}.
                   1873: 
1.1       snw      1874: @node $$REVERSE
                   1875: @section $$REVERSE
                   1876: 
1.25      snw      1877: Returns the reverse of the string.
                   1878: 
1.1       snw      1879: @node $$TOLOWER
                   1880: @section $$TOLOWER
                   1881: 
1.25      snw      1882: Returns an all-lowercase version of the string.
                   1883: 
1.1       snw      1884: @node $$TOUPPER
                   1885: @section $$TOUPPER
                   1886: 
1.25      snw      1887: Returns an all-uppercase version of the string.
                   1888: 
1.1       snw      1889: @node $$TRANSLATE
                   1890: @section $$TRANSLATE
                   1891: 
1.25      snw      1892: Identical to @ref{$TRANSLATE()}, except that the arguments are shifted left by one, and the input string is implicit (the object).
                   1893: 
1.1       snw      1894: @node Commands
                   1895: @chapter Commands
                   1896: @cindex commands
                   1897: 
                   1898: @menu
                   1899: * @@::                                  Execute the following expression as M code.
                   1900: * !::                                   Run an external program or command.
                   1901: * !!::                                  Launch a subshell from FreeM direct mode.
                   1902: * ABLOCK::                              Increment the block counter for one or more event classes.
                   1903: * ASSERT::                              Raise error when a conditional expression evaluates @emph{false}.
                   1904: * ASTART::                              Enable asynchronous event handling for one or more event classes.
                   1905: * ASTOP::                               Disable asynchronous event handling for one or more event classes.
                   1906: * AUNBLOCK::                            Decrement the block counter for one or more event classes.
                   1907: * BREAK::                               Interrupt a running routine to allow interactive debugging.
                   1908: * CLOSE::                               Close an input/output device.
                   1909: * CONST::                               Define a constant that cannot be altered after initial definition.
                   1910: * DO::                                  Transfer program control to one or more subroutines or introduces a new execution level.
                   1911: * ELSE::                                Execute the remainder of a line if @code{@ref{$TEST}} evaluates @emph{false}.
                   1912: * FOR::                                 Repeat execution of a line or block of code.
                   1913: * GOTO::                                Unconditionally transfer program execution to a supplied @emph{entryref}.
                   1914: * HALT::                                Terminate the current FreeM interpreter instance.
                   1915: * HANG::                                Temporarily suspend the running program.
                   1916: * IF::                                  Execute the remainder of a line if a conditional expression evaluates @emph{true}.
                   1917: * JOB::                                 Execute an @emph{entryref} in a child process.
                   1918: * KILL::                                Remove data from a local, global, or structured system variable.
                   1919: * KSUBSCRIPTS::                         Kill only the descendant subscripts of a local, global, global, or structured system variable.
                   1920: * KVALUE::                              Kill only the value of a local, global, or structured system variable.
                   1921: * LOCK::                                Control advisory locking for concurrency control.
                   1922: * MAP::                                 Map a global name to a non-default namespace.
                   1923: * MERGE::                               Merge contents of one local, global, or structured system variable into another.
                   1924: * NEW::                                 Introduce a new scope for a specified local variable or intrinsic special variable or instantiate an object.
                   1925: * OPEN::                                Open a sequential or socket input/output device.
                   1926: * QUIT::                                End execution of the current process level, optionally with return value.
                   1927: * READ::                                Read input from an input/output device.
                   1928: * SET::                                 Set the value of a local variable, global, intrinsic special variable, or structured system variable.
                   1929: * TCOMMIT::                             Commit a transaction.
                   1930: * THEN::                                Preserve @code{@ref{$TEST}} until the end of the current line.
                   1931: * THROW::                               Programmatically raise an error condition.
                   1932: * TROLLBACK::                           Roll back all pending transactions.
                   1933: * TSTART::                              Introduce a new transaction processing level.
                   1934: * UNMAP::                               Remove a mapping of a global to a non-default namespace.
                   1935: * USE::                                 Set the currently-active input/output device.
                   1936: * VIEW::                                Modify FreeM internal parameters.
                   1937: * WATCH::                               Enable or disable watchpoints, or set or clear watchpoints on specified globals, locals, or structured system variables.
                   1938: * WITH::                                Set prefix for future variable references.
                   1939: * WRITE::                               Write output to current input/output device.
                   1940: * XECUTE::                              Interpret string as M code.
                   1941: * ZBREAK::                              Unknown.
                   1942: * ZGO::                                 Unknown.
                   1943: * ZHALT::                               Unknown.
                   1944: * ZINSERT::                             Insert code into routine buffer.
                   1945: * ZJOB::                                Unknown.
                   1946: * ZLOAD::                               Load routine into routine buffer.
                   1947: * ZNEW::                                Unknown.
                   1948: * ZPRINT::                              Print contents of routine buffer.
                   1949: * ZQUIT::                               Unknown.
                   1950: * ZREMOVE::                             Remove code from routine buffer.
                   1951: * ZSAVE::                               Save routine buffer to disk.
                   1952: * ZTRAP::                               Unknown.
                   1953: * ZWRITE::                              Write local variable, global, or structured system variable to @code{@ref{$IO}}.
                   1954: @end menu
                   1955: 
                   1956: @node @@
                   1957: @section @@
                   1958: @cindex @@
                   1959: @cindex commands, @@
                   1960: @cindex commands, implementation-specific
                   1961: @cindex commands, non-standard
                   1962: 
                   1963: Executes FreeM code @emph{expr V mcode}.
                   1964: 
                   1965: @emph{Syntax}
                   1966: 
                   1967: @example
                   1968: @@@emph{expr V mcode}
                   1969: @end example
                   1970: 
                   1971: @emph{Example (Using Variable)}
                   1972: 
                   1973: @example
1.22      snw      1974: DEFAULT.USER> SET FOO="WRITE ""HELLO WORLD"",!"
                   1975: DEFAULT.USER> @@FOO
1.1       snw      1976: 
                   1977: HELLO WORLD
                   1978: 
1.22      snw      1979: DEFAULT.USER>
1.1       snw      1980: @end example
                   1981: 
                   1982: @emph{Example (Using String Literal)}
                   1983: 
                   1984: @example
1.22      snw      1985: DEFAULT.USER> @@"WRITE ""HELLO WORLD"",!"
1.1       snw      1986: 
                   1987: HELLO WORLD
                   1988: 
1.22      snw      1989: DEFAULT.USER>
1.1       snw      1990: @end example
                   1991: 
                   1992: @emph{Example (Using Indirection)}
                   1993: 
                   1994: @example
1.22      snw      1995: DEFAULT.USER> SET FOO="BAR"
1.1       snw      1996: 
1.22      snw      1997: DEFAULT.USER> SET BAR="WRITE ""HELLO WORLD"",!"
1.1       snw      1998: 
1.22      snw      1999: DEFAULT.USER> @@@@FOO
1.1       snw      2000: 
                   2001: HELLO WORLD
                   2002: 
1.22      snw      2003: DEFAULT.USER>
1.1       snw      2004: @end example
                   2005: 
                   2006: 
                   2007: @node !
                   2008: @section !
                   2009: @cindex !
                   2010: @cindex commands, !
                   2011: @cindex commands, external
                   2012: @cindex commands, non-standard
                   2013: @emph{FreeM Extension}
                   2014: 
                   2015: Invokes a shell to run @emph{<external-command>} from within FreeM. This temporarily disables @command{SIGALRM} handling in FreeM, which may interrupt the use of event-driven M programming commands including @command{ESTART} and @command{ESTOP}.
                   2016: 
                   2017: If the @command{<} character is supplied immediately preceding @emph{<external-command>}, FreeM will append the contents of M local variable @code{%} to @emph{<external-command>} as standard input.
                   2018: 
                   2019: If the @command{>} character is supplied immediately preceding @emph{<external-command>}, FreeM will take the standard output stream of @emph{<external-command>} and store it in M local variable @code{%}.
                   2020: 
                   2021: @code{%} contains the number of lines in the input or output. @code{%(1)..%(@emph{n})} contains the data for lines 1-@emph{n}.
                   2022: 
                   2023: @node !!
                   2024: @section !!
                   2025: @cindex !!
                   2026: @cindex commands, !!
                   2027: @cindex commands, external
                   2028: @cindex commands, non-standard
                   2029: @emph{FreeM Extension}
                   2030: 
                   2031: Launches a subshell within the FreeM direct mode, allowing the user to run operating system commands.
                   2032: 
                   2033: @example
1.22      snw      2034: DEFAULT.USER> !!
1.1       snw      2035: 
                   2036: Type Ctrl-D to exit from the shell
                   2037: $ uname -a
                   2038: Linux hesperos 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
                   2039: $ exit
                   2040: 
1.22      snw      2041: DEFAULT.USER> 
1.1       snw      2042: @end example
                   2043: 
                   2044: 
                   2045: @node ABLOCK
                   2046: @section ABLOCK
                   2047: @cindex ABLOCK
                   2048: @cindex commands, ABLOCK
                   2049: 
                   2050: Increments the event block counter for one or more event classes. While the block counter for an event class is greater than zero, registered event handlers for that event class will not execute, and will instead be queued for later execution once the block counter reaches zero (all blocks removed).
                   2051: 
                   2052: An implicit @code{ABLOCK} on all event classes occurs when an event handler subroutine is executing. As soon as a @code{QUIT} is reached within an event handler, an implicit @code{ABLOCK} will occur.
                   2053: 
                   2054: @emph{Syntax}
                   2055: 
                   2056: @example
                   2057:   ABLOCK@emph{:postcondition}
                   2058: @end example
                   2059: 
                   2060: In its argumentless form, @code{ABLOCK} increments the block counter for @emph{all} event classes, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2061: 
                   2062: @example
                   2063:   ABLOCK@emph{:postcondition} @emph{evclass1}...,@emph{evclassN}
                   2064: @end example
                   2065: 
                   2066: In its inclusive form, @code{ABLOCK} increments the block counters for all event classes named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2067: 
                   2068: @example
                   2069:   ABLOCK@emph{:postcondition} (@emph{evclass1}...,@emph{evclassN}
                   2070: @end example
                   2071: 
                   2072: In its exclusive form, @code{ABLOCK} increments the block counters for all event classes @emph{except for} those named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2073: 
                   2074: @node ASSERT
                   2075: @section ASSERT
                   2076: @cindex ASSERT
                   2077: @cindex commands, ASSERT
                   2078: @cindex commands, debugging
                   2079: @cindex commands, implementation-specific
                   2080: @cindex commands, non-standard
                   2081: @emph{FreeM Extension}
                   2082: 
                   2083: Triggers error @code{ASSERT} if the supplied truth-valued expression @emph{tvexpr} is @emph{false} (@emph{1} is @emph{true}, and @emph{0} is @emph{false}), and that the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2084: 
                   2085: The @code{ASSERT} error is catchable whether using standard-style, FreeM-style, or DSM 2.0-style error processing.
                   2086: 
                   2087: @emph{Syntax}
                   2088: 
                   2089: @example
                   2090:  ASSERT@emph{:postcondition} @emph{<tvexpr>}
                   2091: @end example
                   2092: 
                   2093: @emph{Example}
                   2094: 
                   2095: @example
1.22      snw      2096: DEFAULT.USER> SET DEBUG=1
1.1       snw      2097: 
                   2098: 
1.22      snw      2099: DEFAULT.USER> ASSERT:DEBUG 1=1
1.1       snw      2100: 
                   2101: 
1.22      snw      2102: DEFAULT.USER> ASSERT:DEBUG 1=0
1.1       snw      2103:  
                   2104:  
                   2105: >> Error ZASSERT:  programmer assertion failed in SYSTEM::^%SYSINIT  [$STACK = 0]
                   2106: >> ASSERT:DEBUG 1=0
                   2107:                    ^
                   2108: @end example
                   2109: 
                   2110: @node ASTART
                   2111: @section ASTART
                   2112: @cindex ASTART
                   2113: @cindex commands, ASTART
                   2114: 
                   2115: Enables asynchronous event handling for one or more event classes.
                   2116: 
                   2117: @emph{Syntax}
                   2118: 
                   2119: @example
                   2120:   ASTART@emph{:postcondition}
                   2121: @end example
                   2122: 
                   2123: In its argumentless form, @code{ASTART} enables asynchronous event handling for all event classes, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2124: 
                   2125: @example
                   2126:   ASTART@emph{:postcondition} @emph{evclass1}...,@emph{evclassN}
                   2127: @end example
                   2128: 
                   2129: In its inclusive form, @code{ASTART} enables asynchronous event handling for all event classes named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2130: 
                   2131: @example
                   2132:   ASTART@emph{:postcondition} (@emph{evclass1}...,@emph{evclassN})
                   2133: @end example
                   2134: 
                   2135: In its exclusive form, @code{ASTART} enables asynchronous event handling for all event classes @emph{except for} those named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2136: 
                   2137: @node ASTOP
                   2138: @section ASTOP
                   2139: @cindex ASTOP
                   2140: @cindex commands, ASTOP
                   2141: 
                   2142: Disables asynchronous event handling for one or more event classes.
                   2143: 
                   2144: @emph{Syntax}
                   2145: 
                   2146: @example
                   2147:   ASTOP@emph{:postcondition}
                   2148: @end example
                   2149: 
                   2150: In its argumentless form, @code{ASTOP} disables asynchronous event handling for all event classes, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2151: 
                   2152: @example
                   2153:   ASTOP@emph{:postcondition} @emph{evclass1}...,@emph{evclassN}
                   2154: @end example
                   2155: 
                   2156: In its inclusive form, @code{ASTOP} disables asynchronous event handling for all event classes named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2157: 
                   2158: @example
                   2159:   ASTOP@emph{:postcondition} (@emph{evclass1}...,@emph{evclassN})
                   2160: @end example
                   2161: 
                   2162: In its exclusive form, @code{ASTOP} disables asynchronous event handling for all event classes @emph{except for} those named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2163: 
                   2164: @node AUNBLOCK
                   2165: @section AUNBLOCK
                   2166: @cindex AUNBLOCK
                   2167: @cindex commands, AUNBLOCK
                   2168: 
                   2169: Decrements the event block counter for one or more event classes.
                   2170: 
                   2171: @emph{Syntax}
                   2172: 
                   2173: @example
                   2174:   AUNBLOCK@emph{:postcondition}
                   2175: @end example
                   2176: 
                   2177: In its argumentless form, @code{AUNBLOCK} decrements the block counter for @emph{all} event classes, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2178: 
                   2179: @example
                   2180:   AUNBLOCK@emph{:postcondition} @emph{evclass1}...,@emph{evclassN}
                   2181: @end example
                   2182: 
                   2183: In its inclusive form, @code{AUNBLOCK} decrements the block counters for all event classes named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2184: 
                   2185: @example
                   2186:   AUNBLOCK@emph{:postcondition} (@emph{evclass1}...,@emph{evclassN}
                   2187: @end example
                   2188: 
                   2189: In its exclusive form, @code{AUNBLOCK} decrements the block counters for all event classes @emph{except for} those named in the list, provided the optional @emph{postcondition} is either @emph{true} or omitted.
                   2190: 
                   2191: 
                   2192: @node BREAK
                   2193: @section BREAK
                   2194: @cindex BREAK
                   2195: @cindex commands, BREAK
                   2196: 
                   2197: Interrupts running routine to allow interactive debugging.
                   2198: 
                   2199: @emph{Syntax}
                   2200: 
                   2201: @example
                   2202: @code{BREAK@emph{:postcondition}}
                   2203: @end example
                   2204: 
                   2205: In its argumentless form, @code{BREAK} suspends execution of running code, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   2206: 
                   2207: @example
                   2208: @code{BREAK@emph{:postcondition} @emph{breakflag}}
                   2209: @end example
                   2210: 
                   2211: @emph{FreeM Extension}
                   2212: 
                   2213: In its single-argument form, @code{BREAK} sets @emph{Ctrl-C} handling and error handling characteristics, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   2214: The following table enumerates the possible values of @emph{breakflag}
                   2215: 
                   2216: @table @code
                   2217: @item 0
                   2218: Disables @emph{Ctrl-C} handling
                   2219: @item -2
                   2220: Enables normal FreeM error handling
                   2221: @item 2
                   2222: Enables @emph{Digital Standard MUMPS} v2 error handling
                   2223: @item @emph{any integer value other than 0, 2, or -2}
                   2224: Enables @emph{Ctrl-C} handling
                   2225: @end table
                   2226: 
                   2227: @node CLOSE
                   2228: @section CLOSE
                   2229: @cindex CLOSE
                   2230: @cindex commands, CLOSE
                   2231: 
                   2232: Closes an input/output device.
                   2233: 
                   2234: @emph{Syntax}
                   2235: 
                   2236: @example
                   2237: @code{CLOSE@emph{:postcondition}}
                   2238: @end example
                   2239: 
                   2240: In its argumentless form, @code{CLOSE} closes all I/O devices except for device 0 (the @code{HOME} device), provided the optional @emph{postcondition} is @emph{true} or omitted.
                   2241: 
                   2242: @example
                   2243: @code{CLOSE@emph{:postcondition} @emph{channel}}
                   2244: @end example
                   2245: 
                   2246: In its single-argument form, @code{CLOSE} closes the I/O device associated with channel @emph{channel}, provided that @emph{channel} represents a currently-open device, and the optional @emph{postcondition} is @emph{true} or omitted.
                   2247: 
                   2248: @node CONST
                   2249: @section CONST
                   2250: @cindex CONST
                   2251: @cindex commands, CONST
                   2252: @cindex commands, non-standard
                   2253: @emph{FreeM Extension}
                   2254: 
                   2255: Defines a local @emph{constant}, or variable that cannot be altered after its initial definition, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   2256: 
                   2257: Constants must only be locals, and globals are not supported.
                   2258: 
                   2259: @emph{Syntax}
                   2260: 
                   2261: @example
                   2262: @code{CONST@emph{:postcondition} @emph{mref1}=@emph{initial-value1},...,@emph{mrefN}=@emph{initial-valueN}}
                   2263: @end example
                   2264: 
                   2265: @node DO
                   2266: @section DO
                   2267: @cindex DO
                   2268: @cindex commands, DO
                   2269: 
                   2270: In its inclusive form, transfers program control to one or more specified subroutines, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. Line levels of entryrefs specified in the argument list must be one, or error @code{M14} is raised.
                   2271: 
                   2272: @emph{Syntax}
                   2273: 
                   2274: @example
                   2275: DO[@emph{:postcondition}] @emph{entryref}[@emph{:postcondition}[,...]]
                   2276: @end example
                   2277: 
                   2278: In its argumentless form, transfers control to the following block of code where the line level is one greater than the level at which @code{DO} was encountered, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2279: 
                   2280: @emph{Syntax}
                   2281: 
                   2282: @example
                   2283: DO[@emph{:postcondition}]
                   2284: @end example
                   2285: 
                   2286: @node ELSE
                   2287: @section ELSE
                   2288: @cindex ELSE
                   2289: @cindex commands, ELSE
                   2290: 
                   2291: Executes the remainder of the line of code on which @code{ELSE} is encountered only if @code{$TEST} evaluates to @emph{false}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2292: 
                   2293: @emph{Syntax}
                   2294: 
                   2295: @example
                   2296: ELSE[@emph{:postcondition}]
                   2297: @end example
                   2298: 
                   2299: @cartouche
                   2300: @quotation
                   2301: @emph{Non-Standard Behavior}
                   2302: 
                   2303: FreeM allows a @emph{postcondition} on @code{ELSE}. While explicitly forbidden in the @emph{standard}--and for good reason--it was decided that FreeM should allow postconditions everywhere, both for the sake of foolish consistency (the likes of which Emerson warned against), and for the benefit of entrants to a hypothetical future obfuscated M contest, and those with a Machiavellian predisposition to wicked perversions and undue cleverness.
                   2304: 
                   2305: Using postconditions on @code{ELSE} should be strictly avoided in production code, as they have no practical use, and may contribute to technical debt, hardening of the arteries, hobgoblins, a small mind, a surfeit of logic, climate change, Daily WTF rants, or meltdown of global financial markets.
                   2306: @end quotation
                   2307: @end cartouche
                   2308: 
                   2309: @node FOR
                   2310: @section FOR
                   2311: @cindex FOR
                   2312: @cindex commands, FOR
                   2313: 
                   2314: In its argumentless form, repeatedly executes the remainder of the line on which @code{FOR} was encountered until a @code{QUIT}, @code{GOTO}, or end-of-line is encountered, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2315: 
                   2316: @emph{Syntax}
                   2317: 
                   2318: @example
                   2319: FOR[@emph{:postcondition}]
                   2320: @end example
                   2321: 
                   2322: @cartouche
                   2323: @quotation
                   2324: @emph{Non-Standard Behavior}
                   2325: 
                   2326: When @code{$DIALECT} is set to @code{FREEM}, FreeM allows a @emph{postcondition} on @code{FOR}. Much like postconditions on @code{ELSE} and @code{IF}, this is explicitly forbidden in the @emph{standard}. The expression contained in the @emph{postcondition} is evaluated on each iteration of the @code{FOR} loop, and if it does not evaluate @emph{true}, the loop will be immediately exited. The effect is roughly similar to @code{WHILE} constructs present in other languages, but absent from standard M.
                   2327: 
                   2328: As with all non-standard features of FreeM, please exercise caution when using this feature, especially in code that is expected to run in other, less preternaturally-inclined M implementations.
                   2329: @end quotation
                   2330: @end cartouche
                   2331: 
                   2332: In its sentinel form, repeatedly executes the remainder of the line and sets a sentinel variable on each iteration, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2333: 
                   2334: On the first iteration of the loop, @emph{glvn} will be set to @emph{initalizer-expression}. On each subsequent iteration, @emph{glvn} will be incremented by @emph{increment-expression}, and the loop will terminate when @emph{glvn} meets or exceeds the value of @emph{max-expression}.
                   2335: 
                   2336: @emph{Syntax}
                   2337: 
                   2338: @example
                   2339: FOR[@emph{:postcondition}] @emph{glvn}=@emph{initializer-expression}:@emph{increment-expression}:@emph{max-expression}
                   2340: @end example
                   2341: 
                   2342: @emph{Example}
                   2343: 
                   2344: @example
1.22      snw      2345: DEFAULT.USER> FOR I=1:1:10 WRITE I,!
1.1       snw      2346: 
                   2347: 1
                   2348: 2
                   2349: 3
                   2350: 4
                   2351: 5
                   2352: 6
                   2353: 7
                   2354: 8
                   2355: 9
                   2356: 10
                   2357: 
1.22      snw      2358: DEFAULT.USER> FOR I=2:2:10 WRITE I,!
1.1       snw      2359: 
                   2360: 2
                   2361: 4
                   2362: 6
                   2363: 8
                   2364: 10
                   2365: @end example
                   2366: 
                   2367: In its explicit parameter form, a variable is set to each of a series of explicit values, once per iteration, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. The loop terminates when no more values are available.
                   2368: 
                   2369: @emph{Syntax}
                   2370: 
                   2371: @example
                   2372: FOR[@emph{:postcondition}] @emph{glvn}=@emph{expr1}[,..@emph{exprN}]
                   2373: @end example
                   2374: 
                   2375: @emph{Example}
                   2376: 
                   2377: @example
1.22      snw      2378: DEFAULT.USER> FOR I=60,"FOO",-3,"George",1450,$HOROLOG WRITE I,!
1.1       snw      2379: 
                   2380: 60
                   2381: FOO
                   2382: -3
                   2383: George
                   2384: 1450
                   2385: 66106,52388
                   2386: @end example
                   2387: 
                   2388: @node GOTO
                   2389: @section GOTO
                   2390: @cindex GOTO
                   2391: @cindex commands, GOTO
                   2392: 
                   2393: Transfers program execution to another line of code, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. Attempting to @code{GOTO} a different line level or a different block when the line level of @code{GOTO} is greater than one will raise error @code{M45}.
                   2394: 
                   2395: @emph{Syntax}
                   2396: 
                   2397: @example
                   2398: GOTO[@emph{:postcondition}] @emph{entryref}
                   2399: @end example
                   2400: 
                   2401: @node HALT
                   2402: @section HALT
                   2403: @cindex HALT
                   2404: @cindex commands, HALT
                   2405: 
                   2406: Halts program execution and frees resources allocated during execution, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2407: 
                   2408: @emph{Syntax}
                   2409: 
                   2410: @example
                   2411: HALT[@emph{:postcondition}]
                   2412: @end example
                   2413: 
                   2414: @node HANG
                   2415: @section HANG
                   2416: @cindex HANG
                   2417: @cindex commands, HANG
                   2418: 
                   2419: Temporarily suspends the program for @emph{expr} seconds, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. Values of @emph{expr} that are zero or less than zero are ignored.
                   2420: 
                   2421: @emph{Syntax}
                   2422: 
                   2423: @example
                   2424: HANG[@emph{:postcondition}] @emph{expr}
                   2425: @end example
                   2426: 
                   2427: @cartouche
                   2428: @quotation
                   2429: @emph{Non-Standard Behavior}
                   2430: 
                   2431: FreeM supports sub-second values for @emph{expr}.
                   2432: @end quotation
                   2433: @end cartouche
                   2434: 
                   2435: @node IF
                   2436: @section IF
                   2437: @cindex IF
                   2438: @cindex commands, IF
                   2439: 
                   2440: In its argumented form, allows the remainder of the line of code following @code{IF} to execute only if all @emph{tvexpr}s evaluate to @emph{true}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2441: 
                   2442: @emph{Syntax}
                   2443: @example
                   2444: IF[@emph{:postcondition}] @emph{tvexpr}[,...@emph{tvexpr}]
                   2445: @end example
                   2446: 
                   2447: In its argumentless form, allows the remainder of the line of code following @code{IF} to execute only if @code{$TEST} evaluates to @emph{1}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2448: 
                   2449: @emph{Syntax}
                   2450: @example
                   2451: IF[@emph{:postcondition}]
                   2452: @end example
                   2453: 
                   2454: @node JOB
                   2455: @section JOB
                   2456: @cindex JOB
                   2457: @cindex commands, JOB
                   2458: 
                   2459: Executes @emph{entryref} in a separate process, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2460: 
                   2461: @emph{Syntax}
                   2462: @example
                   2463: JOB[@emph{:postcondition}] @emph{entryref}[:@emph{job-parameters}[:@emph{timeout}]]
                   2464: @end example
                   2465: 
                   2466: If @emph{timeout} is supplied, FreeM will set @code{$TEST} to @emph{1} if the child process completes within @emph{timeout} seconds.
                   2467: 
                   2468: @node KILL
                   2469: @section KILL
                   2470: @cindex KILL
                   2471: @cindex commands, KILL
                   2472: 
                   2473: In its inclusive form, @code{KILL} deletes the specified @emph{glvn}s and their descendant subscripts, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2474: 
                   2475: @emph{Syntax}
                   2476: @example
                   2477: KILL[@emph{:postcondition}] @emph{glvn}[,...@emph{glvn}]
                   2478: @end example
                   2479: 
                   2480: In its exclusive form, @code{KILL} deletes all local variables @emph{except} for those specified by @emph{lvn}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2481: 
                   2482: @emph{Syntax}
                   2483: @example
                   2484: KILL[@emph{:postcondition}] (@emph{lvn}[,...@emph{lvn}])
                   2485: @end example
                   2486: 
                   2487: In its argumentless form, @code{KILL} deletes all local variables, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2488: 
                   2489: @emph{Syntax}
                   2490: @example
                   2491: KILL[@emph{:postcondition}]
                   2492: @end example
                   2493: 
                   2494: @node KSUBSCRIPTS
                   2495: @section KSUBSCRIPTS
                   2496: @cindex KSUBSCRIPTS
                   2497: @cindex commands, KSUBSCRIPTS
                   2498: 
                   2499: Kills only the descendant subscripts (but not the data value) of a referenced global, local, or SSVN (where allowed).
                   2500: 
                   2501: @emph{Syntax}
                   2502: 
                   2503: @example
                   2504: KSUBSCRIPTS@emph{:postcondition} @emph{var1},...
                   2505: @end example
                   2506: 
                   2507: In the above @emph{inclusive} form, @code{KVALUE} will kill the descendant subscripts at each local, global, or SSVN node specified in the list (provided that the optional @emph{postcondition} is @emph{true} or omitted), but will leave the data value intact.
                   2508: 
                   2509: @cartouche
                   2510: @quotation
                   2511: @emph{Note}
1.26      snw      2512: The below @emph{argumentless} and @emph{exclusive} forms of @code{KSUBSCRIPTS} are not implemented in FreeM, as of version 0.64.0-rc0, but are planned for a future release.
1.1       snw      2513: @end quotation
                   2514: @end cartouche
                   2515: 
                   2516: @example
                   2517: KSUBSCRIPTS@emph{:postcondition}
                   2518: @end example
                   2519: 
                   2520: In the above @emph{argumentless} form, @code{KSUBSCRIPTS} will kill the descendant subscripts at the root of each local variable (provided that the optional @emph{postcondition} is @emph{true} or omitted), but will leave data values intact.
                   2521: 
                   2522: @example
                   2523: KSUBSCRIPTS@emph{:postcondition} (@emph{var1},...)
                   2524: @end example
                   2525: 
                   2526: In the above @emph{exclusive} form, @code{KSUBSCRIPTS} will kill the descendant subscripts of all local variables, @emph{with the exception of} those named in the list, provided that the optional @emph{postcondition} is @emph{true} or omitted, while leaving their data values intact.
                   2527: 
                   2528: 
                   2529: @node KVALUE
                   2530: @section KVALUE
                   2531: @cindex KVALUE
                   2532: @cindex commands, KVALUE
                   2533: 
                   2534: Kills only the data value (but not descendant subscripts) of a referenced global, local, or SSVN (where allowed).
                   2535: 
                   2536: @emph{Syntax}
                   2537: 
                   2538: @example
                   2539: KVALUE@emph{:postcondition} @emph{var1},...
                   2540: @end example
                   2541: 
                   2542: In the above @emph{inclusive} form, @code{KVALUE} will kill the data values at each local, global, or SSVN node specified in the list (provided that the optional @emph{postcondition} is @emph{true} or omitted), but will leave descendant subscripts intact.
                   2543: 
                   2544: @cartouche
                   2545: @quotation
                   2546: @emph{Note}
1.21      snw      2547: The below @emph{argumentless} and @emph{exclusive} forms of @code{KVALUE} are not implemented in FreeM, as of version 0.64.0-rc0, but are planned for a future release.
1.1       snw      2548: @end quotation
                   2549: @end cartouche
                   2550: 
                   2551: @example
                   2552: KVALUE@emph{:postcondition}
                   2553: @end example
                   2554: 
                   2555: In the above @emph{argumentless} form, @code{KVALUE} will kill the data values at the root of each local variable (provided that the optional @emph{postcondition} is @emph{true} or omitted), but will leave descendant subscripts intact.
                   2556: 
                   2557: @example
                   2558: KVALUE@emph{:postcondition} (@emph{var1},...)
                   2559: @end example
                   2560: 
                   2561: In the above @emph{exclusive} form, @code{KVALUE} will kill the data values of all local variables, @emph{with the exception of} those named in the list, provided that the optional @emph{postcondition} is @emph{true} or omitted, while leaving their descendant subscripts intact.
                   2562: 
                   2563: @node LOCK
                   2564: @section LOCK
                   2565: @cindex LOCK
                   2566: @cindex commands, LOCK
                   2567: 
                   2568: Acquires or releases ownership of names.
                   2569: 
                   2570: In its argumentless form, @code{LOCK} releases ownership of all names previously locked by the current process, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2571: 
                   2572: @emph{Syntax}
                   2573: @example
                   2574: LOCK[@emph{:postcondition}]
                   2575: @end example
                   2576: 
                   2577: In its incremental form, increments or decrements the lock counter for each specified @emph{name}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. Ownership of each @emph{name} is considered to be the current process as long as the lock counter for @emph{name} is greater than zero. If @emph{timeout} is specified, FreeM will wait no more than @emph{timeout} seconds in attempting to acquire ownership of @emph{name}.
                   2578: 
                   2579: If @code{LOCK} succeeds within @emph{timeout}, @code{$TEST} is set to @emph{1}. Otherwise, @code{$TEST} is set to @emph{0}.
                   2580: 
                   2581: @emph{Syntax}
                   2582: @example
                   2583: LOCK[@emph{:postcondition}] [+|-]@emph{name}[:@emph{timeout}][,...[+|-]@emph{name}[:@emph{timeout}]]
                   2584: @end example
                   2585: 
                   2586: @emph{Example}
                   2587: 
1.26      snw      2588: This example will increment the lock counter for @code{^SNW} and decrement the lock counter for @code{^MJR}.
1.1       snw      2589: 
                   2590: @example
1.26      snw      2591: LOCK +^SNW,-^MJR
1.1       snw      2592: @end example
                   2593: 
                   2594: In its non-incremental form, @code{LOCK} releases all @code{LOCK}s held by the current process, and then attempts to acquire a lock on each @emph{name}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. If @emph{timeout} is supplied, FreeM will attempt to lock @emph{name} for no more than @emph{timeout} seconds.
                   2595: 
                   2596: If @code{LOCK} succeeds within @emph{timeout}, @code{$TEST} is set to @emph{1}. Otherwise, @code{$TEST} is set to @emph{0}.
                   2597: 
                   2598: @emph{Syntax}
                   2599: @example
                   2600: LOCK[@emph{:postcondition}] @emph{name}[:@emph{timeout}][,...@emph{name}[:@emph{timeout}]]
                   2601: @end example
                   2602: 
                   2603: @node MAP
                   2604: @section MAP
                   2605: @cindex MAP
                   2606: @cindex commands, MAP
                   2607: @cindex commands, implementation-specific
                   2608: @cindex commands, non-standard
                   2609: 
                   2610: Maps global name @code{gvn} to be mapped to the non-default namespace @emph{expr V namespace}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2611: 
                   2612: @emph{Syntax}
                   2613: 
                   2614: @example
                   2615: MAP[@emph{:postcondition}] GLOBAL @emph{gvn}=@emph{expr V namespace}
                   2616: @end example
                   2617: 
                   2618: @node MERGE
                   2619: @section MERGE
                   2620: @cindex MERGE
                   2621: @cindex commands, MERGE
                   2622: 
                   2623: Merges the contents of one global, local, or SSVN subtree to another global, local, or SSVN.
                   2624: 
                   2625: @emph{Syntax}
                   2626: 
                   2627: @example
                   2628: @code{MERGE A=^$JOB}
                   2629: @end example
                   2630: 
                   2631: The above example will merge the @code{^$JOB} SSVN into the @code{A} local. Note that the FreeM implementation of @code{MERGE} does not yet support multiple merge arguments. Returns error @code{M19} if either the source or the target variable are descendants of each other.
                   2632: 
                   2633: @node NEW
                   2634: @section NEW
                   2635: @cindex NEW
                   2636: @cindex commands, NEW
                   2637: 
                   2638: In all forms of @code{NEW}, @emph{name} must be a local variable name or @code{NEW}-able structured or intrinsic system variable.
                   2639: 
                   2640: In its inclusive form, @code{NEW} saves each specified @emph{name} on the process stack and removes it, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.  When the current stack frame is exited, the previous values are restored.
                   2641: 
                   2642: @emph{Syntax}
                   2643: 
                   2644: @example
                   2645: NEW[@emph{:postcondition}] @emph{name}[,...@emph{name}]
                   2646: @end example
                   2647: 
                   2648: In its exclusive form, @code{NEW} saves all local variables @emph{except} those named (each @emph{name}) and removes them, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. When the current stack frame is exited, the previous values are restored.
                   2649: 
                   2650: @emph{Syntax}
                   2651: @example
                   2652: NEW[@emph{:postcondition}] (@emph{name}[,...@emph{name}])
                   2653: @end example
                   2654: 
                   2655: In its argumentless form, @code{NEW} saves all local variables and removes them, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. When the current stack frame is exited, the previous values are restored.
                   2656: 
                   2657: @emph{Syntax}
                   2658: @example
                   2659: NEW@emph{:postcondition} @emph{name}=@emph{expr}
                   2660: @end example
                   2661: 
                   2662: In its initializing form, @code{NEW} stacks variable @emph{name} and sets its value to @emph{expr}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. When the current stack frame is exited, the previous value is restored.
                   2663: 
1.26      snw      2664: @emph{Syntax}
                   2665: @example
                   2666: NEW@emph{:postcondition} @emph{name}=$%@emph{^CLASS}(@emph{initializer-list})
                   2667: @end example
                   2668: 
                   2669: In its object-oriented form, @code{NEW} creates an instance of class @emph{^CLASS} in local variable @emph{name} and calls the constructor of @emph{^CLASS}, passing @emph{initializer-list} as its argument(s).
                   2670: 
1.1       snw      2671: @node OPEN
                   2672: @section OPEN
                   2673: @cindex OPEN
                   2674: @cindex commands, OPEN
                   2675: 
                   2676: Opens sequential or socket I/O devices and files and associates them with a numeric FreeM input/output channel.
                   2677: 
                   2678: @emph{Syntax (Sequential Files)}
                   2679: 
                   2680: @example
                   2681: @code{OPEN@emph{:postcondition} @emph{channel}:"@emph{filename}/@emph{access-mode}"}
                   2682: @end example
                   2683: 
                   2684: Opens @emph{filename} for reading and/or writing, and associates the file with FreeM I/O channel @emph{channel}, provided that the optional @emph{postcondition} is @emph{true} or omitted.
                   2685: The below table lists the valid options for @emph{access-mode}:
                   2686: 
                   2687: @table @code
                   2688: @item r
                   2689: Read-only access
                   2690: @item w
                   2691: Create a new file for write access
                   2692: @item a
                   2693: Write access; append to existing file
                   2694: @item r+
                   2695: Read/write access
                   2696: @end table
                   2697: 
                   2698: @cartouche
                   2699: @quotation
                   2700: @emph{I/O Path}
                   2701: 
                   2702: You cannot specify a fully-qualified filesystem path in the FreeM @code{OPEN} command. By default, FreeM will assume that @emph{filename} exists in the directory indicated in @code{^$JOB($JOB,"CWD")}. If you wish to
                   2703: access files in other directories, you must first set the @emph{I/O Path} in @code{^$JOB($JOB,"IOPATH")}.
                   2704: 
                   2705: The following example will set the I/O path to @code{/etc}:
                   2706: 
                   2707: @example
                   2708: @code{SET ^$JOB($JOB,"IOPATH")="/etc"}
                   2709: @end example
                   2710: 
                   2711: @end quotation
                   2712: @end cartouche
                   2713: 
                   2714: If @emph{channel} was already @code{OPEN}ed in the current process, calling @code{OPEN} on the same channel again implicitly closes the file or device currently associated with @emph{channel}.
                   2715: 
                   2716: @emph{Syntax (Network Sockets)}
                   2717: 
                   2718: Network sockets use a dedicated range of FreeM I/O channels ranging from 100-255. @code{OPEN}ing a socket I/O channel does @emph{not} implicitly connect the socket. Connecting the socket to the specified remote host is accomplished by the @code{/CONNECT} control mnemonic supplied to the @code{USE} command.
                   2719: 
                   2720: @example
                   2721:   OPEN@emph{:postcondition} @emph{socket-channel}:"@emph{hostname-or-address}:@emph{port}:@emph{address-family}:@emph{connection-type}"
                   2722: @end example
                   2723: 
                   2724: @emph{Socket Parameters}
                   2725: 
                   2726: @table @emph
                   2727: 
                   2728: @item socket-channel
                   2729: The socket I/O channel to use. This must be in the range of 100-255.
                   2730: 
                   2731: @item hostname-or-address
                   2732: The hostname or IP address to connect to. If a hostname is supplied, @code{OPEN} will implictly do a name lookup, the mechanism of which is typically determined by the configuration of @code{/etc/nsswitch.conf} on most UNIX and UNIX-like platforms.
                   2733: 
                   2734: @item port
                   2735: The TCP or UDP port to which the socket will connect on the remote host.
                   2736: 
                   2737: @item address-family
                   2738: The address family to use. Either @emph{IPV4} or @emph{IPV6}.
                   2739: 
                   2740: @item connection-type
                   2741: Which connection type to use. Either @emph{TCP} or @emph{UDP}.
                   2742: 
                   2743: @end table
                   2744: 
                   2745: If you do not specify the address family and connection type, they will default to @emph{IPV4} and @emph{TCP}, respectively.
                   2746: 
                   2747: @node QUIT
                   2748: @section QUIT
                   2749: @cindex QUIT
                   2750: @cindex commands, QUIT
                   2751: 
                   2752: @code{QUIT} will end execution of the current process level, optionally returning @emph{expr}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2753: 
                   2754: @code{QUIT} with @emph{expr} when an argument is not expected will raise error @code{M16}; @code{QUIT} without @emph{expr} when an argument is expected will raise error @code{M17}.
                   2755: 
                   2756: Argumentless @code{QUIT} may also be used to exit a @code{FOR} loop occurring on the same line.
                   2757: 
                   2758: @emph{Syntax}
                   2759: @example
                   2760: QUIT[@emph{:postcondition}] [@emph{expr}]
                   2761: @end example
                   2762: 
                   2763: @node READ
                   2764: @section READ
                   2765: @cindex READ
                   2766: @cindex commands, READ
                   2767: 
                   2768: The @code{READ} command takes input from I/O channel @code{$IO} and stores it into specified variables, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2769: 
                   2770: @emph{Syntax}
                   2771: @example
                   2772: READ[@emph{:postcondition}] @emph{read-argument}[,...@emph{read-argument}]
                   2773: @end example
                   2774: 
                   2775: Each @emph{read-argument} may be one of the following:
                   2776: 
                   2777: @table @asis
                   2778: 
                   2779: @item String Literal
                   2780: String literal @emph{read-argument}s will be output to @code{$IO} unmodified.
                   2781: 
                   2782: @item Format Specifier
                   2783: One or more of the following:
                   2784: 
                   2785: @table @asis
                   2786: @item @code{!} (newline)
                   2787: Advances the cursor down by one line and returns it to the first column.
                   2788: 
                   2789: @item @code{#} (form-feed)
                   2790: Advances the screen down by @code{$ZROWS} and moves the cursor to the upper-left corner of the screen.
                   2791: 
                   2792: @item @code{?@emph{n}} (position)
                   2793: Advances the cursor and @code{$X} forward to position @emph{n}.
                   2794: 
                   2795: @end table
                   2796: 
                   2797: @item Single-Character Read (@code{*@emph{variable-name}[@emph{:timeout}]})
                   2798: Reads one character into variable @emph{variable-name}. If the optional @emph{timeout} is specified, will wait @emph{timeout} seconds to retrieve one character. If a character is read within @emph{timeout} seconds, @code{$TEST} will be set to @emph{1}. If no character is read within @emph{timeout} seconds, @code{$TEST} will be set to @emph{0}.
                   2799: 
                   2800: @item Variable-Length Character Read (@code{@emph{variable-name}[@emph{:timeout}]})
                   2801: Reads characters into @emph{variable-name} until the character or character pair in @code{^$DEVICE(@emph{io-channel},"OPTIONS","TERMINATOR")} is encountered. If the optional @emph{timeout} is specified, will wait @emph{timeout} seconds to retrieve characters. If characters are read within @emph{timeout} seconds, @code{$TEST} will be set to @emph{1}. If no character is read within @emph{timeout} seconds, @code{$TEST} will be set to @emph{0}.
                   2802: 
                   2803: @item Fixed-Length Character Read (@code{@emph{variable-name}#@emph{count}[@emph{:timeout}]})
                   2804: Reads @emph{count} characters into @emph{variable-name}. If the optional @emph{timeout} is specified, will wait @emph{timeout} seconds to retrieve characters. If characters are read within @emph{timeout} seconds, @code{$TEST} will be set to @emph{1}. If no character is read within @emph{timeout} seconds, @code{$TEST} will be set to @emph{0}.
                   2805: 
                   2806: @item Control Mnemonic (@code{/@emph{control-mnemonic}[@emph{(arg1[,...argN])}]})
                   2807: Outputs X3.64 control mnemonic @emph{control-mnemonic} to @code{$IO}. Please see the appendix on X3.64 Control Mnemonics for more information.
                   2808: 
                   2809: @end table
                   2810: 
                   2811: @node SET
                   2812: @section SET
                   2813: @cindex SET
                   2814: @cindex commands, SET
                   2815: 
                   2816: The @code{SET} command places values into one or more variables, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2817: 
                   2818: @emph{Syntax}
                   2819: @example
                   2820: SET[@emph{:postcondition}] @emph{set-argument}[=@emph{expression} | @emph{postfix-operator}][@emph{,...set-argument}[=@emph{expression} | @emph{postfix-operator}]]
                   2821: @end example
                   2822: 
                   2823: Each @emph{set-argument} can be:
                   2824: 
                   2825: @table @asis
                   2826: @item @emph{variable-name}
                   2827: A local variable, global variable, writable intrinsic special variable, or writable structured system variable.
                   2828: 
                   2829: @item @emph{lhs-function}
                   2830: @code{$EXTRACT} or @code{$PIECE}.
                   2831: @end table
                   2832: 
                   2833: If any grouping of @emph{set-argument}s is surrounded by parentheses, all @emph{set-argument}s in the parenthesized group will be set to the result of @emph{expression}.
                   2834: 
                   2835: If @emph{postfix-operator} is used instead of @code{=@emph{expression}}, the results of applying @emph{postfix-operator} to the @emph{set-argument} will be stored in @emph{set-argument}. @emph{postfix-operator} may not be used following a parenthesized group of @emph{set-argument}s.
                   2836: 
                   2837: @emph{Example (postfix-operator)}
                   2838: 
                   2839: @example
                   2840: SET A++,B-- ; increments A, decrements B
                   2841: @end example
                   2842: 
                   2843: @node TCOMMIT
                   2844: @section TCOMMIT
                   2845: @cindex TCOMMIT
                   2846: @cindex commands, TCOMMIT
                   2847: 
                   2848: Commits all pending transactions to the data files, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2849: 
                   2850: @emph{Syntax}
                   2851: @example
                   2852: TCOMMIT[@emph{:postcondition}]
                   2853: @end example
                   2854: 
                   2855: @node THEN
                   2856: @section THEN
                   2857: @cindex THEN
                   2858: @cindex commands, THEN
                   2859: 
                   2860: Saves the value of @code{$TEST} until the end of the current line, restoring it at the end of the current line or when a @code{QUIT} is encountered. @code{THEN} should be used in all new code in conjunction with @code{IF}.
                   2861: 
                   2862: @emph{Example}
                   2863: @example
                   2864: IF 1 THEN  WRITE "HELLO!",!
                   2865: @end example
                   2866: 
                   2867: @node THROW
                   2868: @section THROW
                   2869: @cindex THROW
                   2870: @cindex commands, THROW
                   2871: @cindex commands, non-standard
                   2872: @emph{FreeM Extension}
                   2873: 
                   2874: Raises an error condition as long as the optional @emph{postcondition} is @emph{true} or omitted.
                   2875: 
                   2876: @emph{Syntax}
                   2877: 
                   2878: @example
                   2879: @code{THROW@emph{:postcondition} @emph{expr V error-code}}
                   2880: @end example
                   2881: 
                   2882: @emph{Example}
                   2883: 
                   2884: @example
                   2885: @code{THROW "M102"}
                   2886: @end example
                   2887: 
                   2888: @node TROLLBACK
                   2889: @section TROLLBACK
                   2890: @cindex TROLLBACK
                   2891: @cindex commands, TROLLBACK
                   2892: 
                   2893: Rolls back all pending transactions for the current process, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2894: 
                   2895: @emph{Syntax}
                   2896: 
                   2897: @example
                   2898: TROLLBACK[@emph{:postcondition}]
                   2899: @end example
                   2900: 
                   2901: @node TSTART
                   2902: @section TSTART
                   2903: @cindex TSTART
                   2904: @cindex commands, TSTART
                   2905: 
                   2906: Introduces a new transaction level, incrementing @code{$TLEVEL}, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted. Any global data file operations encountered when @code{$TLEVEL} is greater than zero will not be committed to the global data files until @code{TCOMMIT} is encountered.
                   2907: 
                   2908: If a transaction is restartable, variables in the @emph{variables-list} will be restored to their original values on a restart of the transaction.
                   2909: 
                   2910: @emph{Syntax}
                   2911: 
                   2912: @example
                   2913: TSTART[@emph{:postcondition}] @emph{<variables-list>}:@emph{<transaction-parameters>}
                   2914: @end example
                   2915: 
                   2916: @emph{<variables-list>} can be:
                   2917: 
                   2918: @table @asis
                   2919: 
                   2920: @item @code{()}
                   2921: Do not save off any local variables. Makes the transaction non-restartable.
                   2922: 
                   2923: @item @code{*}
                   2924: Save off all local variables. Makes the transaction restartable.
                   2925: 
                   2926: @item @code{@emph{variableName}}
                   2927: Saves off only one local variable, @emph{variableName}. Makes the transaction restartable.
                   2928: 
                   2929: @item @code{(@emph{variableName1},...,@emph{variableNameN})}
                   2930: Saves off all local variables listed. Makes the transaction restartable.
                   2931: 
                   2932: @end table
                   2933: 
                   2934: @emph{<transaction-parameters>} can be:
                   2935: 
                   2936: @table @asis
                   2937: 
                   2938: @item @code{S[ERIAL]}
                   2939: Forces ACID properties on the transaction. When @code{SERIAL} is not selected, transactions occur in batch mode, and no attempt is made to guarantee ACID properties.
                   2940: 
                   2941: @item @code{T[RANSACTIONID]=@emph{transaction-id}}
                   2942: Sets the ID of the transaction to @emph{transaction-id}
                   2943: 
                   2944: @end table
                   2945: 
                   2946: If you are using more than one transaction parameter, surround all of them in parentheses and separate them with commas, e.g.:
                   2947: 
                   2948: @example
                   2949: TSTART (FOO,BAR):(SERIAL,TRANSACTIONID="FOO")
                   2950: @end example
                   2951: 
                   2952: @node UNMAP
                   2953: @section UNMAP
                   2954: @cindex UNMAP
                   2955: @cindex commands, UNMAP
                   2956: @cindex commands, implementation-specific
                   2957: @cindex commands, non-standard
                   2958: 
                   2959: Removes any mapping connecting @emph{gvn} to a non-default namespace, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   2960: 
                   2961: @emph{Syntax}
                   2962: 
                   2963: @example
                   2964: UNMAP GLOBAL @emph{gvn}
                   2965: @end example
                   2966: 
                   2967: @node USE
                   2968: @section USE
                   2969: @cindex USE
                   2970: @cindex commands, USE
                   2971: 
                   2972: Sets @code{$IO} to a particular FreeM I/O channel, allowing @code{READ}s from and @code{WRITE}s to the associated terminal, sequential file, or network socket. Also sets various device parameters.
                   2973: 
                   2974: @emph{Syntax (Terminal)}
                   2975: 
                   2976: @example
                   2977:   USE@emph{:postcondition} @emph{io-channel}[:(@emph{right-margin}:@emph{input-field-length}:@emph{device-status-word}:@emph{position}:@emph{line-terminator}:@emph{break-key})]
                   2978: @end example
                   2979: 
                   2980: For terminals, @emph{io-channel} must be 0.
                   2981: 
                   2982: Semantic and functional description of each device parameter TBA.
                   2983: 
                   2984: @emph{Syntax (Sequential Files)}
                   2985: 
                   2986: @example
                   2987:   USE@emph{:postcondition} @emph{io-channel}[:@emph{seek-position}:@emph{terminator}:@emph{nodelay})]
                   2988: @end example
                   2989: 
                   2990: For sequential files, @emph{io-channel} must be in the range 1-99.
                   2991: 
                   2992: Semantic and functional description of each device parameter TBA.
                   2993: 
                   2994: @emph{Syntax (Network Sockets)}
                   2995: 
                   2996: @example
                   2997:   USE@emph{:postcondition} @emph{io-channel}
                   2998: @end example
                   2999: 
                   3000: The above syntax will set @code{$IO} to @emph{io-channel}, directing successive @code{READ}s and @code{WRITE}s to @emph{io-channel}, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3001: 
                   3002: @example
                   3003:   USE@emph{:postcondition} @emph{io-channel}:/CONNECT
                   3004: @end example
                   3005: 
                   3006: The above syntax will set @code{$IO} to @emph{io-channel}, as in the prior example, but will also attempt to connect to the host and port specified for @emph{io-channel} when it was @code{OPEN}ed. The @code{/CONNECT} control mnemonic is only valid for socket channels whose connection type is @code{TCP}. Using @code{/CONNECT} on a @code{UDP} socket channel will throw @code{SCKAERR} (error code 55).
                   3007: 
                   3008: For network sockets, @emph{io-channel} must be in the range 100-255.
                   3009: 
                   3010: @node VIEW
                   3011: @section VIEW
                   3012: @cindex VIEW
                   3013: @cindex commands, VIEW
                   3014: 
                   3015: Provides write access to various FreeM internal parameters, provided the optional @emph{postcondition} evaluates to @emph{true} or is omitted.
                   3016: 
                   3017: @emph{Syntax}
                   3018: @example
                   3019: VIEW[@emph{:postcondition}] @emph{view-number}[:@emph{view-argument}[:@emph{view-argument}...]]
                   3020: @end example
                   3021: 
                   3022: The @emph{view-number} argument can be one of the following:
                   3023: 
                   3024: @table @asis
                   3025: 
                   3026: @item @code{21} - Close All Globals
                   3027: Closes all global data files open in the current process. Takes no arguments.
                   3028: 
                   3029: @emph{Syntax}
                   3030: @example
                   3031: VIEW 21
                   3032: @end example
                   3033: 
                   3034: @item @code{52} - Set G0 Input Translation Table for @code{$IO}
                   3035: 
                   3036: @emph{Syntax}
                   3037: @example
                   3038: VIEW 52:@emph{expr V trantab}
                   3039: @end example
                   3040: 
                   3041: @item @code{53} - Set G0 Output Translation Table for @code{$IO}
                   3042: 
                   3043: @emph{Syntax}
                   3044: @example
                   3045: VIEW 53:@emph{expr V trantab}
                   3046: @end example
                   3047: 
                   3048: @item @code{54} - Set G1 Input Translation Table for @code{$IO}
                   3049: 
                   3050: @emph{Syntax}
                   3051: @example
                   3052: VIEW 54:@emph{expr V trantab}
                   3053: @end example
                   3054: 
                   3055: @item @code{55} - Set G1 Output Translation Table for @code{$IO}
                   3056: 
                   3057: @emph{Syntax}
                   3058: @example
                   3059: VIEW 55:@emph{expr V trantab}
                   3060: @end example
                   3061: 
                   3062: @item @code{62} - Set @code{$RANDOM} Seed Number
                   3063: Sets the seed number used by @code{$RANDOM} to @emph{numexpr}.
                   3064: 
                   3065: @emph{Syntax}
                   3066: @example
                   3067: VIEW 62:@emph{numexpr}
                   3068: @end example
                   3069: 
                   3070: @item @code{63} - Set @code{$RANDOM} Parameter A
                   3071: Sets the number used for @code{$RANDOM} Parameter A to @emph{numexpr}.
                   3072: 
                   3073: @emph{Syntax}
                   3074: @example
                   3075: VIEW 63:@emph{numexpr}
                   3076: @end example
                   3077: 
                   3078: @item @code{64} - Set @code{$RANDOM} Parameter B
                   3079: Sets the number used for @code{$RANDOM} Parameter B to @emph{numexpr}.
                   3080: 
                   3081: @emph{Syntax}
                   3082: @example
                   3083: VIEW 64:@emph{numexpr}
                   3084: @end example
                   3085: 
                   3086: @item @code{65} - Set @code{$RANDOM} Parameter C
                   3087: Sets the number used for @code{$RANDOM} Parameter C to @emph{numexpr}.
                   3088: 
                   3089: @emph{Syntax}
                   3090: @example
                   3091: VIEW 65:@emph{numexpr}
                   3092: @end example
                   3093: 
                   3094: @item @code{66} - Set or Clear @code{SIGTERM} Handling Flag
                   3095: Enables or disables handling of @code{SIGTERM} UNIX signals. If @emph{tvexpr} evaluates to 1 (@emph{true}), @code{SIGTERM} handling will be enabled. Otherwise, @code{SIGTERM} handling will be disabled.
                   3096: 
                   3097: @emph{Syntax}
                   3098: @example
                   3099: VIEW 66:@emph{tvexpr}
                   3100: @end example
                   3101: 
                   3102: @item @code{67} - Set or Clear @code{SIGHUP} Handling Flag
                   3103: Enables or disables handling of @code{SIGHUP} UNIX signals. If @emph{tvexpr} evaluates to 1 (@emph{true}), @code{SIGHUP} handling will be enabled. Otherwise, @code{SIGHUP} handling will be disabled.
                   3104: 
                   3105: @emph{Syntax}
                   3106: @example
                   3107: VIEW 67:@emph{tvexpr}
                   3108: @end example
                   3109: 
                   3110: @item @code{70} - Set @code{$ZSORT}/@code{$ZSYNTAX} Flag
                   3111: Selects whether @code{$ZS} resolves to @code{$ZSORT} or @code{$ZSYNTAX}.
                   3112: 
                   3113: If @emph{tvexpr} evaluates to @emph{true}, selects @code{$ZSYNTAX}. Otherwise, selects @code{$ZSORT}.
                   3114: 
                   3115: @emph{Syntax}
                   3116: @example
                   3117: VIEW 70:@emph{tvexpr}
                   3118: @end example
                   3119: 
                   3120: @item @code{71} - Set @code{$ZNEXT}/@code{$ZNAME} Flag
                   3121: Selects whether @code{$ZN} resolves to @code{$ZNEXT} or @code{$ZNAME}.
                   3122: 
                   3123: If @emph{tvexpr} evaluates to @emph{true}, selects @code{$ZNAME}. Otherwise, selects @code{$ZNEXT}.
                   3124: 
                   3125: @emph{Syntax}
                   3126: @example
                   3127: VIEW 71:@emph{tvexpr}
                   3128: @end example
                   3129: 
                   3130: @item @code{72} - Set @code{$ZPREVIOUS}/@code{$ZPIECE} Flag
                   3131: Selects whether @code{$ZP} resolves to @code{$ZPREVIOUS} or @code{$ZPIECE}.
                   3132: 
                   3133: If @emph{tvexpr} evaluates to @emph{true}, selects @code{$ZPIECE}. Otherwise, selects @code{$ZPREVIOUS}.
                   3134: 
                   3135: @emph{Syntax}
                   3136: @example
                   3137: VIEW 72:@emph{tvexpr}
                   3138: @end example
                   3139: 
                   3140: @item @code{73} - Set @code{$ZDATA}/@code{$ZDATE} Flag
                   3141: Selects whether @code{$ZD} resolves to @code{$ZDATA} or @code{$ZDATE}.
                   3142: 
                   3143: If @emph{tvexpr} evaluates to @emph{true}, selects @code{$ZDATE}. Otherwise, selects @code{$ZDATA}.
                   3144: 
                   3145: @emph{Syntax}
                   3146: @example
                   3147: VIEW 73:@emph{tvexpr}
                   3148: @end example
                   3149: 
                   3150: @item @code{79} - Set Old @code{ZJOB} vs. New @code{ZJOB} Flag
                   3151: If @emph{tvexpr} evaluates to @emph{true}, sets the @code{ZJOB} mode to new, otherwise, sets it to old.
                   3152: 
                   3153: @emph{Syntax}
                   3154: @example
                   3155: VIEW 79:@emph{tvexpr}
                   3156: @end example
                   3157: 
                   3158: @item @code{80} - Set or Clear 8-Bit Flag
                   3159: If @emph{tvexpr} evaluates to @emph{true}, sets FreeM to 8-bit mode. Otherwise, sets FreeM to 7-bit mode.
                   3160: 
                   3161: @emph{Syntax}
                   3162: @example
                   3163: VIEW 80:@emph{tvexpr}
                   3164: @end example
                   3165: 
                   3166: @item @code{81} - Set or Clear PF1 Flag
                   3167: If @emph{tvexpr} evaluates to @emph{true}, sets the @code{PF1} flag. We do not yet know what this does.
                   3168: 
                   3169: @emph{Syntax}
                   3170: @example
                   3171: VIEW 81:@emph{tvexpr}
                   3172: @end example
                   3173: 
                   3174: @item @code{83} - Set or Clear Text in @code{$ZERROR} Flag
                   3175: If @emph{tvexpr} evaluates to @emph{true}, descriptive error messages will be included in @code{$ZERROR}. Otherwise, only the short error code (i.e. @emph{ZILLFUN}) will be included in @code{$ZERROR}.
                   3176: 
                   3177: @emph{Syntax}
                   3178: @example
                   3179: VIEW 83:@emph{tvexpr}
                   3180: @end example
                   3181: 
                   3182: @item @code{92} - Set Type Mismatch Error Flag on @code{EUR2DEM}
                   3183: If @emph{tvexpr} evaluates to @emph{true}, a type mismatch error will be thrown in @code{EUR2DEM} currency conversions in certain situations that we do not yet understand.
                   3184: 
                   3185: @emph{Syntax}
                   3186: @example
                   3187: VIEW 92:@emph{tvexpr}
                   3188: @end example
                   3189: 
                   3190: @item @code{93} - Define @code{ZKEY} Production Rule
                   3191: We do not know what this does.
                   3192: 
                   3193: @item @code{96} - Set Global Prefix
                   3194: Forces global data filenames to be prefixed with the result of @emph{expr}.
                   3195: 
                   3196: @emph{Syntax}
                   3197: @example
                   3198: VIEW 96:@emph{expr V string}
                   3199: @end example
                   3200: 
                   3201: @item @code{97} - Set Global Postfix
                   3202: Forces global data filenames to be postfixed with the result of @emph{expr}.
                   3203: 
                   3204: @emph{Syntax}
                   3205: @example
                   3206: VIEW 97:@emph{expr V string}
                   3207: @end example
                   3208: 
                   3209: @item @code{98} - Set Routine Extension
                   3210: Sets the default extension for M routine filenames to the result of @emph{expr}.
                   3211: 
                   3212: @emph{Syntax}
                   3213: @example
                   3214: VIEW 98:@emph{expr V string}
                   3215: @end example
                   3216: 
                   3217: @item @code{101} - Set @code{ierr}
                   3218: Sets the FreeM internal @code{ierr} value to @emph{intexpr}. Used by some FreeM polyfills (commands or functions implemented in M code).
                   3219: 
                   3220: @emph{Syntax}
                   3221: @example
                   3222: VIEW 101:@emph{intexpr}
                   3223: @end example
                   3224: 
                   3225: @item @code{102} - Set @code{ierr} (Deferred)
                   3226: Sets the FreeM internal @code{ierr} value to @emph{intexpr}, but only after the current process stack level is exited. Used by FreeM polyfills to throw an error that will appear to come from the user's own code rather than the polyfill implementation M code.
                   3227: 
                   3228: @emph{Syntax}
                   3229: @example
                   3230: VIEW 102:@emph{intexpr}
                   3231: @end example
                   3232: 
                   3233: @item @code{103} - Signal @code{MERGE} to @code{^$WINDOW} Complete
                   3234: Signals FreeM's MWAPI implementation that a @code{MERGE} to @code{^$WINDOW} or descendant subscripts thereof has completed.
                   3235: 
                   3236: @emph{Syntax}
                   3237: @example
                   3238: VIEW 103[@emph{:subscript}]
                   3239: @end example
                   3240: 
                   3241: @item @code{110} - Set Local @code{$ORDER}/@code{$QUERY} Data Value
                   3242: Sets the local variable @code{$ORDER}/@code{$QUERY} data value to the result of @emph{expr}. We're not entirely sure what this is.
                   3243: 
                   3244: @emph{Syntax}
                   3245: @example
                   3246: VIEW 110:@emph{expr}
                   3247: @end example
                   3248: 
                   3249: @item @code{111} - Set Global @code{$ORDER}/@code{$QUERY} Data Value
                   3250: Sets the global variable @code{$ORDER}/@code{$QUERY} data value to the result of @emph{expr}. We're not entirely sure what this is.
                   3251: 
                   3252: @emph{Syntax}
                   3253: @example
                   3254: VIEW 111:@emph{expr}
                   3255: @end example
                   3256: 
                   3257: @item @code{113} - Set @code{termio} Information
                   3258: We don't know what this does.
                   3259: 
                   3260: @item @code{133} - Remember @code{ZLOAD} Directory on @code{ZSAVE}
                   3261: We don't know what this does, but it takes a @emph{tvexpr}.
                   3262: 
                   3263: @emph{Syntax}
                   3264: @example
                   3265: VIEW 133:@emph{tvexpr}
                   3266: @end example
                   3267: 
                   3268: @end table
                   3269: 
                   3270: @node WATCH
                   3271: @section WATCH
                   3272: @cindex WATCH
                   3273: @cindex commands, WATCH
                   3274: @cindex commands, debugging
                   3275: @cindex commands, implementation-specific
                   3276: @cindex commands, non-standard
                   3277: @emph{FreeM Extension}
                   3278: 
                   3279: Sets a watchpoint on a global, local, or SSVN node.
                   3280: 
                   3281: @emph{Syntax}
                   3282: 
                   3283: 
                   3284: In its @emph{argumentless} form, @code{WATCH} toggles watchpoints on and off, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3285: 
                   3286: @example
                   3287: WATCH[@emph{:postcondition}]
                   3288: @end example
                   3289: 
                   3290: In its @emph{inclusive} form, @code{WATCH} adds, removes, or examines watchpoints, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3291: 
                   3292: A @code{+} adds a new watchpoint to the following variable.
                   3293: 
                   3294: A @code{-} removes an existing watchpoint for the following variable.
                   3295: 
                   3296: A @code{?} examines the status of a watchpoint for the following variable.
                   3297: 
                   3298: @example
                   3299: WATCH[@emph{:postcondition}] [+|-|?]@emph{var1}...,[+|-|?]@emph{varN}
                   3300: @end example
                   3301: 
                   3302: 
                   3303: The following example demonstrates turning watchpoint processing on and adding a watchpoint for global variable @code{^jpw(1)}. It then changes the value of @code{^jpw(1)}.
                   3304: 
                   3305: @example
1.22      snw      3306: DEFAULT.USER> WATCH
1.1       snw      3307:  
                   3308: Watchpoints enabled.
                   3309:  
1.22      snw      3310: DEFAULT.USER> WATCH +^JPW(1)
1.1       snw      3311:  
                   3312: Added '^JPW("1")' to the watchlist.
                   3313:  
1.22      snw      3314: DEFAULT.USER> SET ^JPW(1)="new value"
1.1       snw      3315:  
                   3316: >> WATCHPOINT:  ^JPW("1") => 'new value' (changed 1 times)
                   3317: 
                   3318: @end example
                   3319: 
                   3320: The following example will remove that watchpoint:
                   3321: 
                   3322: @example
1.22      snw      3323: DEFAULT.USER> WATCH -^JPW(1)
1.1       snw      3324:  
                   3325: Removed '^JPW("1")' from the watchlist.
                   3326:  
1.22      snw      3327: DEFAULT.USER> WATCH ?^JPW(1)
1.1       snw      3328:  
                   3329: '^JPW("1")' is not being watched.
                   3330: @end example
                   3331: 
                   3332: @node WITH
                   3333: @section WITH
                   3334: @cindex WITH
                   3335: @cindex commands, WITH
                   3336: @cindex commands, non-standard
                   3337: @emph{FreeM Extension}
                   3338: 
1.26      snw      3339: NOTE: This command may be deprecated and removed in future FreeM releases.
                   3340: 
1.1       snw      3341: Sets a prefix to be applied to all subsequent local variable or constant references.
                   3342: 
                   3343: @emph{Syntax}
                   3344: 
                   3345: @example
                   3346: @code{WITH@emph{:postcondition} @emph{var-prefix}}
                   3347: @end example
                   3348: 
                   3349: In the above single-argument form, sets the @code{$WITH} prefix to @emph{var-prefix}, provided that the optional @emph{postcondition} is either @emph{true} or omitted.
                   3350: 
                   3351: The @emph{var-prefix} argument may be a string literal or any valid FreeM expression.
                   3352: 
                   3353: @example
                   3354: @code{WITH@emph{:postcondition}}
                   3355: @end example
                   3356: 
                   3357: In the above argumentless form, clears the @code{$WITH} prefix, provided the optional @emph{postcondition} is either @emph{true} or omitted. Equivalent to @code{WITH ""}.
                   3358: 
                   3359: 
                   3360: @node WRITE
                   3361: @section WRITE
                   3362: @cindex WRITE
                   3363: @cindex commands, WRITE
                   3364: 
                   3365: @node XECUTE
                   3366: @section XECUTE
                   3367: @cindex XECUTE
                   3368: @cindex commands, XECUTE
                   3369: 
                   3370: @node ZBREAK
                   3371: @section ZBREAK
                   3372: @cindex ZBREAK
                   3373: @cindex commands, ZBREAK
                   3374: @cindex commands, debugging
                   3375: @cindex commands, implementation-specific
                   3376: @cindex commands, non-standard
                   3377: @emph{FreeM Extension}
                   3378: 
                   3379: @node ZGO
                   3380: @section ZGO
                   3381: @cindex ZGO
                   3382: @cindex commands, ZGO
                   3383: @cindex commands, implementation-specific
                   3384: @cindex commands, non-standard
                   3385: @emph{FreeM Extension}
                   3386: 
                   3387: @node ZHALT
                   3388: @section ZHALT
                   3389: @cindex ZHALT
                   3390: @cindex commands, ZHALT
                   3391: @cindex commands, implementation-specific
                   3392: @cindex commands, non-standard
                   3393: @emph{FreeM Extension}
                   3394: 
                   3395: @node ZINSERT
                   3396: @section ZINSERT
                   3397: @cindex ZINSERT
                   3398: @cindex commands, ZINSERT
                   3399: @cindex commands, implementation-specific
                   3400: @cindex commands, non-standard
                   3401: @emph{FreeM Extension}
                   3402: 
                   3403: @node ZJOB
                   3404: @section ZJOB
                   3405: @cindex ZJOB
                   3406: @cindex commands, ZJOB
                   3407: @cindex commands, implementation-specific
                   3408: @cindex commands, non-standard
                   3409: @emph{FreeM Extension}
                   3410: 
                   3411: When @code{ZJOB} is used, the semantics are identical to @code{JOB}, with the exception that the @emph{timeout} is forced to be @code{0}, regardless of what the user specifies.
                   3412: 
                   3413: For more information, see @code{JOB}.
                   3414: 
                   3415: @node ZLOAD
                   3416: @section ZLOAD
                   3417: @cindex ZLOAD
                   3418: @cindex commands, ZLOAD
                   3419: @cindex commands, implementation-specific
                   3420: @cindex commands, non-standard
                   3421: @emph{FreeM Extension}
                   3422: 
                   3423: Loads routine @emph{<routine-name>} into FreeM's routine buffer, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3424: 
                   3425: @emph{Syntax}
                   3426: 
                   3427: @example
                   3428: ZLOAD@emph{:postcondition} @emph{<routine-name>}
                   3429: @end example
                   3430: 
                   3431: @node ZNEW
                   3432: @section ZNEW
                   3433: @cindex ZNEW
                   3434: @cindex commands, ZNEW
                   3435: @cindex commands, implementation-specific
                   3436: @cindex commands, non-standard
                   3437: @emph{FreeM Extension}
                   3438: 
                   3439: @node ZPRINT
                   3440: @section ZPRINT
                   3441: @cindex ZPRINT
                   3442: @cindex commands, ZPRINT
                   3443: @cindex commands, implementation-specific
                   3444: @cindex commands, non-standard
                   3445: @emph{FreeM Extension}
                   3446: 
                   3447: Prints the contents of the current routine buffer, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3448: 
                   3449: @emph{Syntax}
                   3450: 
                   3451: @example
                   3452: ZPRINT@emph{:postcondition}
                   3453: @end example
                   3454: 
                   3455: @node ZQUIT
                   3456: @section ZQUIT
                   3457: @cindex ZQUIT
                   3458: @cindex commands, ZQUIT
                   3459: @cindex commands, implementation-specific
                   3460: @cindex commands, non-standard
                   3461: @emph{FreeM Extension}
                   3462: 
                   3463: In its single-argument form, quits from @emph{levels} levels of the stack, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3464: 
                   3465: In its argumentless form, quits from @code{$STACK} levels of the stack, provided the optional @emph{postcondition} is @emph{true} or omitted.
                   3466: 
                   3467: @emph{Syntax}
                   3468: 
                   3469: @example
                   3470: @code{ZQUIT@emph{:postcondition} [@emph{levels}]}
                   3471: @end example
                   3472: 
                   3473: @node ZREMOVE
                   3474: @section ZREMOVE
                   3475: @cindex ZREMOVE
                   3476: @cindex commands, ZREMOVE
                   3477: @cindex commands, implementation-specific
                   3478: @cindex commands, non-standard
                   3479: @emph{FreeM Extension}
                   3480: 
                   3481: @node ZSAVE
                   3482: @section ZSAVE
                   3483: @cindex ZSAVE
                   3484: @cindex commands, ZSAVE
                   3485: @cindex commands, implementation-specific
                   3486: @cindex commands, non-standard
                   3487: @emph{FreeM Extension}
                   3488: 
                   3489: @node ZTRAP
                   3490: @section ZTRAP
                   3491: @cindex ZTRAP
                   3492: @cindex commands, ZTRAP
                   3493: @cindex commands, debugging
                   3494: @cindex commands, implementation-specific
                   3495: @cindex commands, non-standard
                   3496: @emph{FreeM Extension}
                   3497: 
                   3498: @node ZWRITE
                   3499: @section ZWRITE
                   3500: @cindex ZWRITE
                   3501: @cindex commands, ZWRITE
                   3502: @cindex commands, implementation-specific
                   3503: @cindex commands, non-standard
                   3504: @emph{FreeM Extension}
                   3505: 
                   3506: Writes the names and values of M variables to @code{$IO}.
                   3507: 
                   3508: @emph{Syntax}
                   3509: 
                   3510: @example
                   3511: ZWRITE@emph{:postcondition}
                   3512: @end example
                   3513: 
                   3514: In the argumentless form, writes the names and values of all local variables to @code{$IO} if the optional @emph{postcondition} is @emph{true} or omitted.
                   3515: 
                   3516: @example
                   3517: ZWRITE@emph{:postcondition} @emph{ArrayName},@dots{}
                   3518: @end example
                   3519: 
                   3520: In the inclusive form, writes the names and values of all local, global, or structured system variables specified in the list of @emph{ArrayName}s to @code{$IO} if the optional @emph{postcondition} is @emph{true} or omitted.
                   3521: 
                   3522: @example
                   3523: ZWRITE@emph{:postcondition} (@emph{ArrayName},@dots{})
                   3524: @end example
                   3525: 
                   3526: In the exclusive form, writes all local variables @emph{except} those specified in the list of @emph{ArrayName}s to @code{$IO} if the optional @emph{postcondition} is @emph{true} or omitted.
                   3527: 
                   3528: 
                   3529: @node Structured System Variables
                   3530: @chapter Structured System Variables
                   3531: @cindex variables, structured system
                   3532: @cindex structured system variables
                   3533: @cindex SSVNs
                   3534: 
                   3535: @menu
                   3536: * ^$CHARACTER::                         Character set information.
                   3537: * ^$DEVICE::                            Device information.
                   3538: * ^$DISPLAY::                           Information about graphic display.
                   3539: * ^$EVENT::                             Information supplied about a synchronous or asynchronous event.
                   3540: * ^$GLOBAL::                            Information about M globals.
                   3541: * ^$JOB::                               Information about and control of FreeM jobs.
                   3542: * ^$LOCK::                              Information about the FreeM lock table.
                   3543: * ^$OBJECT::                            Information about FreeM objects.
                   3544: * ^$ROUTINE::                           Information about FreeM routines.
                   3545: * ^$SYSTEM::                            Information about the running system.
                   3546: * ^$WINDOW::                            Configuration of MWAPI windows.
                   3547: * ^$ZPROCESS::                          Information about and control of system processes.
                   3548: * ^$ZRPI::                              Information about and control of Raspberry Pi GPIO pins.
                   3549: @end menu
                   3550: 
                   3551: SSVN subscripts are each described in the following format:
                   3552: 
                   3553: @table @asis
                   3554: @item @code{@emph{<ssvn-subscript-name>}} +/-R +/-U +/-D
                   3555: @end table
                   3556: 
                   3557: The R, U, and D flags represent Read, Update, and Delete. A minus sign indicates that the given operation is @emph{not} allowed, and a plus sign indicates that the given operation @emph{is} allowed.
                   3558: 
                   3559: @node ^$CHARACTER
                   3560: @section ^$CHARACTER
                   3561: @cindex ^$CHARACTER
                   3562: @cindex structured system variables, ^$CHARACTER
                   3563: 
                   3564: Exposes character set information. As FreeM currently only supports the @code{M} character set, the first subscript of @code{^$CHARACTER} must always be @code{"M"}.
                   3565: 
                   3566: The following values for the second subscript are supported:
                   3567: 
                   3568: @table @asis
                   3569: 
                   3570: @item @code{IDENT} +R -U -D
                   3571: Returns the empty string.
                   3572: 
                   3573: @item @code{COLLATE} +R -U -D
                   3574: Returns the empty string.
                   3575: 
                   3576: @item @code{INPUT} +R -U -D
                   3577: Returns the empty string if the third subscript is @code{M}, otherwise, raises error @code{M38}.
                   3578: 
                   3579: @item @code{OUTPUT} +R -U -D
                   3580: Returns the empty string if the third subscript is @code{M}, otherwise, raises error @code{M38}.
                   3581: 
                   3582: @end table
                   3583: 
                   3584: @node ^$DEVICE
                   3585: @section ^$DEVICE
                   3586: @cindex ^$DEVICE
                   3587: @cindex structured system variables, ^$DEVICE
                   3588: 
                   3589: FreeM implements several important pieces of functionality in the @code{^$DEVICE} SSVN.
                   3590: 
                   3591: The first subscript of @code{^$DEVICE} represents the I/O channel of an @code{OPEN}ed device.
                   3592: 
                   3593: The following values for the second subscript are supported:
                   3594: 
                   3595: @table @asis
                   3596: 
                   3597: @item @code{$DEVICE}
                   3598: Returns the value of @code{$DEVICE} for the specified I/O channel.
                   3599: 
                   3600: @item @code{$X} +R -U -D
                   3601: Returns the horizontal cursor position of a terminal device. Only valid if the I/O channel is @code{0}.
                   3602: 
                   3603: @item @code{$Y} +R -U -D
                   3604: Returns the vertical cursor position of a terminal device. Only valid if the I/O channel is @code{0}.
                   3605: 
                   3606: @item @code{ROWS} +R -U -D
                   3607: Returns the number of character rows on the terminal device. Only valid if the I/O channel is @code{0}.
                   3608: 
                   3609: @item @code{COLUMNS} +R -U -D
                   3610: Returns the number of character columns on the terminal device. Only valid if the I/O channel is @code{0}.
                   3611: 
                   3612: @item @code{CHARACTER} +R -U -D
                   3613: Returns the character set of the specified I/O channel; always @code{M} in the current implementation.
                   3614: 
                   3615: @item @code{INPUT_BUFFER} +R +U -D
                   3616: Returns or sets the contents of the input buffer for the specified I/O channel. Data populated in this node will remain in the buffer until subsequent @code{READ} command(s) remove it. This can be used to perform input buffer stuffing, i.e., to fill out an interactive form programmatically.
                   3617: 
                   3618: @item @code{NAME} +R -U -D
                   3619: Returns the operating system's name for the file, device, or socket attached to the specified I/O channel.
                   3620: 
                   3621: @item @code{FD} +R -U -D
                   3622: Returns the UNIX file descriptor of the specified I/O channel.
                   3623: 
                   3624: @item @code{MODE} +R -U -D
                   3625: Returns one of @code{READ}, @code{WRITE}, @code{READWRITE}, or @code{APPEND}, depending on the mode in which the specified I/O channel was opened.
                   3626: 
                   3627: @item @code{EOF} +R -U -D
                   3628: Returns @code{1} if the I/O channel has encountered an end-of-file condition; @code{0} otherwise. Only valid if the I/O channel is connected to a sequential file.
                   3629: 
                   3630: @item @code{LENGTH} +R -U -D
                   3631: Returns the length of the file connected to the I/O channel. Only valid if the I/O channel is connected to a sequential file.
                   3632: 
                   3633: @item @code{NAMESPACE} +R -U -D
                   3634: Returns the current @emph{mnemonic-space} in use for the referenced I/O channel. Always @code{X364} for terminals and blank for sequential files.
                   3635: 
                   3636: @item @code{TYPE} +R -U -D
                   3637: Returns either @code{1,FILE}, @code{2,SOCKET}, or @code{4,TERMINAL}, depending on the device type associated with the specified I/O channel.
                   3638: 
                   3639: @item @code{OPTIONS} -R -U -D
                   3640: The following subscripts reside beneath @code{^$DEVICE(<io-channel>,"OPTIONS")}, and this subscript may not be accessed without one of the following third-level subscripts being specified:
                   3641: 
                   3642: @table @asis
                   3643: 
                   3644: @item @code{DSW} +R +U -D
                   3645: Sets or returns the current @emph{Device Status Word} controlling terminal characteristics. Only valid for I/O channel 0.
                   3646: 
                   3647: @item @code{TERMINATOR} +R +U -D
                   3648: Sets or returns the @code{READ} terminator for the specified I/O channel. Must be either @code{$C(13,10)} or @code{$C(10)}. Currently only supported for socket devices (those having an I/O channel of 100-255).
                   3649: 
                   3650: @item @code{TERMID} +R -U -D
                   3651: Returns the type of terminal connected to channel 0. Only valid for I/O channel 0.
                   3652: 
                   3653: @item @code{ECHO} +R +U -D
                   3654: Enables or disables local echo of characters typed in a @code{READ} command. Only valid for I/O channel 0. Corresponds to bit 0 of the Device Status Word.
                   3655: 
                   3656: @item @code{DELMODE} +R +U -D
                   3657: Enables or disables visual backspace during a @code{READ} command. Only valid for I/O channel 0. Corresponds to bit 2 of the Device Status Word.
                   3658: 
                   3659: @item @code{ESCAPE} +R +U -D
                   3660: Enables or disables escape sequence processing during a @code{READ} command. Only valid for I/O channel 0. Corresponds to bit 6 of the Device Status Word.
                   3661: 
                   3662: @item @code{CONVUPPER} +R +U -D
                   3663: Enables or disables automatic conversion to uppercase of alphabetical characters during a @code{READ} command. Only valid for I/O channel 0. Corresponds to bit 14 of the Device Status Word.
                   3664: 
                   3665: @item @code{DELEMPTY} +R +U -D
                   3666: Enables or disables the automatic deletion of empty strings supplied to a @code{READ} command. Only valid for I/O channel 0. Corresponds to bit 19 of the Device Status Word.
                   3667: 
                   3668: @item @code{NOCTRLS} +R +U -D
                   3669: TBD. Only valid for I/O channel 0. Corresponds to bit 20 of the Device Status Word.
                   3670: 
                   3671: @item @code{CTRLOPROC} +R +U -D
                   3672: Enables or disables @emph{Ctrl-O} processing during @code{READ} commands. Only valid for I/O channel 0. Corresponds to bit 21 of the Device Status Word.
                   3673: 
                   3674: @item @code{NOTYPEAHEAD} +R +U -D
                   3675: Enables or disables typeahead buffering during @code{READ} commands. Only valid for I/O channel 0. Corresponds to bit 25 of the Device Status Word.
                   3676: @end table
                   3677: @end table
                   3678: 
                   3679: @emph{Example}
                   3680: 
                   3681: The following example M code opens @code{/etc/freem.conf} and reads its contents line-by-line until the end of the file is reached.
                   3682: 
                   3683: @example
                   3684:  SET ^$JOB($JOB,"IOPATH")="/etc"   ; set I/O path to /etc
                   3685:  OPEN 1:"freem.conf/r" ; open freem.conf for reading
                   3686:  ;
                   3687:  ; read until we run out of lines
                   3688:  ;
                   3689:  FOR  USE 1 READ LINE USE 0 QUIT:^$DEVICE(1,"EOF")  D
                   3690:  . WRITE LINE,!
                   3691:  ;
                   3692:  CLOSE 1
                   3693:  QUIT
                   3694: @end example
                   3695: 
                   3696: @node ^$DISPLAY
                   3697: @section ^$DISPLAY
                   3698: @cindex ^$DISPLAY
                   3699: @cindex structured system variables, ^$DISPLAY
                   3700: 
                   3701: Provides information about the specified graphical display. The first subscript corresponds to a display number, which is an integer value, often corresponding to the current value of the @code{$PDISPLAY} ISV.
                   3702: 
                   3703: The following second-level subscripts and specified descendant subscripts are supported:
                   3704: 
                   3705: @table @asis
                   3706: 
                   3707: @item @code{CLIPBOARD} +R +U +D
                   3708: Retrieves, sets, or erases the contents of the system clipboard.
                   3709: 
                   3710: @item @code{PLATFORM} +R -U -D
                   3711: Retrieves the name and version of the underlying window system platform.
                   3712: 
                   3713: @item @code{SIZE} +R -U -D
                   3714: Retrieves the display resolution of the specified graphical display. For instance, a 1080p display would have a @code{SIZE} value of @code{1920,1080}.
                   3715: 
                   3716: @item @code{SPECTRUM} +R -U -D
                   3717: Retrieves the color depth (number of colors supported) of the specified graphical display.
                   3718: 
                   3719: @item @code{COLORTYPE} +R -U -D
                   3720: Always returns @code{COLOR}, as monochrome and grayscale displays are not yet supported in FreeM.
                   3721: 
                   3722: @item @code{UNITS} +R -U -D
                   3723: Returns the measurement unit of the specified display, i.e., @code{PIXEL}.
                   3724: 
                   3725: @item @code{TYPEFACE} +R -U -D
                   3726: The third-level subscripts beneath this subscript represent a list of font families available on this display. The fourth level subscript is a list of sizes supported for the specified typeface, or @code{0} for vector typefaces, such as TrueType, OpenType, and Adobe Type 1 fonts.
                   3727: 
                   3728: @end table
                   3729: 
                   3730: @node ^$EVENT
                   3731: @section ^$EVENT
                   3732: @cindex ^$EVENT
                   3733: @cindex structured system variables, ^$EVENT
                   3734: 
                   3735: The @code{^$EVENT} SSVN is not yet implemented.
                   3736: 
                   3737: @node ^$GLOBAL
                   3738: @section ^$GLOBAL
                   3739: @cindex ^$GLOBAL
                   3740: @cindex structured system variables, ^$GLOBAL
                   3741: 
                   3742: The @code{^$GLOBAL} structured system variable provides information about M globals. The first-level subscript is a global name, sans the leading caret symbol.
                   3743: 
                   3744: The following second-level subscripts are supported:
                   3745: 
                   3746: @table @asis
                   3747: 
                   3748: @item @code{BYTES} +R -U -D
                   3749: Returns the number of bytes this global occupies in fixed storage.
                   3750: 
                   3751: @item @code{BLOCKS} +R -U -D
                   3752: Returns the number of blocks contained in this global.
                   3753: 
                   3754: @item @code{BLOCKSIZE} +R -U -D
                   3755: Returns the size of data blocks for this global. Currently, FreeM only supports 1024-byte blocks.
                   3756: 
                   3757: @item @code{FILE} +R -U -D
                   3758: Returns the full filesystem path to the data file where this global resides in fixed storage.
                   3759: 
                   3760: @item @code{NAMESPACE} +R +U +D
                   3761: Returns or sets the name of the FreeM namespace to which this global belongs. @code{SET}ting this node creates a mapping for the specified global name to a non-default namespace. @code{KILL}ing this node restores the mapping configuration for the specified global to the default.
                   3762: 
                   3763: @end table
                   3764: 
                   3765: @node ^$JOB
                   3766: @section ^$JOB
                   3767: @cindex ^$JOB
                   3768: @cindex structured system variables, ^$JOB
                   3769: 
                   3770: FreeM fully implements @code{^$JOB} per ANSI X11.1-1995, as well as several extensions proposed in the M Millennium Draft Standard.
                   3771: 
                   3772: The first subscript of @code{^$JOB} represents the @code{$JOB} of the process.
                   3773: 
                   3774: If you @code{KILL} a first-level subscript of @code{^$JOB}, the @code{SIGTERM} signal will be sent to the corresponding UNIX process, causing pending transactions to be rolled back and the process to be terminated. If the targeted process is in direct mode, the user will be prompted with options of either rolling back or committing any pending transactions.
                   3775: 
                   3776: The following subscripts are supported:
                   3777: 
                   3778: @table @asis
                   3779: 
                   3780: @item @code{GVNDEFAULT} +R +U +D
                   3781: Contains a default expression to be evaluated if a global variable access attempt results in an @code{M7} error.
                   3782: 
                   3783: Equivalent to wrapping all global accesses in @code{$GET(@emph{global-name},@emph{string-expr})}.
                   3784: 
                   3785: @item @code{LVNDEFAULT} +R +U +D
                   3786: Contains a default expression to be evaluated if a local variable access attempt results in an @code{M6} error.
                   3787: 
                   3788: Equivalent to wrapping all local accesses in @code{$GET(@emph{global-name},@emph{string-expr})}.
                   3789: 
                   3790: @item @code{LVNQOVAL} +R +U +D
                   3791: Contains the data value (if any) at the subscripted local variable reference from the most recent @code{$ORDER} or @code{$QUERY} operation.
                   3792: 
                   3793: This node is useful for code that uses @code{$ORDER} or @code{$QUERY} heavily in loops that retrieve successive data values, as it will prevent an additional symbol table scan that would result from retrieving the data value in the usual way, thus improving application performance. However, this optimization comes at the cost of compatibility with other M implementations.
                   3794: 
                   3795: @item @code{GVNQOVAL} +R +U +D
                   3796: Contains the data value (if any) at the subscripted global variable reference from the most recent @code{$ORDER} or @code{$QUERY} operation.
                   3797: 
                   3798: This node is useful for code that uses @code{$ORDER} or @code{$QUERY} heavily in loops that retrieve successive data values, as it will prevent an additional data file scan that would result from retrieving the data value in the usual way, thus improving application performance. However, this optimization comes at the cost of compatibility with other M implementations.
                   3799: 
                   3800: @item @code{ZCOMMANDS} +R +U -D
                   3801: Contains a space-delimited list of @code{Z}-commands to be treated as intrinsic. Any @code{Z}-command not appearing in this list will be treated as a user-defined command.
                   3802: 
                   3803: For instance, if command @code{ZFOO} does @emph{not} appear in this list, FreeM will attempt to run @code{^%ZFOO} as a subroutine when the @code{ZFOO} command is encountered in program code.
                   3804: 
                   3805: If you remove a command from this list, you may provide your own private M implementation of the command in the manner described above.
                   3806: 
                   3807: If an argument is passed to a @code{Z}-command you implement in M, it is made available to your M code in a variable whose name is specified in @code{^$JOB($JOB,"ZCOMMAND_ARGUMENT_NAME")}, which defaults to @code{%}.
                   3808: 
                   3809: @item @code{PIPE_GLVN} +R +U -D
                   3810: Contains an M local or global variable to be used as standard input or standard output for the external shell commands run by @code{!<} and @code{!>}.
                   3811: 
                   3812: @item @code{ZCOMMAND_ARGUMENT_NAME} +R +U -D
                   3813: Returns or sets the variable name in which arguments to user-defined @code{Z}-commands are passed. Defaults to @code{%}.
                   3814: 
                   3815: @item @code{ZFUNCTIONS} +R +U -D
                   3816: Contains a space-delimited list of @code{Z} functions to be treated as intrinsic. Any @code{Z} function not appearing in this list will be treated as a user-defined extrinsic function.
                   3817: 
                   3818: For instance, if function @code{$ZFOO} does @emph{not} appear in this list, FreeM will attempt to return the value of @code{$$^%ZFOO} called as an extrinsic function.
                   3819: 
                   3820: If you remove a function from this list, you may provide your own private M implementation of the function in the manner described above.
                   3821: 
                   3822: @item @code{ZSVS} +R +U -D
                   3823: Contains a space-delimited list of @code{Z} special variables to be treated as intrinsic. Any @code{Z} special variable  not appearing in this list will be treated as a user-defined extrinsic function taking no arguments.
                   3824: 
                   3825: For instance, if the special variable @code{$ZFOO} does @emph{not} appear in this list, FreeM will attempt to return the value of @code{$$^%ZFOO} called as an extrinsic function.
                   3826: 
                   3827: If you remove a built-in special variable from this list, you may provide your own private M implementation of the special variable in the manner described above.
                   3828: 
                   3829: @item @code{BREAK_HANDLER} +R +U -D
                   3830: Contains M code to be executed when the @code{BREAK} command is run.
                   3831: 
                   3832: @item @code{ROUTINE_BUFFER_SIZE} +R +U -D
                   3833: Returns or sets the number of bytes allocated to each routine buffer. If @code{ROUTINE_BUFFER_AUTO_ADJUST} is set to @code{0}, this determines the maximum size of routines that FreeM will execute.
                   3834: 
                   3835: @item @code{ROUTINE_BUFFER_COUNT} +R +U -D
                   3836: Returns or sets the number of routine buffers that FreeM will store in memory concurrently. Raising this value will increase memory usage, but will also increase performance if your applications call many different routines repeatedly.
                   3837: 
                   3838: @item @code{ROUTINE_BUFFER_AUTO_ADJUST} +R +U -D
                   3839: Determines whether or not the size of routine buffers will be automatically adjusted at runtime. If set to @code{0}, routine buffers will be fixed to the byte size specified in @code{ROUTINE_BUFFER_SIZE} and may be manually resized using @code{ROUTINE_BUFFER_SIZE}. If set to @code{1}, routine buffers will grow automatically as necessary.
                   3840: 
                   3841: @item @code{SYMBOL_TABLE_SIZE} +R +U -D
                   3842: Returns or sets the number of bytes allocated to each of the two FreeM symbol tables. If @code{SYMBOL_TABLE_AUTO_ADJUST} is @code{1}, this value is treated as a default, initial size. If @code{SYMBOL_TABLE_AUTO_ADJUST} is @code{0}, this value controls the fixed size of the two symbol tables.
                   3843: 
                   3844: @item @code{SYMBOL_TABLE_AUTO_ADJUST} +R +U -D
                   3845: Determines whether or not the size of the two FreeM symbol tables will be automatically adjusted at runtime. If set to @code{0}, the symbol table will be fixed to the byte size specified in @code{SYMBOL_TABLE_SIZE} and may be manually resized by modifying @code{SYMBOL_TABLE_SIZE}. If set to @code{1}, the two symbol tables will grow automatically as necessary.
                   3846: 
                   3847: 
                   3848: @item @code{USER_DEFINED_ISV_TABLE_SIZE} +R +U -D
                   3849: Returns or sets the number of bytes allocated to the FreeM user-defined intrinsic special variable table. If @code{USER_DEFINED_ISV_TABLE_AUTO_ADJUST} is @code{1}, this value is treated as a default, initial size. If @code{USER_DEFINED_ISV_TABLE_AUTO_ADJUST} is @code{0}, this value controls the fixed byte size of the user-defined intrinsic special variable table.
                   3850: 
                   3851: @item @code{USER_DEFINED_ISV_TABLE_AUTO_ADJUST} +R +U -D
                   3852: Determines whether or not the size of the FreeM user-defined intrinsic special variable table will be automatically adjusted at runtime. If set to @code{0}, the user-defined ISV table will be fixed to the byte size specified in @code{USER_DEFINED_ISV_TABLE_SIZE} and may be manually resized by modifying @code{USER_DEFINED_ISV_TABLE_SIZE}. If set to @code{1}, the user-defined ISV table will grow automatically as necessary.
                   3853: 
                   3854: @item @code{GVN_UNIQUE_CHARS} +R +U -D
                   3855: Returns or sets the number of characters of a global name that make it unique, from 1 to 255.
                   3856: 
                   3857: @item @code{GVN_CASE_SENSITIVE} +R +U -D
                   3858: Returns or sets the case sensitivity of global names. If set to @code{0}, global names are case-insensitive. If set to @code{1}, global names are case-sensitive.
                   3859: 
                   3860: @item @code{GVN_NAME_SUB_LENGTH} +R +U -D
                   3861: Returns or sets the maximum number of characters of a global name plus all of its subscripts, from 1-255.
                   3862: 
                   3863: @item @code{GVN_SUB_LENGTH} +R +U -D
                   3864: Returns or sets the maximum number of characters of a single global subscript, from 1-255.
                   3865: 
                   3866: @item @code{SINGLE_USER} +R +U -D
1.27    ! snw      3867: If set to @code{1}, FreeM will skip all file locking operations on globals. If set to @code{0}, FreeM will enforce file locking on both.
1.1       snw      3868: 
1.27    ! snw      3869: Setting @code{SINGLE_USER} to @code{1} will improve FreeM performance, but you must @emph{ONLY} use this on systems where you are absolutely sure that only one FreeM process will run at any given time, as running multiple instances of FreeM concurrently when any of them are set to @code{SINGLE_USER} mode @emph{will} cause global data corruption.
1.1       snw      3870: 
                   3871: @item @code{CHARACTER} +R -U -D
                   3872: Returns the character set of the job.
                   3873: 
                   3874: @item @code{CWD} +R +U -D
                   3875: Returns or sets the current working directory of the job.
                   3876: 
                   3877: @item @code{OPEN} +R -U -D
                   3878: The @code{^$JOB($JOB,"OPEN",<channel>} subscripts list the open I/O channels in the specified job.
                   3879: 
                   3880: @item @code{BERKELEYDB,FLUSH_THRESHOLD} +R +U -D
                   3881: Returns or sets the number of write operations that will be cached in the BerkeleyDB global handler prior to flushing BerkeleyDB's cache to disk.
                   3882: 
                   3883: @item @code{EVENT} +R +U +D
                   3884: The subtree contained under @code{^$JOB($J,"EVENT")} defines asynchronous event handlers for the current job. Please see @emph{Asynchronous Event Handling} for more information.
                   3885: 
                   3886: @item @code{GLOBAL} +R -U -D
                   3887: Returns the global environment of the job.
                   3888: 
                   3889: @item @code{IOPATH} +R +U -D
                   3890: Returns or sets the @emph{I/O path} to be used by the @code{OPEN} command.
                   3891: 
                   3892: @item @code{PRIORITY} +R +U -D
                   3893: Returns or sets the @emph{nice} value of the FreeM job.
                   3894: 
                   3895: @item @code{REVSTR} +R +U -D
                   3896: When set to 1, allows @code{$EXTRACT} to accept negative values.
                   3897: 
                   3898: @item @code{ROUTINE} +R -U -D
                   3899: Returns the name of the routine currently being executed by the job.
                   3900: 
                   3901: @item @code{SYMTAB} +R +U -D
                   3902: Returns or sets the current local variable symbol table in use.
                   3903: 
                   3904: FreeM supports two unique and independent symbol tables, allowing FreeM programs to maintain two independent sets of identically- or differently-named local variables per process.
                   3905: 
                   3906: The default symbol table is @code{0}, and the alternate symbol table is @code{1}, corresponding to the valid values for @code{^$JOB($JOB,"SYMTAB")}.
                   3907: 
                   3908: Setting this subscript to values other than @code{0} or @code{1} will result in a @code{ZINVEXPR} error.
                   3909: 
                   3910: @item @code{$PDISPLAY} +R -U -D
                   3911: Returns the value of @code{$PDISPLAY} for the job.
                   3912: 
                   3913: @item @code{$PRINCIPAL} +R -U -D
                   3914: Returns the value of @code{$PRINCIPAL} for the job.
                   3915: 
                   3916: @item @code{$TLEVEL} +R -U -D
                   3917: Returns the current transaction level (value of @code{$TLEVEL} for the job.
                   3918: 
                   3919: @item @code{$IO} +R -U -D
                   3920: Returns the current value of @code{$IO} for the job.
                   3921: 
                   3922: @item @code{USER} +R -U -D
                   3923: Returns the UID of the user owning the job.
                   3924: 
                   3925: @item @code{GROUP} +R -U -D
                   3926: Returns the GID of the group owning the job.
                   3927: 
                   3928: @item @code{NAMESPACE} +R +U -D
                   3929: Returns or sets the name of the job's currently-active namespace.
                   3930: 
                   3931: @item @code{MATH} +R +U -D
                   3932: Returns or sets the mode in which decimal comparisons and arithmetic calculations are conducted. Valid values are @code{FIXED}, for fixed-point decimals having up to 20,000 digits of precision, as determined by the @code{$ZPRECISION} intrinsic special variable, and @code{IEEE754}, to use IEEE 754 floating-point decimals. When in @code{IEEE754} mode, floating-point numbers support up to 16 digits of numeric precision.
                   3933: 
                   3934: @code{IEEE754} mode will make mathematical calculations significantly faster, especially when accelerated by a floating-point processor, at the expense of precision and accuracy.
                   3935: 
                   3936: @code{FIXED} mode is recommended for financial calculations, or where precision and accuracy are valued over performance. @code{FIXED} is the default mode of FreeM operation.
                   3937: 
                   3938: Attempting to @code{SET} this node to values other than @code{FIXED} or @code{IEEE754} will set @code{$ECODE} to @code{M29}.
                   3939: 
                   3940: @end table
                   3941: 
                   3942: @node ^$LOCK
                   3943: @section ^$LOCK
                   3944: @cindex ^$LOCK
                   3945: @cindex structured system variables, ^$LOCK
                   3946: 
                   3947: The first-level subscript of @code{^$LOCK} is a lock name. The value at each node is the PID which owns the lock, a comma, and the lock counter for the locked resource.
                   3948: 
                   3949: Attempting to @code{SET} or @code{KILL} any node in @code{^$LOCK} will raise error @code{M29}.
                   3950: 
                   3951: @node ^$OBJECT
                   3952: @section ^$OBJECT
                   3953: @cindex ^$OBJECT
                   3954: @cindex structured system variables, ^$OBJECT
                   3955: 
                   3956: @node ^$ROUTINE
                   3957: @section ^$ROUTINE
                   3958: @cindex ^$ROUTINE
                   3959: @cindex structured system variables, ^$ROUTINE
                   3960: 
                   3961: The @code{^$ROUTINE} SSVN exposes a list of routines available in the current FreeM namespace, as well as additional attributes further describing each routine.
                   3962: 
                   3963: The first-level subscript is the name of a FreeM routine minus the leading caret symbol.
                   3964: 
                   3965: The following second-level subscripts are supported:
                   3966: 
                   3967: @table @asis
                   3968: 
                   3969: @item @code{CHARACTER} +R -U -D
                   3970: Returns the character set of the routine.
                   3971: 
                   3972: @item @code{NAMESPACE} +R -U -D
                   3973: Returns the name of the FreeM namespace in which the routine resides.
                   3974: 
                   3975: @item @code{PATH} +R -U -D
                   3976: Returns the full filesystem path to the routine in fixed storage.
                   3977: 
                   3978: @end table
                   3979: 
                   3980: @node ^$SYSTEM
                   3981: @section ^$SYSTEM
                   3982: @cindex ^$SYSTEM
                   3983: @cindex structured system variables, ^$SYSTEM
                   3984: 
                   3985: The @code{^$SYSTEM} SSVN exposes system-level implementation details.
                   3986: 
                   3987: The following first-level subscripts are supported:
                   3988: 
                   3989: @table @asis
                   3990: 
                   3991: @item @code{DEFPSIZE} +R -U -D
                   3992: Returns the default size in bytes of the symbol table and routine buffer memory partition.
                   3993: 
                   3994: @item @code{DEFUDFSVSIZ} +R -U -D
                   3995: Returns the default size in bytes of the user-defined intrinsic special variable table.
                   3996: 
                   3997: @item @code{DEFNSIZE} +R -U -D
                   3998: Returns the default size of the @code{NEW} stack, in number of entries.
                   3999: 
                   4000: @item @code{MAXNO_OF_RBUF} +R -U -D
                   4001: Returns the maximum number of routine buffers.
                   4002: 
                   4003: @item @code{DEFNO_OF_RBUF} +R -U -D
                   4004: Returns the default number of routine buffers.
                   4005: 
                   4006: @item @code{DEFPSIZE0} +R -U -D
                   4007: Returns the default size in bytes of each routine buffer.
                   4008: 
                   4009: @item @code{NO_GLOBLS} +R -U -D
                   4010: Returns the maximum number of globals that can be concurrently opened.
                   4011: 
                   4012: @item @code{NO_OF_GBUF} +R -U -D
                   4013: Returns the number of global buffers.
                   4014: 
                   4015: @item @code{NESTLEVLS} +R -U -D
                   4016: Returns the depth of the @code{DO}, @code{FOR}, @code{XECUTE} stack.
                   4017: 
                   4018: @item @code{PARDEPTH} +R -U -D
                   4019: Returns the maximum depth of the parser's parameter stack.
                   4020: 
                   4021: @item @code{PATDEPTH} +R -U -D
                   4022: Returns the maximum number of @emph{patatom}s in each pattern.
                   4023: 
                   4024: @item @code{TRLIM} +R -U -D
                   4025: Returns the trace limit of the @code{BUILTIN} global handler.
                   4026: 
                   4027: @item @code{ARGS_IN_ESC} +R -U -D
                   4028: Returns the maximum number of arguments in a terminal escape sequence.
                   4029: 
                   4030: @item @code{ZTLEN} +R -U -D
                   4031: Returns the maximum length of @code{$ZTRAP}.
                   4032: 
                   4033: @item @code{FUNLEN} +R -U -D
                   4034: Returns the maximum length of the @code{$ZF} (function key) variable.
                   4035: 
                   4036: @item @code{NAME_LENGTH} +R -U -D
                   4037: Returns the maximum length of variable names in the current FreeM build. Compatible with the same SSVN node in @emph{Reference Standard M}
                   4038: 
                   4039: @item @code{STRING_MAX} +R -U -D
                   4040: Returns the maximum length of character strings in the current FreeM build. Compatible with the same SSVN node in @emph{Reference Standard M}
                   4041: 
                   4042: @item @code{$NEXTOK} +R -U -D
                   4043: Returns a value indicating whether or not the @code{$NEXT} intrinsic function is allowed. In FreeM, @code{$NEXT} is always enabled, and this SSVN is provided solely for compatibility with @emph{Reference Standard M}. Thus, this SSVN node always returns @code{1}.
                   4044: 
                   4045: @item @code{EOK} +R -U -D
                   4046: Returns a value indicating whether or not @code{E} notation for exponents is allowed. In FreeM, this feature is always enabled, and this SSVN is provided solely for compatibility with @emph{Reference Standard M}. Thus, this SSVN node always returns @code{1}.
                   4047: 
                   4048: @item @code{OFFOK} +R -U -D
                   4049: Returns a value indicating whether or not offsets are allowed in @code{DO} and @code{GOTO}. In FreeM, this feature is always enabled, and this SSVN is provided solely for compatibility with @emph{Reference Standard M}. Thus, this SSVN node always returns @code{1}.
                   4050: 
                   4051: @item @code{BIG_ENDIAN} +R -U -D
                   4052: Returns a 1 if FreeM is running on a big-endian platform, or a 0 otherwise. Compatible with the same SSVN node in @emph{Reference Standard M}.
                   4053: 
                   4054: @item @code{NAMESPACE} +R -U -D
                   4055: The descendant subscripts of this node list each namespace in the current FreeM environment.
                   4056: 
                   4057: @item @code{MAPPINGS,GLOBAL} +R -U -D
                   4058: Descendant subscripts of this node represent global name mappings set in @code{^$GLOBAL(@emph{gvn},"NAMESPACE")}
                   4059: 
                   4060: @end table
                   4061: 
                   4062: @node ^$WINDOW
                   4063: @section ^$WINDOW
                   4064: @cindex ^$WINDOW
                   4065: @cindex structured system variables, ^$WINDOW
                   4066: 
                   4067: The @code{^$WINDOW} SSVN has no nodes yet defined. However, completing a @code{MERGE} to this SSVN will cause MWAPI-ish things to happen, and further work is proceeding on MWAPI implementation.
                   4068: 
                   4069: @node ^$ZPROCESS
                   4070: @section ^$ZPROCESS
                   4071: @cindex ^$ZPROCESS
                   4072: @cindex structured system variables, ^$ZPROCESS
                   4073: 
                   4074: Provides access to @code{procfs}, which is a filesystem-like abstraction for UNIX process metadata contained in @code{/proc}, as well as features for examining and controlling the state of processes external to the FreeM interpreter.
                   4075: 
                   4076: The first subscript always represents the @emph{process ID} of the external process being acted upon.
                   4077: 
                   4078: The following values for the second subscript are supported:
                   4079: 
                   4080: 
                   4081: @table @asis
                   4082: 
                   4083: @item @code{EXISTS} +R -U -D
                   4084: Returns 1 if the referenced process exists; 0 otherwise.
                   4085: 
                   4086: @item @code{ATTRIBUTE} +R -U -D
                   4087: Exposes the @code{/proc} files as descendant subscripts, i.e., @code{WRITE ^$ZPROCESS(2900,"ATTRIBUTE","cmdline"),!} would print the initial command line used to invoke process ID 2900. Note that the third subscript (the immediate descendant of the @code{ATTRIBUTE} subscript) is case sensitive.
                   4088: 
                   4089: @item @code{SIGNAL} -R +U -D
                   4090: Allows signals to be sent to the referenced process. The following subscript is an integer value corresponding to the desired signal number. You may obtain a list of signal numbers on most UNIX systems with the command @code{kill -l}.
                   4091: 
                   4092: The constants @code{%SYS.SIGNAL.HUP}, @code{%SYS.SIGNAL.INT}, @code{%SYS.SIGNAL.KILL}, and @code{%SYS.SIGNAL.TERM} are provided for convenient use of this SSVN subscript.
                   4093: 
                   4094: @end table
                   4095: 
                   4096: @node ^$ZRPI
                   4097: @section ^$ZRPI
                   4098: @cindex ^$ZRPI
                   4099: @cindex structured system variables, ^$ZRPI
                   4100: 
                   4101: The @code{^$ZRPI} structured system variable provides easy access to general-purpose input/output (GPIO) pins on Raspberry Pi single-board computers.
                   4102: 
                   4103: To initialize the GPIO subsystem, @code{SET ^$ZRPI("INITIALIZE")=1}.
                   4104: 
                   4105: Individual pins are accessed through @code{^$ZRPI("GPIO",<pin>,...)}, where @code{<pin>} represents the desired pin number. Descendant subscripts of @code{^$ZRPI("GPIO",<pin>)} are as follows:
                   4106: 
                   4107: @table @asis
                   4108: 
                   4109: @item @code{MODE} +R +U -D
                   4110: Represents the operating mode of the selected pin. One of @code{INPUT}, @code{OUTPUT}, @code{PWM_OUTPUT}, or @code{GPIO_CLOCK}.
                   4111: 
                   4112: @item @code{DIGITAL} +R +U -D
                   4113: Reads or writes the selected pin digitally. The value is limited to @code{1} or @code{0}.
                   4114: 
                   4115: @item @code{ANALOG} +R +U -D
                   4116: Reads or writes the selected pin in an analog fashion. The value represents analog voltage.
                   4117: 
                   4118: @end table
                   4119: 
                   4120: @node Operators
                   4121: @chapter Operators
                   4122: 
                   4123: @menu
                   4124: * Unary +::                     Force a value to positive.
                   4125: * Unary -::                     Force a value to negative.
                   4126: * +::                           Add.
                   4127: * +=::                          Add and assign.
                   4128: * ++::                          Postfix increment.
                   4129: * -::                           Subtract.
                   4130: * -=::                          Subtract and assign.
                   4131: * --::                          Postfix decrement.
                   4132: * *::                           Multiply.
                   4133: * *=::                          Multiply and assign.
                   4134: * /::                           Divide.
                   4135: * /=::                          Divide and assign.
                   4136: * \::                           Integer divide.
                   4137: * \=::                          Integer divide and assign.
                   4138: * #::                           Modulo.
                   4139: * #=::                          Modulo and assign.
                   4140: * **::                          Exponentiate.
                   4141: * **=::                         Exponentiate and assign.
                   4142: * <::                           Less than.
                   4143: * <=::                          Less than or equal to.
                   4144: * >::                           Greater than.
                   4145: * >=::                          Greater than or equal to.
                   4146: * _::                           Concatenate.
                   4147: * _=::                          Concatenate and assign.
                   4148: * =::                           Equals.
                   4149: * [::                           Contains.
                   4150: * ]::                           Follows.
                   4151: * ]]::                          Sorts after.
                   4152: * ?::                           Pattern match.
                   4153: * &::                           Logical AND.
                   4154: * ! (Operator)::                Logical OR.
                   4155: * '::                           Logical NOT.
                   4156: * @@ (Operator)::               Indirect
                   4157: @end menu
                   4158: 
                   4159: @node Unary +
                   4160: @section Unary +
                   4161: @cindex operators, unary +
                   4162: 
                   4163: Forces a number to positive, whether positive or negative. Also forces numeric coercion of strings.
                   4164: 
                   4165: @node Unary -
                   4166: @section Unary -
                   4167: @cindex operators, unary -
                   4168: 
                   4169: @node +
                   4170: @section + (Add)
                   4171: @cindex operators, +
                   4172: 
                   4173: @node +=
                   4174: @section += (Add/Assign)
                   4175: @cindex operators, +=
                   4176: 
                   4177: @node ++
                   4178: @section ++ (Postfix Increment)
                   4179: @cindex operators, ++
                   4180: 
                   4181: @node -
                   4182: @section - (Subtract)
                   4183: @cindex operators, -
                   4184: 
                   4185: @node -=
                   4186: @section -= (Subtract/Assign)
                   4187: @cindex operators, -=
                   4188: 
                   4189: @node --
                   4190: @section -- (Postfix Decrement)
                   4191: @cindex operators, --
                   4192: 
                   4193: @node *
                   4194: @section * (Multiply)
                   4195: @cindex operators, *
                   4196: 
                   4197: @node *=
                   4198: @section *= (Multiply/Assign)
                   4199: @cindex operators, *=
                   4200: 
                   4201: @node /
                   4202: @section / (Divide)
                   4203: @cindex operators, /
                   4204: 
                   4205: @node /=
                   4206: @section /= (Divide/Assign)
                   4207: @cindex operators, /=
                   4208: 
                   4209: @node \
                   4210: @section \ (Integer Divide)
                   4211: @cindex operators, \
                   4212: 
                   4213: @node \=
                   4214: @section \= (Integer Divide/Assign)
                   4215: @cindex operators, \=
                   4216: 
                   4217: @node #
                   4218: @section # (Modulo)
                   4219: @cindex operators, #
                   4220: 
                   4221: @node #=
                   4222: @section #= (Modulo/Assign)
                   4223: @cindex operators, #=
                   4224: 
                   4225: @node **
                   4226: @section ** (Exponentiate)
                   4227: @cindex operators, **
                   4228: 
                   4229: @node **=
                   4230: @section **= (Exponentiate/Assign)
                   4231: @cindex operators, **=
                   4232: 
                   4233: @node <
                   4234: @section < (Less Than)
                   4235: @cindex operators, <
                   4236: 
                   4237: @node <=
                   4238: @section <= (Less Than or Equal To)
                   4239: @cindex operators, <=
                   4240: 
                   4241: @node >
                   4242: @section > (Greater Than)
                   4243: @cindex operators, >
                   4244: 
                   4245: @node >=
                   4246: @section >= (Greater Than or Equal To)
                   4247: @cindex operators, >=
                   4248: 
                   4249: @node _
                   4250: @section _ (Concatenate)
                   4251: @cindex operators, _
                   4252: 
                   4253: @node _=
                   4254: @section _= (Concatenate/Assign)
                   4255: @cindex operators, _=
                   4256: 
                   4257: @node =
                   4258: @section = (Equals)
                   4259: @cindex operators, =
                   4260: 
                   4261: @node [
                   4262: @section [ (Contains)
                   4263: @cindex operators, [
                   4264: 
                   4265: @node ]
                   4266: @section ] (Follows)
                   4267: @cindex operators, ]
                   4268: 
                   4269: @node ]]
                   4270: @section ]] (Sorts After)
                   4271: @cindex operators, ]]
                   4272: 
                   4273: @node ?
                   4274: @section ? (Pattern Match)
                   4275: @cindex operators, ?
                   4276: 
                   4277: @node &
                   4278: @section & (Logical AND)
                   4279: @cindex operators, &
                   4280: 
                   4281: @node ! (Operator)
                   4282: @section ! (Logical OR)
                   4283: @cindex operators, !
                   4284: 
                   4285: @node '
                   4286: @section ' (Logical NOT)
                   4287: @cindex operators, '
                   4288: 
                   4289: @node @@ (Operator)
                   4290: @section @@ (Indirect)
                   4291: @cindex operators, @@
                   4292: 
                   4293: @node Routines
                   4294: @chapter Routines
                   4295: @cindex routines
                   4296: 
                   4297: A @emph{routine} is a file containing M source code to be processed by FreeM.
                   4298: 
                   4299: Routines exist within a @emph{namespace} (such as @code{SYSTEM} or @code{USER}), which in turn exist within an @emph{environment} (such as @code{DEFAULT}).
                   4300: 
                   4301: @menu
                   4302: * Routine Naming::              Requirements and conventions for routine names.
                   4303: @end menu
                   4304: 
                   4305: 
                   4306: @node Routine Naming
                   4307: @section Routine Naming
                   4308: The routine's filename follows the format @code{NAME.m}, where @code{NAME} is the name of the routine, and @code{.m} is the filename extension.
                   4309: 
                   4310: Routine naming rules are as follows:
                   4311: 
                   4312: @itemize @bullet
                   4313: @item Routine names must begin with an upper- or lower-case letter, or a @code{%} sign
                   4314: @item Within the routine name, you may have upper-case or lower-case letters or digits
                   4315: @item The entire routine name must not be longer than 255 characters
                   4316: @end itemize
                   4317: 
                   4318: Routines whose names begin with @code{%} must be located in the @code{SYSTEM} namespace. Other routines may be located in any namespace.
                   4319: 
                   4320: @node Types
                   4321: @chapter Types
                   4322: @cindex types
                   4323: @cindex data types
                   4324: 
                   4325: FreeM supports all @emph{libdatatype} types defined in the former MDC's @emph{Millennium Draft Standard}, with the exception of @code{MATRIX}, and with extensions supporting object-oriented programming. A notable enhancement in FreeM is that the library data types can be used in the @emph{formallist} of any extrinsic function or subroutine; not only in @emph{libraryelement}s.
                   4326: 
                   4327: @menu
                   4328: * BOOLEAN::                     Truth values.
                   4329: * COMPLEX::                     Numbers with real and imaginary parts.
                   4330: * INTEGER::                     Numbers with no decimal part.
                   4331: * REAL::                        Numbers with a decimal part.
                   4332: * STRING::                      Arbitrary strings of characters.
                   4333: * Custom Types (Classes)::      User-defined, object-oriented types.
                   4334: @end menu
                   4335: 
                   4336: @node BOOLEAN
                   4337: @section BOOLEAN
                   4338: @cindex data types, BOOLEAN
                   4339: @cindex types, BOOLEAN
                   4340: 
                   4341: The @code{BOOLEAN} type represents any M value that can be interpreted as a truth-value.
                   4342: 
                   4343: @node COMPLEX
                   4344: @section COMPLEX
                   4345: @cindex data types, COMPLEX
                   4346: @cindex types, COMPLEX
                   4347: 
                   4348: The @code{COMPLEX} type is a complex number represented as a string in the format @code{@emph{<real-part>}%@emph{<imaginary-part>}}, where @emph{real-part} and @emph{imaginary-part} are both @code{REAL} numbers. See @ref{REAL} for more information.
                   4349: 
                   4350: FreeM will attempt to interpret any @code{COMPLEX} value according to the usual rules for M canonical numbers, i.e., the string @code{sabc123.345%fbd3.1} would be interpreted as a complex number with the real part being @code{123.345} and the imaginary part being @code{3.1}.
                   4351: 
                   4352: @node INTEGER
                   4353: @section INTEGER
                   4354: @cindex data types, INTEGER
                   4355: @cindex types, INTEGER
                   4356: 
                   4357: An @code{INTEGER} is an interpretation of numeric data with any fractional part removed.
                   4358: 
                   4359: @node REAL
                   4360: @section REAL
                   4361: @cindex data types, REAL
                   4362: @cindex types, REAL
                   4363: 
                   4364: @node STRING
                   4365: @section STRING
                   4366: @cindex data types, STRING
                   4367: @cindex types, STRING
                   4368: 
                   4369: @node Custom Types (Classes)
                   4370: @section Custom Types (Classes)
                   4371: @cindex data types, custom
                   4372: @cindex types, custom
                   4373: @cindex classes
                   4374: 
                   4375: See @ref{Classes}.
                   4376: 
                   4377: @node Globals
                   4378: @chapter Globals
                   4379: @cindex globals
                   4380: @cindex variables, global
                   4381: @cindex data
                   4382: 
                   4383: @node Concurrency Control
                   4384: @chapter Concurrency Control
                   4385: @cindex concurrency control
                   4386: @cindex locking
                   4387: @cindex transaction processing
                   4388: 
                   4389: @node Local Variables
                   4390: @chapter Local Variables
                   4391: @cindex variables, local
                   4392: @cindex local variables
                   4393: 
                   4394: @node Scoping
                   4395: @chapter Scoping
                   4396: @cindex scoping
                   4397: 
                   4398: @node Decision Constructs
                   4399: @chapter Decision Constructs
                   4400: @cindex decision constructs
                   4401: @cindex IF
                   4402: @cindex ELSE
                   4403: @cindex THEN
                   4404: @cindex postconditionals
                   4405: 
                   4406: @node Branch Constructs
                   4407: @chapter Branch Constructs
                   4408: @cindex branch constructs
                   4409: @cindex DO
                   4410: @cindex GOTO
                   4411: @cindex JOB
                   4412: 
                   4413: @node Loop Constructs
                   4414: @chapter Loop Constructs
                   4415: @cindex loop constructs
                   4416: @cindex FOR
                   4417: 
                   4418: @node Modular Programming
                   4419: @chapter Modular Programming
                   4420: @cindex modular programming
                   4421: @cindex functions, extrinsic
                   4422: @cindex subroutines
                   4423: 
1.2       snw      4424: @menu
                   4425: * Subroutines::         Making sections of code reusable.
                   4426: * Extrinsic Functions:: Reusable code that returns a value.
                   4427: @end menu
                   4428: 
1.1       snw      4429: @node Subroutines
                   4430: @section Subroutines
                   4431: 
                   4432: @node Extrinsic Functions
                   4433: @section Extrinsic Functions
                   4434: 
                   4435: @node Object-Oriented Programming
                   4436: @chapter Object-Oriented Programming
                   4437: @cindex object-oriented programming
                   4438: @cindex programming, object-oriented
                   4439: 
1.2       snw      4440: @menu
                   4441: * Classes::             The basis of object-oriented programming.
                   4442: @end menu
                   4443: 
1.1       snw      4444: @node Classes
                   4445: @section Classes
                   4446: 
1.2       snw      4447: @menu
                   4448: * Inheritance::         Basing one class upon another.
                   4449: * Methods::             Attaching code to a class.
                   4450: * Public Variables::    Variables visible outside of a class.
                   4451: * Private Variables::   Variables only visible within a class.
                   4452: @end menu
                   4453: 
1.1       snw      4454: @node Inheritance
                   4455: @subsection Inheritance
                   4456: 
                   4457: @node Methods
                   4458: @subsection Methods
                   4459: 
                   4460: @node Public Variables 
                   4461: @subsection Public Variables
                   4462: 
                   4463: @node Private Variables
                   4464: @subsection Private Variables
                   4465: 
                   4466: @node Libraries
                   4467: @chapter Libraries
                   4468: @cindex libraries
                   4469: 
                   4470: @node Sequential I/O
                   4471: @chapter Sequential I/O
                   4472: 
                   4473: @node Network I/O
                   4474: @chapter Network I/O
                   4475: @cindex networks, input and output
                   4476: 
                   4477: Network I/O in FreeM is supplied through I/O channels 100-255. The normal @code{READ} and @code{WRITE} syntax will work with network sockets, with a few exceptions.
                   4478: 
                   4479: @section Opening and Connecting a Client Socket
                   4480: @cindex networks, opening and connecting client sockets
                   4481: 
                   4482: To open a client socket and connect to it, you will need to call the @code{OPEN} command and the @code{USE} command:
                   4483: 
                   4484: @example
                   4485:   ;
                   4486:   ; Set socket read terminator to LF
                   4487:   ;
                   4488:   SET ^$DEVICE(100,"OPTIONS","TERMINATOR")=$C(10)
                   4489:   ;
                   4490:   ; Open an IPv4 TCP socket to mail.mydomain.com on port 25 (SMTP)
                   4491:   ; and connect to it
                   4492:   ;
                   4493:   OPEN 100:"mail.mydomain.com:25:IPV4:TCP"
                   4494:   USE 100:/CONNECT
                   4495:   ;
                   4496:   ; Read a line of input from the remote host and write it to the terminal
                   4497:   ;
                   4498:   NEW LINE
                   4499:   READ LINE
                   4500:   USE 0
                   4501:   WRITE LINE,!
                   4502:   ;
                   4503:   ; CLOSE the socket and disconnect
                   4504:   ;
                   4505:   CLOSE 100
                   4506:   QUIT
                   4507: @end example
                   4508: 
                   4509: @node Extended Global References
                   4510: @chapter Extended Global References
                   4511: @cindex global references, extended
                   4512: @cindex extended global references
                   4513: 
                   4514: @section Standard Extended Global References
                   4515: @cindex extended global references, standard
                   4516: 
                   4517: FreeM supports extended global references, allowing the user to access globals in namespaces other than the current default namespace and the @code{SYSTEM} namespace, without switching to the other namespace.
                   4518: 
                   4519: For example, if you are in the @code{USER} namespace, the following code will print the value of @code{^VA(200,0)} in the @code{VISTA} namespace:
                   4520: 
                   4521: @example
                   4522:   WRITE ^|"VISTA"|VA(200,0),!
                   4523: @end example
                   4524: 
                   4525: You may also use an expression that resolves to a string containing a valid namespace name:
                   4526: 
                   4527: @example
                   4528:   SET NS="VISTA"
                   4529:   WRITE ^|NS|VA(200,0),!
                   4530: @end example  
                   4531: 
                   4532: @node Global Aliasing
                   4533: @chapter Global Aliasing
                   4534: @cindex aliasing, global
                   4535: @cindex globals, aliasing
                   4536: 
                   4537: FreeM provides the ability to set alternative names for M global variables.
                   4538: 
                   4539: To create an alias of @code{^FOO} named @code{^BAR}, use the following command:
                   4540: 
                   4541: @example
                   4542:   SET ^$JOB($JOB,"ALIASES","^BAR")="^FOO"
                   4543: @end example
                   4544: 
                   4545: If such an alias is set, any reference to global variable @code{^BAR} will affect @code{^FOO} instead of @code{^BAR} until @code{^$JOB($JOB,"ALIASES","^BAR")} is @code{KILL}ed. If @code{^BAR} existed prior to the definition of this alias, its data will be unavailable to and unaffected by application code.  
                   4546: 
                   4547: @node Global Mappings
                   4548: @chapter Global Mappings
                   4549: @cindex mappings, global
                   4550: @cindex globals, mapping
                   4551: 
                   4552: FreeM supports creating persistent mappings through which arbitrary global names may be mapped to specific namespaces. This allows non-@code{%} globals to be stored in the @code{SYSTEM} namespace, or @code{%} globals to be stored in non-@code{SYSTEM} namespaces.
                   4553: 
                   4554: To map the @code{^FOO} global to the @code{SYSTEM} namespace, any of the following will work:
                   4555: 
                   4556: @example
                   4557:   MAP GLOBAL ^FOO="SYSTEM"
                   4558:   SET ^$GLOBAL("FOO","NAMESPACE")="SYSTEM"
                   4559:   SET ^$SYSTEM("MAPPINGS","GLOBAL","^FOO")="SYSTEM"
                   4560: @end example
                   4561: 
                   4562: There is no functional difference in any of the three approaches; the method you choose is a matter of personal preference.
                   4563: 
                   4564: To remove the above mapping, any of the following examples will also work:
                   4565: 
                   4566: @example
                   4567:   UNMAP GLOBAL ^FOO
                   4568:   KILL ^$GLOBAL("FOO","NAMESPACE")
                   4569:   KILL ^$SYSTEM("MAPPINGS","GLOBAL","^FOO")
                   4570: @end example
                   4571: 
                   4572: @node Transaction Processing
                   4573: @chapter Transaction Processing
                   4574: @cindex transaction processing
                   4575: 
                   4576: FreeM implements a significant subset of the transaction processing features from @emph{ANSI X11.1-1995}. This allows a series of global operations to be conducted all at once, either in batch mode (where concurrency is not disturbed), or in serial mode (where writes are guaranteed to be atomic, consistent, isolated, and durable).
                   4577: 
                   4578: @section Theory of Operation
                   4579: 
                   4580: FreeM uses a pessimistic concurrency control mechanism for @code{SERIAL} transactions, meaning that any @code{TSTART} command that includes the @code{SERIAL} transaction parameter will cause the process to acquire the transaction processing mutex, which prevents any process but the one holding the mutex from performing any data access (read or write) until either @code{TCOMMIT} or @code{TROLLBACK} is called, either committing or rolling back the transaction, respectively.
                   4581: 
                   4582: Any transaction in between its @code{TSTART} and @code{TCOMMIT}/@code{TROLLBACK} is said to be @emph{in-flight}. During the in-flight stage, pending global operations are held only in memory and after-image journals.
                   4583: 
                   4584: FreeM maintains a list of all globals affected during a transaction in-flight. When a @code{TCOMMIT} is reached, FreeM will generate a @emph{checkpoint} of each global data file to be changed by the transaction. These checkpoints allow all FreeM globals to be restored to their pre-transaction state if a @code{TCOMMIT} should fail part of the way through its operation. 
                   4585: 
                   4586: Checkpoints can have one of two modes:
                   4587: 
                   4588: @table @asis
                   4589: 
                   4590: @item @code{CP_REMOVE}
                   4591: Used for globals that did not exist prior to the beginning of this transaction. Simply marks the entire global data file for deletion in case of @code{TCOMMIT} failure.
                   4592: 
                   4593: @item @code{CP_RESTORE}
                   4594: Used for globals that @emph{did} exist prior to the beginning of this transaction. In this case, the entire global data file is copied to a new file with a @code{.chk} extension. In cases of @code{TCOMMIT} failure, @code{CP_RESTORE} checkpoint files will be restored over the partially-modified live data file.
                   4595: 
                   4596: @end table
                   4597: 
                   4598: The below example shows a few global operations and checkpoints for a transaction in-flight using the @code{trantab} direct-mode command:
                   4599: 
                   4600: @verbatim
1.22      snw      4601: TL1:DEFAULT.USER> trantab
1.1       snw      4602:  $TLEVEL 1*
                   4603:   Operations for Transaction ID: 6ea14aad-b8f1-47f9-9f52-4f513f892bc0 [RESTARTABLE SERIAL]
                   4604: 
                   4605:    OP. NO.   ACTION         KEY/DATA
                   4606:    -------   ------         --------
                   4607:    1         SET            ^FOO=3
                   4608:    2         KILL           ^FOO
                   4609:    3         SET            ^jpw=10
                   4610:    4         SET            ^BRANDNEW=6
                   4611: 
                   4612:   Global checkpoints:
                   4613: 
                   4614:    GLOBAL                        MODE                FILES
                   4615:    ------                        ----                -----
                   4616:    ^BRANDNEW                     CP_REMOVE           IN:   /usr/local/var/freem/USER/globals/^BRANDNEW
                   4617:    ^jpw                          CP_RESTORE          IN:   /usr/local/var/freem/USER/globals/^jpw
                   4618:                                                      OUT:  /usr/local/var/freem/USER/globals/^jpw.23390.1.chk
                   4619:    ^FOO                          CP_RESTORE          IN:   /usr/local/var/freem/USER/globals/^FOO
                   4620:                                                      OUT:  /usr/local/var/freem/USER/globals/^FOO.23390.1.chk
                   4621: @end verbatim
                   4622: 
                   4623: In the above example, @code{IN} files are the live data file that will be overwritten or removed, and @code{OUT} files are the checkpoints themselves. Note that @code{OUT} files are only used for @code{CP_RESTORE} checkpoints.
                   4624: 
                   4625: 
                   4626: @node Asynchronous Event Handling
                   4627: @chapter Asynchronous Event Handling
                   4628: @cindex event handling, asynchronous
                   4629: 
                   4630: Asynchronous event handling in FreeM follows the specifications of the unpublished MDC @emph{Millennium Draft Standard}.
                   4631: 
                   4632: @section Setting Up Async Event Handlers
                   4633: 
                   4634: Asynchronous event handlers are configured through the @code{^$JOB} structured system variable for job-specific events, and the @code{^$SYSTEM} structured system variable for system-wide events. In order to become proficient in writing asynchronous event handling code, you need to be aware of several important concepts:
                   4635: 
                   4636: @table @emph
                   4637: 
                   4638: @item Event Classes
                   4639: @emph{Event classes} denote particular categories of events. These include @code{COMM}, @code{HALT}, @code{IPC}, @code{INTERRUPT}, @code{POWER}, @code{TIMER}, @code{TRIGGER}, and @code{USER} event classes. At present, only @code{INTERRUPT} and @code{TRIGGER} event classes are supported.
                   4640: 
                   4641: @item Event Identifiers
                   4642: @emph{Event identifiers} denote the precise nature of the event that has occurred. For instance, resizing the terminal window in which a FreeM job is running will send an event of class @code{INTERRUPT} with an event identifier of @code{SIGWINCH} (short for @emph{SIGnal WINdow CHange}).
                   4643: 
                   4644: @item Event Handlers
                   4645: @emph{Event handlers} are M routines or subroutines that can be registered to run when an event of a certain event class occurs.
                   4646: 
                   4647: @item Event Registration
                   4648: @emph{Event registration} is the process of modifying the @code{^$JOB} or @code{^$SYSTEM} SSVN to associate a particular event class and event identifier with an event handler routine or subroutine.
                   4649: 
                   4650: @item Event Blocking and Unblocking
                   4651: @emph{Event blocking} is the means by which asynchronous event handling can be temporarily suspended. For example, asynchronous events are temporarily and implicitly blocked for the duration of event handler execution, unless explicitly un-blocked within the event handler. Event handling can also be blocked and unblocked programatically from M code using the @code{ABLOCK} and @code{AUNBLOCK} commands.
                   4652: 
                   4653: @end table
                   4654: 
                   4655: The following sections of this chapter will take you step-by-step through setting up an event handler for @code{SIGWINCH} signal handling.
                   4656: 
                   4657: @section Registering an Asynchronous Event Handler
                   4658: @cindex event handlers, registration
                   4659: 
                   4660: To register a job-specific event handler that will only execute in the current FreeM process, use the following syntax:
                   4661: 
                   4662: @example
                   4663:   SET ^$JOB($JOB,"EVENT",@emph{event-class},@emph{event-identifier})=@emph{entryref}
                   4664: @end example
                   4665: 
                   4666: To register a system-wide event handler that will execute in every FreeM process, use the following syntax:
                   4667: 
                   4668: @example
                   4669:   SET ^$SYSTEM("EVENT",@emph{event-class},@emph{event-identifier})=@emph{entryref}
                   4670: @end example
                   4671: 
                   4672: For example, use the following to register @code{^RESIZE} as an asynchronous event handler for @code{SIGWINCH} events:
                   4673: 
                   4674: @example
                   4675:   SET ^$JOB($JOB,"EVENT","INTERRUPT","SIGWINCH")="^RESIZE"
                   4676: @end example
                   4677: 
                   4678: This by itself will not enable asynchronous event handling, as it merely @emph{registers} an event handler, associating it with event class @code{INTERRUPT} and event identifier @code{SIGWINCH}.
                   4679: 
                   4680: @section Enabling Asynchronous Event Handling
                   4681: @cindex event handlers, enabling
                   4682: 
                   4683: In order to enable asyncronous event handling, the @code{ASTART} command is used. In the following example, we will enable asynchronous event handling for the @code{INTERRUPT} event class:
                   4684: 
                   4685: @example
                   4686:   ASTART "INTERRUPT"
                   4687: @end example
                   4688: 
                   4689: Omitting the @code{"INTERRUPT"} argument will enable asynchronous event handling for @emph{all} event classes. See @code{ASTART} in the commands section for more details.
                   4690: 
                   4691: Once this is done, any event handlers registered for the @code{INTERRUPT} event class in @code{^$JOB} will be executed asynchronously as appropriate.
                   4692: 
                   4693: Please note that @code{ASTART "TRIGGER"} is run implicitly at FreeM startup, to ensure consistency in applications depending on business logic contained in system-wide global triggers. To disable this behavior, add @code{ASTOP "TRIGGER"} to the @code{LOCAL.STARTUP} routine in the @code{USER} namespace. If @code{LOCAL.STARTUP} does not yet exist in your environment, you may create it by typing @code{fmadm edit routine USER LOCAL.STARTUP} from your UNIX command-line shell.
                   4694: 
                   4695: @section Disabling Asynchronous Event Handling
                   4696: @cindex event handlers, disabling
                   4697: 
                   4698: To disable asynchronous event handling, the @code{ASTOP} command is used. In the following example, we will disable asynchronous event handling for the @code{INTERRUPT} event class:
                   4699: 
                   4700: @example
                   4701:   ASTOP "INTERRUPT"
                   4702: @end example
                   4703: 
                   4704: Omitting the @code{"INTERRUPT"} argument will disable asynchronous event handling for @emph{all} event classes. See @code{ASTOP} in the commands section for more details.
                   4705: 
                   4706: You may also disable asynchronous event handling for a specific event identifier by @code{KILL}ing the appropriate node in the @code{^$JOB} SSVN, which unregisters the event handler altogether. The following example will unregister the event handler for the @code{SIGWINCH} event identifier:
                   4707: 
                   4708: @example
                   4709:   KILL ^$JOB($JOB,"EVENT","INTERRUPT","SIGWINCH")
                   4710: @end example  
                   4711: 
                   4712: @section Temporarily Blocking Asynchronous Event Handling
                   4713: @cindex event handlers, blocking
                   4714: 
                   4715: To temporarily block processing of specific event classes, you will use the @code{ABLOCK} command. @code{ABLOCK} functions incrementally, that is, each successive call to @code{ABLOCK} will increment a counter of blocks held for the specified event class or classes, and each successive call to @code{AUNBLOCK} will decrement that counter. Event handling for the specified event classes will be blocked as long as the @code{ABLOCK} counter for those classes is greater than zero. Thus, event blocking is cumulative, in a manner similar to M incremental locks.
                   4716: 
                   4717: The following example blocks asynchronous event handling for the @code{INTERRUPT} event class:
                   4718: 
                   4719: @example
                   4720:   ABLOCK "INTERRUPT"
                   4721: @end example
                   4722: 
                   4723: Note that entering an event handler causes an implicit @code{ABLOCK} of @emph{all} event classes, to prevent event handlers from interrupting other event handlers during their execution. This may be overridden by calling @code{AUNBLOCK} for one or more event classes within an event handler. However, unblocking event handling during an event handler should be done with great caution, as this can make the flow of code execution somewhat unpredictable, especially if M globals are modified inside of an event handler routine or subroutine.
                   4724: 
                   4725: Modifying M globals within event handlers is allowed but strongly discouraged, as doing so can lead to logical corruption of the data. If you must modify an M global within an event handler, guard all such operations with prodigious and careful use of @code{LOCK}s, ensuring that such modifications occur in the desired logical order.
                   4726: 
                   4727: @node Global Triggers
                   4728: @chapter Global Triggers
                   4729: @cindex global triggers
                   4730: @cindex triggers
                   4731: 
                   4732: Global triggers use the FreeM asynchronous event handling subsystem to allow a FreeM process to execute arbitrary M code when a particular action occurs on a particular global.
                   4733: 
                   4734: To set up a global trigger, you must set up an event handler for event class @code{TRIGGER}. The event identifier must be in the format of @code{"<action>:<gvn>"}, where @emph{<gvn>} is a global variable name, and @emph{<action>} is one of the following:
                   4735: 
                   4736: @table @asis
                   4737: 
                   4738: @item @code{DATA}
                   4739: Trigger will fire when the @code{$DATA} intrinsic function is called on @emph{<gvn>}.
                   4740: 
                   4741: @item @code{GET}
                   4742: Trigger will fire when @emph{<gvn>} is read from.
                   4743: 
                   4744: @item @code{INCREMENT}
                   4745: Trigger will fire when intrinsic function @code{$INCREMENT} is called on @emph{<gvn>}.
                   4746: 
                   4747: @item @code{KILL}
                   4748: Trigger will fire when @emph{<gvn>} is @code{KILL}ed.
                   4749: 
                   4750: @item @code{NEXT}
                   4751: Trigger will fire when intrinsic function @code{$NEXT} is called on @emph{<gvn>}.
                   4752: 
                   4753: @item @code{ORDER}
                   4754: Trigger will fire when intrinsic function @code{$ORDER} is called on @emph{<gvn>}.
                   4755: 
                   4756: @item @code{QUERY}
                   4757: Trigger will fire when intrinsic function @code{$QUERY} is called on @emph{<gvn>}.
                   4758: 
                   4759: @item @code{SET}
                   4760: Trigger will fire when @code{SET @emph{<gvn>}=@emph{value}} occurs.
                   4761: 
                   4762: @item @code{ZDATA}
                   4763: Trigger will fire when intrinsic function @code{ZDATA} is called on @emph{<gvn>}.
                   4764: 
                   4765: @end table
                   4766: 
                   4767: When a @code{TRIGGER} event occurs, the @code{"GLOBAL"} node of the @code{^$EVENT} structured system variable will be populated with the global reference that invoked the trigger event.
                   4768: 
                   4769: If a @code{SET} or @code{KILL} trigger was the source of the @code{TRIGGER} event, the @code{OLD_VALUE} node of @code{^$EVENT} will be populated with original value of @code{^$EVENT("GLOBAL")} prior to the change, and @code{NEW_VALUE} will be populated with the new value. This allows triggers to contain logic to undo global changes. This functionality can also be used to provide auditing of specific global changes.
                   4770: 
                   4771: The following example shows a trigger implemented for @code{SET} operations on the @code{^DD} global.
                   4772: 
                   4773: @example
                   4774: TRIGGER ;
                   4775:     ;
                   4776:     ; Set up a SET trigger on ^DD
                   4777:     ;
                   4778:     SET ^$JOB($JOB,"EVENT","TRIGGER","SET:^DD")="ONSET^TRIGGER"
                   4779:     ;
                   4780:     ; Enable the TRIGGER event class
                   4781:     ;
                   4782:     ASTART "TRIGGER"
                   4783:     ;
                   4784:     ; Try setting a node in ^DD
                   4785:     ;
                   4786:     SET ^DD(1)="Test"
                   4787:     ;
                   4788:     ; Quit
                   4789:     ;
                   4790:     QUIT
                   4791:     ;
                   4792:     ;
                   4793: ONSET ;
                   4794:     WRITE "The "_^$EVENT("GLOBAL")_" global node was SET.",!
                   4795:     QUIT
                   4796: @end example
                   4797: 
                   4798: You can also set up a trigger that applies to all FreeM processes by setting descendant subscripts of @code{^$SYSTEM("EVENT","TRIGGER",...)} instead of using @code{^$JOB($JOB,"EVENT","TRIGGER",...)}.
                   4799: 
                   4800: @node Synchronous Event Handling
                   4801: @chapter Synchronous Event Handling
                   4802: 
                   4803: @node GUI Programming with MWAPI
                   4804: @chapter GUI Programming with MWAPI
                   4805: 
                   4806: @node User-Defined Z Commands
                   4807: @chapter User-Defined Z Commands
                   4808: 
                   4809: @node User-Defined Z Functions
                   4810: @chapter User-Defined Z Functions
                   4811: 
                   4812: @cindex z functions, user-defined
                   4813: 
                   4814: @node User-Defined SSVNs
                   4815: @chapter User-Defined SSVNs 
                   4816: 
                   4817: @cindex structured system variables, user-defined
                   4818: @cindex structured system variables
                   4819: 
                   4820: @node Language Dialects
                   4821: @chapter Language Dialects
                   4822: 
                   4823: @cindex language dialects
                   4824: @cindex dialects, language
                   4825: 
                   4826: 
                   4827: @node System Library Routines
                   4828: @chapter System Library Routines
                   4829: @cindex system library routines
                   4830: 
                   4831: @section ^%ZCOLUMNS
                   4832: @cindex ^%ZCOLUMNS
                   4833: @cindex system library routines, ^%ZCOLUMNS
                   4834: 
                   4835: This routine is the implementation of the @code{$ZCOLUMNS} intrinsic special variable.
                   4836: 
                   4837: @section ^%SYSINIT
                   4838: @cindex ^%SYSINIT
                   4839: @cindex system library routines, ^%SYSINIT
                   4840: 
                   4841: This routine is the default startup routine for FreeM running in direct mode.
                   4842: 
                   4843: Running @code{DO INFO} from direct mode will use this routine to display information about the current FreeM status and namespace configuration.
                   4844: 
                   4845: @section ^%ZHELP
                   4846: @cindex ^%ZHELP
                   4847: @cindex system library routines, ^%ZHELP
                   4848: 
                   4849: This routine implements the online help feature of FreeM, invoked by typing @code{?} in direct mode. It simply asks the underlying system to execute the command @command{info freem}.
                   4850: 
                   4851: @section ^%ZROWS
                   4852: @cindex ^%ZROWS
                   4853: @cindex system library routines, ^%ZROWS
                   4854: 
                   4855: This routine is the implementation of the @code{$ZROWS} intrinsic special variable.
                   4856: 
                   4857: @node Interrupt Handling
                   4858: @chapter Interrupt Handling
                   4859: @cindex interrupt handling
                   4860: 
1.22      snw      4861: When FreeM receives the @code{SIGINT} signal, either by pressing @code{Ctrl-C} during program execution, or by external signal from the operating system, the FreeM environment daemon, or another external process, one of two things can happen, depending on the state of the @code{$ZI} special variable:
1.1       snw      4862: 
                   4863: @table @asis
                   4864: @item @code{$ZI} evaluates @emph{true}
                   4865: In this case, the @code{ZINRPT} error is raised, and normal error handling procedures apply. If neither @code{$ZTRAP} nor @code{$ETRAP} are set, FreeM prints an error diagnostic on the home device and will exit the FreeM process in application mode (i.e., the @code{freem} executable was started with the @code{--routine} or @code{-r} flag), or return to the direct mode prompt otherwise.
                   4866: 
                   4867: This is the default behavior of FreeM.
                   4868: @item @code{$ZI} evaluates @emph{false}
                   4869: In this case, no error is raised, but the @code{$ZCONTROLC} flag is set. In this mode of operation, it is up to program code to check for @code{$ZCONTROLC} and take appropriate action.
                   4870: 
                   4871: Checking the value of @code{$ZCONTROLC} will reset it to @emph{false}.
                   4872: @end table
                   4873: 
                   4874: In either case, if asynchronous event handling is enabled for the @code{INTERRUPT} event class (i.e., @code{ASTART "INTERRUPT"} or @code{ASTART} have been invoked by the current process), an asynchronous event of event class @code{INTERRUPT} and event identifier @code{SIGINT} will be enqueued. 
                   4875: 
                   4876: @node Error Processing
                   4877: @chapter Error Processing
                   4878: @cindex error processing
                   4879: 
                   4880: FreeM exposes three means of processing M program execution errors:
                   4881: 
                   4882: @table @emph
                   4883: 
                   4884: @item FreeM-style error processing
                   4885: FreeM-style error processing exposes a read/write error trap in @code{$ZTRAP}. The contents of @code{$ZTRAP} must be either empty or a valid M entryref, to which FreeM will @code{GOTO} if an error occurs. Each program stack execution level can have its own @code{$ZTRAP} error handler enabled.
                   4886: 
                   4887: @item DSM 2.0-style error processing
                   4888: DSM 2.0-style error processing emulates the @code{$ZTRAP} behavior of Digital Standard MUMPS v2. It has the same behavior as FreeM-style error handling, with the exception that in DSM 2.0-style error processing, only one @code{$ZTRAP} error handler is set across all program stack execution levels.
                   4889: 
                   4890: @item Standard error processing
                   4891: Standard error processing uses the @code{NEW}-able @code{$ETRAP} variable to store error handler code, which may be any valid M code. The code in @code{$ETRAP} will run when an error occurs or the @code{$ECODE} ISV becomes non-empty. Stack information for standard error handling is provided by the @code{$STACK} ISV, the @code{$STACK()} intrinsic pseudo-function, and the @code{NEW}-able @code{$ESTACK} ISV.
                   4892: 
                   4893: If @code{$ETRAP} is non-empty when an error condition occurs, @code{$ZTRAP} is ignored, regardless of whether FreeM-style or DSM 2.0-style error processing is enabled at the time of the error.
                   4894: 
                   4895: @end table
                   4896: 
                   4897: For further information on switching between FreeM-style and DSM 2.0-style @code{$ZTRAP} error handling, see the documentation for the @code{BREAK} command.
                   4898: 
                   4899: @node FreeM Error Codes
                   4900: @chapter FreeM Error Codes
                   4901: @cindex Error Codes
                   4902: 
                   4903: @table @asis
                   4904: 
                   4905: @item @code{ZINRPT} - @emph{interrupt}
                   4906: Raised when an interrupt signal is received.
                   4907: 
                   4908: @item @code{ZBKERR} - @emph{BREAK point}
                   4909: Raised when a @code{BREAK} point is reached.
                   4910: 
                   4911: @item @code{ZNOSTAND} - @emph{non standard syntax}
                   4912: Raised when features incompatible with the current value of @code{$DIALECT} are used.
                   4913: 
                   4914: @item @code{ZUNDEF} - @emph{variable not found}
                   4915: Raised when an undefined local or global variable is accessed. This error code has been deprecated in favor of standard error codes @code{M6} and @code{M7}.
                   4916: 
                   4917: @item @code{ZLBLUNDEF} - @emph{label not found}
                   4918: Raised when a referenced label is not found.
                   4919: 
                   4920: @item @code{ZMISSOPD} - @emph{missing operand}
                   4921: Raised when an operand is missing from an expression.
                   4922: 
                   4923: @item @code{ZMISSOP} - @emph{missing operator}
                   4924: Raised when an operator is missing from an expression.
                   4925: 
                   4926: @item @code{ZILLOP} - @emph{unrecognized operator}
                   4927: Raised when an unrecognized operator is encountered in an expression.
                   4928: 
                   4929: @item @code{ZQUOTER} - @emph{unmatched quotes}
                   4930: Raised when unbalanced quotes are encountered.
                   4931: 
                   4932: @item @code{ZCOMMAER} - @emph{comma expected}
                   4933: Raised when a comma is expected in program syntax but is not found.
                   4934: 
                   4935: @item @code{ZASSIGNER} - @emph{equals '=' expected}
                   4936: Raised when an equals sign is expected in program syntax but is not found.
                   4937: 
                   4938: @item @code{ZARGER} - @emph{argument not permitted}
                   4939: Raised when an argument is encountered in a syntactic position where arguments are not permitted.
                   4940: 
                   4941: @item @code{ZSPACER} - @emph{blank ' ' expected}
                   4942: Raised when a space character is expected in program syntax but is not found.
                   4943: 
                   4944: @item @code{ZBRAER} - @emph{unmatched parentheses}
                   4945: Raised when unbalanced parentheses are detected in program syntax.
                   4946: 
                   4947: @item @code{ZLVLERR} - @emph{level error}
                   4948: Raised when a level error occurs.
                   4949: 
                   4950: @item @code{ZDIVER} - @emph{divide by zero}
                   4951: Raised when program code attempts to divide by zero. Deprecated in favor of standard error code @code{M9}.
                   4952: 
                   4953: @item @code{ZILLFUN} - @emph{function not found}
                   4954: Raised when program code attempts to call intrinsic or extrinsic functions that are not defined.
                   4955: 
                   4956: @item @code{ZFUNARG} - @emph{wrong number of function arguments}
                   4957: Raised when an intrinsic or extrinsic function is called with the wrong number of arguments.
                   4958: 
                   4959: @item @code{ZZTERR} - @emph{ZTRAP error}
                   4960: Raised when a @code{$ZTRAP} error occurs.
                   4961: 
                   4962: @item @code{ZNEXTERR} - @emph{$NEXT/$ORDER error}
                   4963: Raised when an error occurs in @code{$NEXT} or @code{$ORDER}.
                   4964: 
                   4965: @item @code{ZSELER} - @emph{$SELECT error}
                   4966: Raised when an error occurs in @code{$SELECT}
                   4967: 
                   4968: @item @code{ZCMMND} - @emph{illegal command}
                   4969: Raised when program code attempts to execute an illegal command.
                   4970: 
                   4971: @item @code{ZARGLIST} - @emph{argument list incorrect}
                   4972: Raised when the argument list supplied to an M language element does not match that language element's syntactic requirements.
                   4973: 
                   4974: @item @code{ZINVEXPR} - @emph{invalid expression}
                   4975: Raised when an invalid expression is encountered.
                   4976: 
                   4977: @item @code{ZINVREF} - @emph{invalid reference}
                   4978: Raised when an invalid variable reference is encountered.
                   4979: 
                   4980: @item @code{ZMXSTR} - @emph{string too long}
                   4981: Raised when a string is encountered that exceeds @code{^$SYSTEM("STRING_MAX")}.
                   4982: 
                   4983: @item @code{ZTOOPARA} - @emph{too many parameters}
                   4984: Raised when too many parameters are passed to a function or subroutine.
                   4985: 
                   4986: @item @code{ZNOPEN} - @emph{unit not open}
                   4987: Raised when attempting to access an I/O channel that has not been opened.
                   4988: 
                   4989: @item @code{ZNODEVICE} - @emph{unit does not exist}
                   4990: Raised when attempting to access a device that does not exist.
                   4991: 
                   4992: @item @code{ZPROTECT} - @emph{file protection violation}
                   4993: Raised when attempting to access a file or device to which you do not have permission.
                   4994: 
                   4995: @item @code{ZGLOBER} - @emph{global not permitted}
                   4996: Raised when attempting to use a global in a syntactic element where global variables are not permitted.
                   4997: 
                   4998: @item @code{ZFILERR} - @emph{file not found}
                   4999: Raised when attempting to access a file that does not exist.
                   5000: 
                   5001: @item @code{ZPGMOV} - @emph{program overflow}
                   5002: Raised when a program overflows the limits of a routine buffer.
                   5003: 
                   5004: @item @code{ZSTKOV} - @emph{stack overflow}
                   5005: Raised when @code{DO}, @code{FOR}, or @code{XECUTE} nesting levels exceed the value in @code{^$SYSTEM("NESTLEVLS")}.
                   5006: 
                   5007: @item @code{ZSTORE} - @emph{symbol table overflow}
                   5008: Raised when program code attempts to store too much data in the local symbol table. Should not occur unless symbol table auto-adjust is disabled.
                   5009: 
                   5010: @item @code{ZNOREAD} - @emph{file won't read}
                   5011: Raised when program code attempts to read from an unreadable file.
                   5012: 
                   5013: @item @code{ZNOWRITE} - @emph{file won't write}
                   5014: Raised when program code attempts to write to an unwritable file.
                   5015: 
                   5016: @item @code{ZNOPGM} - @emph{routine not found}
                   5017: Raised when an attempt is made to load or execute a routine that does not exist in the current namespace.
                   5018: 
                   5019: @item @code{ZNAKED} - @emph{illegal naked reference}
                   5020: Raised when an attempt is made to use an illegal naked reference.
                   5021: 
                   5022: @item @code{ZSBSCR} - @emph{illegal subscript}
                   5023: Raised when an illegal subscript access is attempted.
                   5024: 
                   5025: @item @code{ZISYNTX} - @emph{insert syntax}
                   5026: Raised when illegal insert syntax is used.
                   5027: 
                   5028: @item @code{ZDBDGD} - @emph{global data degradation}
                   5029: Raised when corruption is detected in global data files.
                   5030: 
                   5031: @item @code{ZKILLER} - @emph{job kill signal}
                   5032: Raised on a job kill signal.
                   5033: 
                   5034: @item @code{ZHUPER} - @emph{hangup signal}
                   5035: Raised on a job hangup signal.
                   5036: 
                   5037: @item @code{ZMXNUM} - @emph{numeric overflow}
                   5038: Raised when an assignment or expression result exceeds @code{$ZPRECISION}.
                   5039: 
                   5040: @item @code{ZNOVAL} - @emph{function returns no value}
                   5041: Raised when a function does not return a value. Extrinsic functions must @code{QUIT} with a value.
                   5042: 
                   5043: @item @code{ZTYPEMISMATCH} - @emph{type mismatch}
                   5044: Raised when a type mismatch occurs.
                   5045: 
                   5046: @item @code{ZMEMOV} - @emph{out of memory}
                   5047: Raised when FreeM runs out of heap memory.
                   5048: 
                   5049: @item @code{ZNAMERES} - @emph{error in name resolution}
                   5050: Raised when an attempted name resolution fails.
                   5051: 
                   5052: @item @code{ZSCKCREAT} - @emph{error creating socket}
                   5053: Raised when an error occurs creating a socket for network I/O.
                   5054: 
                   5055: @item @code{ZSCKIFAM} - @emph{invalid address family (must be IPV4 or IPV6)}
                   5056: Raised when the address family specified in an @code{OPEN} command for a socket I/O channel is not IPV4 or IPV6.
                   5057: 
                   5058: @item @code{ZSCKITYP} - @emph{invalid connection type (must be TCP or UDP)}
                   5059: Raised when the connection type specified in an @code{OPEN} command for a socket I/O channel is not @code{TCP} or @code{UDP}.
                   5060: 
                   5061: @item @code{ZSCKIPRT} - @emph{invalid port number}
                   5062: Raised when the port number specified in an @code{OPEN} command for a socket I/O channel is invalid. Valid TCP and UDP ports are in the range of 1-65535.
                   5063: 
                   5064: @item @code{ZSCKCERR} - @emph{connection error}
                   5065: Raised when an error occurs on a @code{USE <channel>:/CONNECT} command.
                   5066: 
                   5067: @item @code{ZSCKAERR} - @emph{USE action invalid for connection type (possibly CONNECT on UDP socket?)}
                   5068: Raised when an attempt is made to @code{USE <channel>:/CONNECT} on a UDP socket I/O channel. The UDP protocol is connectionless.
                   5069: 
                   5070: @item @code{ZSCKACON} - @emph{attempted to CONNECT an already-connected socket}
                   5071: Raised when an attempt is made to @code{USE <channel>:/CONNECT} on a TCP socket I/O channel that is already connected.
                   5072: 
                   5073: @item @code{ZSCKNCON} - @emph{attempted to READ from a disconnected TCP socket}
                   5074: Raised when an attempt is made to @code{READ} a TCP socket that has not yet been connected.
                   5075: 
                   5076: @item @code{ZSCKEOPT} - @emph{error setting socket options}
                   5077: Raised when an error is encountered while setting socket options.
                   5078: 
                   5079: @item @code{ZSCKERCV} - @emph{error in READ from socket}
                   5080: Raised when an error occurs in a socket I/O channel @code{READ}.
                   5081: 
                   5082: @item @code{ZSCKESND} - @emph{error in WRITE to socket}
                   5083: Raised when an error occurs while attempting to @code{WRITE} to a socket I/O channel.
                   5084: 
                   5085: @item @code{ZNORPI} - @emph{^$ZRPI only supported on Raspberry Pi hardware}
                   5086: Raised when an attempt is made to use the @code{^$ZRPI} structured system variable on a platform other than the Raspberry Pi single-board computer.
                   5087: 
                   5088: @item @code{ZCREDEF} - @emph{cannot redefine CONST}
                   5089: Raised when attempts are made to redefine a @code{CONST} after its initial definition.
                   5090: 
                   5091: @item @code{ZCMODIFY} - @emph{cannot modify CONST}
                   5092: Raised when attempts are made to change the value of a @code{CONST}.
                   5093: 
                   5094: @item @code{ZFILEXWR} - @emph{cannot open existing file for WRITE}
                   5095: Raised when an attempt is made to open an existing file in write (but not append) mode.
                   5096: 
                   5097: @item @code{INEWMULT} - @emph{initializing NEW with multiple setarguments not supported}
                   5098: Raised when you attempt to use multiple setarguments with initializing @code{NEW}, e.g. @code{NEW X=2,Y=3}.
                   5099: 
                   5100: @item @code{ZECODEINV} - @emph{invalid value for $ECODE}
                   5101: Raised when attempts are made to set @code{$ECODE} to an invalid error code value. Obsolete and replaced by standard error code @code{M101}.
                   5102: 
                   5103: @item @code{ZASSERT} - @emph{programmer assertion failed}
                   5104: Raised when an @code{ASSERT} expression's result is not true.
                   5105: 
                   5106: @item @code{ZUSERERR} - @emph{user-defined error}
                   5107: Raised when program code calls @code{THROW} with an error code argument for which the first character is @code{U}, or when @code{$ECODE} is set to an error code for which the first character is @code{U}.
                   5108: 
                   5109: Custom error messages for @code{ZUSERERR} may be set in @code{^$JOB($JOB,"USER_ERRORS",<user_error_code>)}, where @code{<user_error_code>} represents the custom error code.
                   5110: 
                   5111: For example:
                   5112: 
                   5113: @example
1.22      snw      5114: DEFAULT.USER> S ^$JOB($JOB,"USER_ERRORS","UBLACKHOLE")="black hole encountered"
1.1       snw      5115: 
                   5116: 
1.22      snw      5117: DEFAULT.USER> THROW UBLACKHOLE
1.1       snw      5118: 
                   5119: 
                   5120: >> Error UBLACKHOLE:  black hole encountered in SYSTEM::^%SYSINIT  [$STACK = 0]
                   5121: >> THROW UBLACKHOLE
                   5122:                   ^
                   5123: @end example
                   5124: 
                   5125: @item @code{ZSYNTERR} - @emph{syntax error}
                   5126: Raised when a syntax error without a more specific error code is encountered.
                   5127: 
                   5128: @item @code{ZCTRLB} - @emph{break}
                   5129: Pseudo-error used by the FreeM debugger. Not visibly raised in normal program operation.
                   5130: 
                   5131: @item @code{ZASYNC} - @emph{asynchronous interruption}
                   5132: Pseudo-error used by the FreeM asynchronous events subsystem. Not visibly raised in normal program operation.
                   5133: 
                   5134: @item @code{M1} - @emph{naked indicator undefined}
                   5135: Raised when an attempt is made to use a naked reference before the naked indicator is set.
                   5136: 
                   5137: @item @code{M2} - @emph{invalid combination with $FNUMBER code atom}
                   5138: 
                   5139: 
                   5140: @item @code{M3} - @emph{$RANDOM seed less than 1}
                   5141: 
                   5142: 
                   5143: @item @code{M4} - @emph{no true condition in $SELECT}
                   5144: 
                   5145: 
                   5146: @item @code{M5} - @emph{line reference less than zero}
                   5147: 
                   5148: 
                   5149: @item @code{M6} - @emph{undefined local variable}
                   5150: 
                   5151: 
                   5152: @item @code{M7} - @emph{undefined global variable}
                   5153: 
                   5154: 
                   5155: @item @code{M8} - @emph{undefined intrinsic special variable}
                   5156: 
                   5157: 
                   5158: @item @code{M9} - @emph{divide by zero}
                   5159: 
                   5160: 
                   5161: @item @code{M10} - @emph{invalid pattern match range}
                   5162: 
                   5163: 
                   5164: @item @code{M11} - @emph{no parameters passed}
                   5165: 
                   5166: 
                   5167: @item @code{M12} - @emph{invalid line reference (negative offset)}
                   5168: 
                   5169: 
                   5170: @item @code{M13} - @emph{invalid line reference (line not found)}
                   5171: 
                   5172: 
                   5173: @item @code{M14} - @emph{line level not 1}
                   5174: 
                   5175: 
                   5176: @item @code{M15} - @emph{undefined index variable}
                   5177: 
                   5178: 
                   5179: @item @code{M16} - @emph{argumented QUIT not allowed}
                   5180: 
                   5181: 
                   5182: @item @code{M17} - @emph{argumented QUIT required}
                   5183: 
                   5184: 
                   5185: @item @code{M18} - @emph{fixed length READ not greater than zero}
                   5186: 
                   5187: 
                   5188: @item @code{M19} - @emph{cannot copy a tree or subtree onto itself}
                   5189: 
                   5190: 
                   5191: @item @code{M20} - @emph{line must have a formal parameter list}
                   5192: 
                   5193: 
                   5194: @item @code{M21} - @emph{algorithm specification invalid}
                   5195: 
                   5196: 
                   5197: @item @code{M22} - @emph{SET or KILL to ^$GLOBAL when data in global}
                   5198: 
                   5199: 
                   5200: @item @code{M23} - @emph{SET or KILL to ^$JOB for non-existent job number}
                   5201: 
                   5202: 
                   5203: @item @code{M24} - @emph{change to collation algorithm while subscripted local variables defined}
                   5204: 
                   5205: 
                   5206: @item @code{M26} - @emph{non-existent environment}
                   5207: 
                   5208: 
                   5209: @item @code{M27} - @emph{attempt to rollback a transaction that is not restartable}
                   5210: 
                   5211: 
                   5212: @item @code{M28} - @emph{mathematical function, parameter out of range}
                   5213: 
                   5214: 
                   5215: @item @code{M29} - @emph{SET or KILL on structured system variable not allowed by implementation}
                   5216: 
                   5217: 
                   5218: @item @code{M30} - @emph{reference to global variable with different collating sequence within a collating algorithm}
                   5219: 
                   5220: 
                   5221: @item @code{M31} - @emph{control mnemonic used for device without a mnemonic space selected}
                   5222: 
                   5223: 
                   5224: @item @code{M32} - @emph{control mnemonic used in user-defined mnemonic space which has no associated line}
                   5225: 
                   5226: 
                   5227: @item @code{M33} - @emph{SET or KILL to ^$ROUTINE when routine exists}
                   5228: 
                   5229: 
                   5230: @item @code{M35} - @emph{device does not support mnemonic space}
                   5231: 
                   5232: 
                   5233: @item @code{M36} - @emph{incompatible mnemonic spaces}
                   5234: 
                   5235: 
                   5236: @item @code{M37} - @emph{READ from device identified by empty string}
                   5237: 
                   5238: 
                   5239: @item @code{M38} - @emph{invalid structured system variable subscript}
                   5240: 
                   5241: 
                   5242: @item @code{M39} - @emph{invalid $NAME argument}
                   5243: 
                   5244: 
                   5245: @item @code{M40} - @emph{call-by-reference in JOB actual parameter}
                   5246: 
                   5247: 
                   5248: @item @code{M41} - @emph{invalid LOCK argument within a transaction}
                   5249: 
                   5250: 
                   5251: @item @code{M42} - @emph{invalid QUIT within a transaction}
                   5252: 
                   5253: 
                   5254: @item @code{M43} - @emph{invalid range value ($X, $Y}
                   5255: 
                   5256: 
                   5257: @item @code{M44} - @emph{invalid command outside of a transaction}
                   5258: 
                   5259: 
                   5260: @item @code{M45} - @emph{invalid GOTO reference}
                   5261: 
                   5262: 
                   5263: @item @code{M56} - @emph{identifier exceeds maximum length}
                   5264: 
                   5265: 
                   5266: @item @code{M57} - @emph{more than one defining occurrence of label in routine}
                   5267: 
                   5268: 
                   5269: @item @code{M58} - @emph{too few formal parameters}
                   5270: 
                   5271: 
                   5272: @item @code{M60} - @emph{illegal attempt to use an undefined SSVN}
                   5273: 
                   5274: 
                   5275: @item @code{M101} - @emph{invalid value for $ECODE}
                   5276: 
                   5277: 
                   5278: @item @code{M102} - @emph{synchronous and asynchronous event processing cannot be simultaneously enabled for the same event class}
                   5279: 
                   5280: 
                   5281: @item @code{M103} - @emph{invalid event identifier}
                   5282: 
                   5283: 
                   5284: @item @code{M104} - @emph{ETRIGGER event identifier for IPC event class does not match job process identifier}
                   5285: 
                   5286: 
                   5287: @end table
                   5288: 
                   5289: @node Debugging
                   5290: @chapter Debugging
                   5291: @cindex debugging
                   5292: 
                   5293: @node System Configuration
                   5294: @chapter System Configuration
                   5295: @cindex configuration, system
                   5296: 
                   5297: @section Installing FreeM
                   5298: @cindex installation
                   5299: 
                   5300: @section Build Configuration
                   5301: @cindex build configuration
                   5302: 
                   5303: When configuring FreeM with the supplied @code{configure} script, there are some FreeM-specific options that may be used to compile in optional features, or exclude default ones:
                   5304: 
                   5305: @table @asis
                   5306: 
                   5307: @item @code{--enable-mwapigtk} (EXPERIMENTAL)
                   5308: Enables experimental support for the M Windowing API using the GTK3 libraries. Requires that you have GTK 3 libraries, their headers, and their dependencies installed on your system.
                   5309: 
                   5310: Please consult your operating system's documentation for the correct commands to install the required libraries.
                   5311: 
                   5312: @emph{Example}
                   5313: 
                   5314: @example
                   5315: $ ./configure --enable-mwapigtk
                   5316: $ make
                   5317: $ sudo make install
                   5318: @end example
                   5319: 
                   5320: @item @code{--enable-berkeleydb} (EXPERIMENTAL)
                   5321: Enables experimental support for using the BerkeleyDB database as a global handler for FreeM global namespaces. Requires that you have the @code{libdb} library, headers, and dependencies installed on your system.
                   5322: 
                   5323: Please consult your operating system's documentation for the correct commands to install the required libraries.
                   5324: 
                   5325: @emph{Example}
                   5326: 
                   5327: @example
                   5328: $ ./configure --enable-berkeleydb
                   5329: $ make
                   5330: $ sudo make install
                   5331: @end example
                   5332: 
                   5333: 
                   5334: @item @code{--without-readline}
                   5335: Builds FreeM without GNU @code{readline} support, even if @code{readline} is installed on your system.
                   5336: 
                   5337: Please note that building FreeM without GNU @code{readline} will also exclude REPL functionality and all direct-mode utility commands, i.e. @code{events}, @code{tdump}, @code{shmstat}, and @code{shmpages}.
                   5338: 
                   5339: @emph{Example}
                   5340: 
                   5341: @example
                   5342: $ ./configure --without-readline
                   5343: $ make
                   5344: $ sudo make install
                   5345: @end example
                   5346: 
                   5347: 
                   5348: @end table
                   5349: 
                   5350: @node Accessing FreeM from C Programs
                   5351: @chapter Accessing FreeM from C Programs
                   5352: 
                   5353: FreeM provides a library, @file{libfreem.so}, as well as corresponding header file @file{freem.h}, allowing C programmers to write programs that access FreeM globals, locals, structured system variables, subroutines, and extrinsic functions. This functionality can be used to implement language bindings and data access drivers for external systems.
                   5354: 
                   5355: In order to be used in your C programs, your C programs must link with @file{libfreem.so} and include @file{freem.h}. This will allow your C code access to the function prototypes, data structures, and constants required for calling the @file{libfreem.so} APIs.
                   5356: 
                   5357: You must exercise caution in developing programs that interface with FreeM through @file{libfreem.so} to ensure that all @file{libfreem.so} API calls are serialized, as FreeM and the @file{libfreem.so} library are neither thread-safe nor reentrant.
                   5358: 
                   5359: You must also avoid setting signal handlers for @code{SIGALRM}, as FreeM uses @code{SIGALRM} to manage timeouts for @command{LOCK}, @command{READ}, and @command{WRITE}.
                   5360: 
                   5361: @section freem_ref_t Data Structure
                   5362: @cindex libfreem, data structures: freem_ref_t
                   5363: 
                   5364: The @code{libfreem} API uses a @code{struct} of type @code{freem_ref_t} in order to communicate state, pass in values, and return results.
                   5365: 
                   5366: The data structure, defined in @file{freem.h}, looks like this:
                   5367: 
                   5368: @verbatim
                   5369: typedef struct freem_ref_t {
                   5370: 
                   5371:     /*
                   5372:      * The 'reftype' field can be one of:
                   5373:      * 
                   5374:      *  MREF_RT_LOCAL
                   5375:      *  MREF_RT_GLOBAL
                   5376:      *  MREF_RT_SSV
                   5377:      */
                   5378:     short reftype;
                   5379: 
                   5380:     /*
                   5381:      * The 'name' field is the name of the local variable,
                   5382:      * global variable, or SSVN (without ^ or ^$).
                   5383:      */
                   5384:     char name[256];    
                   5385: 
                   5386:     /*
                   5387:      * Returned data goes in a string, so you've got to figure out the
                   5388:      * whole M canonical number thing yourself. Good luck. :-)
                   5389:      */
                   5390:     char value[STRLEN];   
                   5391: 
                   5392:     short status;
                   5393: 
                   5394:     unsigned int subscript_count;
                   5395:     char subscripts[255][256];
                   5396: 
                   5397: } freem_ref_t;
                   5398: @end verbatim
                   5399: 
                   5400: @emph{freem_ref_t Members}
                   5401: 
                   5402: @table @asis
                   5403: @cindex libfreem, freem_ref_t.reftype
                   5404: @item @option{reftype}
                   5405: The @option{reftype} member determines whether we are operating on a local variable, a global variable, or a structured system variable. It may be set to any of following constants: @code{MREF_RT_LOCAL}, @code{MREF_RT_GLOBAL}, or @code{MREF_RT_SSV}.
                   5406: 
                   5407: @cindex libfreem, freem_ref_t.name
                   5408: @item @option{name}
                   5409: The @option{name} member contains the name of the global, local, or SSVN to be accessed. You @emph{must not} include leading characters, such as @code{^} or @code{^$}.
                   5410: 
                   5411: @cindex libfreem, freem_ref_t.value
                   5412: @item @option{value}
                   5413: This member contains the value read from or the value to be written to the global, local, or SSVN.
                   5414: 
                   5415: @cindex libfreem, freem_ref_t.status
                   5416: @item @option{status}
                   5417: This member gives us various API status values after the API call returns. In general, this value is also returned by each API function.
                   5418: 
                   5419: @cindex libfreem, freem_ref_t.subscript_count
                   5420: @item @option{subscript_count}
                   5421: The number of subscripts to be passed into the API function being called. This value represents the maximum index into the first dimension of the @code{subscripts} array.
                   5422: 
                   5423: @cindex libfreem, freem_ref_t.subscripts
                   5424: @item @option{subscripts}
                   5425: A two-dimensional array containing the subscripts to which we are referring in this API call. 
                   5426: 
                   5427: @end table
                   5428: 
                   5429: @section freem_ent_t Data Structure
                   5430: @cindex libfreem, data structures: freem_ent_t
                   5431: 
                   5432: The @code{freem_function()} and @code{freem_procedure()} APIs in @code{libfreem} use the @code{freem_ent_t} struct in order to indicate the name of the entry point being called, any arguments being passed to it, and the return value of the called function (not used for @code{freem_procedure()}).
                   5433: 
                   5434: The data structure, defined in @file{freem.h}, looks like this:
                   5435: 
                   5436: @verbatim
                   5437: typedef struct freem_ent_t {
                   5438: 
                   5439:     /* name of function or procedure entry point */
                   5440:     char name[256];
                   5441: 
                   5442:     /* return value */
                   5443:     char value[STRLEN];
                   5444: 
                   5445:     /* value of ierr on return */
                   5446:     short status;
                   5447: 
                   5448:     /* argument count and array */
                   5449:     unsigned int argument_count;
                   5450:     char arguments[255][256];
                   5451: 
                   5452: } freem_ent_t;
                   5453: @end verbatim
                   5454: 
                   5455: @emph{freem_ent_t Members}
                   5456: 
                   5457: @table @asis
                   5458: 
                   5459: @item @option{name}
                   5460: @cindex libfreem, freem_ent_t.name
                   5461: The @option{name} member contains the name of the extrinsic function or procedure to be called.
                   5462: 
                   5463: @cindex libfreem, freem_ent_t.value
                   5464: @item @option{value}
                   5465: This member contains the value returned by the function called. Not used by @code{freem_procedure()}. 
                   5466: 
                   5467: @cindex libfreem, freem_ent_t.status
                   5468: @item @option{status}
                   5469: This member gives us the value of @code{ierr} after the function or procedure call returns. The possible values of @code{ierr} are listed in @code{merr.h}.
                   5470: 
                   5471: @cindex libfreem, freem_ent_t.argument_count
                   5472: @item @option{argument_count}
                   5473: The number of arguments to be passed into the extrinsic function or procedure being called. This value represents the maximum index into the first dimension of the @code{arguments} array.
                   5474: 
                   5475: @cindex libfreem, freem_ent_t.arguments
                   5476: @item @option{arguments}
                   5477: A two-dimensional array containing the arguments to be passed into the extrinsic function or procedure being called.
                   5478: 
                   5479: @end table
                   5480: 
                   5481: @section freem_init()
                   5482: @cindex libfreem, freem_init()
                   5483: 
                   5484: Initializes @code{libfreem} in preparation for calling other APIs.
                   5485: 
                   5486: @emph{Synopsis}
                   5487: 
                   5488: @code{pid_t freem_init(char *environment_name, char *namespace_name);}
                   5489: 
                   5490: @emph{Parameters}
                   5491: 
                   5492: @table @asis
                   5493: @item @code{environment_name}
                   5494: Specifies the environment to use.
                   5495: @item @code{namespace_name}
                   5496: Specifies the namespace to use.
                   5497: @end table
                   5498: 
                   5499: @emph{Return Values}
                   5500: 
                   5501: Returns the process ID of the @code{libfreem} process on success, or @code{-1} on failure.
                   5502: 
                   5503: @emph{Example}
                   5504: 
                   5505: This example prompts the user to enter a FreeM namespace and then attempts to initialize @code{libfreem} to use the selected namespace.
                   5506: 
                   5507: @verbatim
                   5508: #include <stdio.h>
                   5509: #include <string.h>
                   5510: #include <freem.h>
                   5511: 
                   5512: int main(int argc, char **argv, char **envp)
                   5513: {
                   5514:     char namespace[256];
                   5515: 
                   5516:     /* get the namespace name to use */
                   5517:     printf("Enter FreeM namespace to use: ");
                   5518:     fgets(namespace, 255, stdin);
                   5519: 
                   5520:     /* remove the trailing newline */
                   5521:     namespace[strcspn(buffer, "\n")] = '\0';
                   5522: 
                   5523:     /* initialize libfreem using the provided namespace */
                   5524:     if(freem_init("DEFAULT", namespace) == TRUE) {
                   5525:         printf("\nSuccess\n");
                   5526:     }
                   5527:     else {
                   5528:         printf("\nFailure\n");
                   5529:     }
                   5530:      
                   5531:     return 0;
                   5532: }
                   5533: @end verbatim
                   5534: 
                   5535: @section freem_version()
                   5536: @cindex libfreem, freem_version()
                   5537: 
                   5538: Returns the version of FreeM in use.
                   5539: 
                   5540: @emph{Synopsis}
                   5541: 
                   5542: @code{short freem_version(char *result);}
                   5543: 
                   5544: @emph{Parameters}
                   5545: 
                   5546: @table @asis
                   5547: @item @code{result}
                   5548: The @code{result} parameter is a pointer to a buffer in which the FreeM version information will be returned. The caller must allocate memory for this buffer prior to calling this API. It should be at least 20 bytes in length.
                   5549: @end table
                   5550: 
                   5551: @emph{Return Value}
                   5552: 
                   5553: Returns @code{0}.
                   5554: 
                   5555: @emph{Example}
                   5556: 
                   5557: This example will display the FreeM version on standard output.
                   5558: 
                   5559: @verbatim
                   5560: #include <stdio.h>
                   5561: #include <string.h>
                   5562: #include <freem.h>
                   5563: 
                   5564: int main(int argc, char **argv, char **envp)
                   5565: {
                   5566:     char version[20] = {0};
                   5567: 
                   5568:     freem_init(``USER'');
                   5569:     freem_version(version);
                   5570: 
                   5571:     printf(``FreeM version:  %s\n'', version);
                   5572: 
                   5573: }
                   5574: @end verbatim
                   5575: 
                   5576: @section freem_set()
                   5577: @cindex libfreem, freem_set()
                   5578: 
                   5579: Sets a FreeM local node, global node, or writable SSVN node. 
                   5580: 
                   5581: @emph{Synopsis}
                   5582: 
                   5583: @code{short freem_set(freem_ref_t *ref);}
                   5584: 
                   5585: @emph{Parameters}
                   5586: 
                   5587: @table @asis
                   5588: @item @code{freem_ref_t}
                   5589: This parameter is a pointer to a @code{freem_ref_t} struct. The caller must allocate the memory for this struct.
                   5590: @end table
                   5591: 
                   5592: @emph{Return Value}
                   5593: 
                   5594: Returns @code{OK} on success, or one of the other error values defined in @code{merr.h}.
                   5595: 
                   5596: @emph{Example}
                   5597: 
                   5598: This example sets the value @code{blue} into global node @code{^car("color")}.
                   5599: 
                   5600: @verbatim
                   5601: #include <stdio.h>
                   5602: #include <string.h>
                   5603: #include <freem.h>
                   5604: 
                   5605: int main(int argc, char **argv, char **envp)
                   5606: {
                   5607:     freem_ref_t ref;
                   5608: 
                   5609:     /* we're setting a global */
                   5610:     ref.reftype = MREF_RT_GLOBAL;
                   5611: 
                   5612:     /* access global "car" */
                   5613:     strcpy(ref.name, "car");
                   5614: 
                   5615:     /* set up the subscripts */
                   5616:     ref.subscript_count = 1;
                   5617:     strcpy(ref.subscripts[0], "color");
                   5618:  
                   5619: 
                   5620:     /* use the USER namespace */
                   5621:     freem_init("USER");
                   5622: 
                   5623:     /* write the data out */
                   5624:     freem_set(&ref);
                   5625:     
                   5626: }
                   5627: @end verbatim
                   5628: 
                   5629: @section freem_get()
                   5630: @cindex libfreem, freem_get()
                   5631: 
                   5632: Retrieves a FreeM local node, global node, or writable SSVN node.
                   5633: 
                   5634: @emph{Synopsis}
                   5635: 
                   5636: @code{short freem_get(freem_ref_t *ref);}
                   5637: 
                   5638: @emph{Parameters}
                   5639: 
                   5640: @table @asis
                   5641: @item @code{freem_ref_t}
                   5642: This parameter is a pointer to a @code{freem_ref_t} struct. The caller must allocate the memory for this struct.
                   5643: @end table
                   5644: 
                   5645: @emph{Return Value}
                   5646: 
                   5647: Returns @code{OK} on success, or one of the other error values defined in @code{merr.h}.
                   5648: 
                   5649: @emph{Example}
                   5650: 
                   5651: This example retrieves the character set of the current process.
                   5652: 
                   5653: @verbatim
                   5654: #include <stdio.h>
                   5655: #include <sys/types.h>
                   5656: #include <unistd.h>
                   5657: #include <string.h>
                   5658: #include <freem.h>
                   5659: 
                   5660: int main(int argc, char **argv, char)
                   5661: {
                   5662:     pid_t pid;
                   5663:     freem_ref_t ref;
                   5664: 
                   5665:     /* get the PID of this process */
                   5666:     pid = getpid();
                   5667: 
                   5668:     /* we want to access an SSVN */
                   5669:     ref.reftype = MREF_RT_SSV;
                   5670:     
                   5671:     /* set up the name and subscripts */
                   5672:     strcpy(ref.name, "JOB");
                   5673: 
                   5674:     ref.subscript_count = 2;
                   5675:     sprintf(ref.subscripts[0], "%d", pid);
                   5676:     strcpy(ref.subscripts[1], "CHARACTER");
                   5677: 
                   5678:     /* initialize libfreem, using the USER namespace */
                   5679:     freem_init("USER");
                   5680: 
                   5681:     /* call libfreem API */
                   5682:     freem_get(&ref);
                   5683: 
                   5684:     /* output the character set info */
                   5685:     printf("PID %d character set is '%s'\n", pid, ref.value);
                   5686: }
                   5687: @end verbatim
                   5688: 
                   5689: @section freem_kill()
                   5690: @cindex libfreem, freem_kill()
                   5691: 
                   5692: Deletes a FreeM local node, global node, or killable SSVN node, as well as all of its children.
                   5693: 
                   5694: @emph{short freem_kill(freem_ref_t *ref);}
                   5695: 
                   5696: @emph{Parameters}
                   5697: 
                   5698: @table @asis
                   5699: @item @code{freem_ref_t}
                   5700: This parameter is a pointer to a @code{freem_ref_t} struct. The caller must allocate the memory for this struct.
                   5701: @end table
                   5702: 
                   5703: @emph{Return Value}
                   5704: 
                   5705: Returns @code{OK} on success, or one of the other error values defined in @code{merr.h}.
                   5706: 
                   5707: @emph{Example}
                   5708: 
                   5709: @verbatim
                   5710: #include <stdio.h>
                   5711: #include <string.h>
                   5712: #include <freem.h>
                   5713: 
                   5714: int main(int argc, char **argv, char **envp)
                   5715: {
                   5716:     freem_ref_t ref;
                   5717: 
                   5718:     /* we're killing a global node */
                   5719:     ref.reftype = MREF_RT_GLOBAL;
                   5720: 
                   5721:     /* access global "car" */
                   5722:     strcpy(ref.name, "car");
                   5723: 
                   5724:     /* set up the subscripts */
                   5725:     ref.subscript_count = 0;
                   5726: 
                   5727:     /* use the USER namespace */
                   5728:     freem_init("USER");
                   5729: 
                   5730:     /* kill the global and all its descendant subscripts */
                   5731:     freem_kill(&ref);    
                   5732: }
                   5733: @end verbatim
                   5734: 
                   5735: @section freem_data()
                   5736: @cindex libfreem, freem_data()
                   5737: 
                   5738: @section freem_order()
                   5739: @cindex libfreem, freem_order()
                   5740: 
                   5741: @section freem_query()
                   5742: @cindex libfreem, freem_query()
                   5743: 
                   5744: @section freem_lock()
                   5745: @cindex libfreem, freem_lock()
                   5746: 
                   5747: @section freem_unlock()
                   5748: @cindex libfreem, freem_unlock()
                   5749: 
                   5750: @section freem_tstart()
                   5751: @cindex libfreem, freem_tstart()
                   5752: 
                   5753: @section freem_trestart()
                   5754: @cindex libfreem, freem_trestart()
                   5755: 
                   5756: @section freem_trollback()
                   5757: @cindex libfreem, freem_trollback()
                   5758: 
                   5759: @section freem_tlevel()
                   5760: @cindex libfreem, freem_tlevel()
                   5761: 
                   5762: @section freem_tcommit()
                   5763: @cindex libfreem, freem_tcommit()
                   5764: 
                   5765: @section freem_function()
                   5766: @cindex libfreem, freem_function()
                   5767: 
                   5768: @section freem_procedure()
                   5769: @cindex libfreem, freem_procedure()
                   5770: 
                   5771: @node FreeM Administrator
                   5772: @appendix FreeM Administrator
                   5773: @cindex utilities, system management
                   5774: @cindex utilities, fmadm
                   5775: @cindex fmadm
                   5776: 
                   5777: The @code{fmadm} utility is the preferred method of managing a FreeM installation, and will eventually replace all of the existing utilities.
                   5778: Unlike the existing, legacy utilities, @code{fmadm} presents a consistent, simple interface for all FreeM management tasks, and is namespace-aware.
                   5779: This appendix will document each @code{fmadm} facility as it is implemented, until all of the legacy utilities have been replaced.
                   5780: 
                   5781: The @code{fmadm} utility's functions all follow the below, consistent syntax:
                   5782: 
                   5783: @example
                   5784: usage:  fmadm <action> <object> <namespace> [OPTIONS]
                   5785: @end example
                   5786: 
                   5787: The @emph{action} keyword can be one of the following:
                   5788: 
                   5789: @table @emph
                   5790: 
                   5791: @item list
                   5792: Lists instances of @emph{object}
                   5793: 
                   5794: @item examine
                   5795: Examines a single instance of @emph{object}
                   5796: 
                   5797: @item verify
                   5798: Verifies the integrity of @emph{object}
                   5799: 
                   5800: @item compact
                   5801: Compacts @emph{object}
                   5802: 
                   5803: @item repair
                   5804: Repairs integrity problems in @emph{object}
                   5805: 
                   5806: @item create
                   5807: Creates an instance of @emph{object}
                   5808: 
                   5809: @item remove
                   5810: Removes an instance of @emph{object}
                   5811: 
                   5812: @item import
                   5813: Imports an @emph{object}
                   5814: 
                   5815: @item export
                   5816: Exports an @emph{object}
                   5817: 
                   5818: @item backup
                   5819: Creates a backup of @emph{object}
                   5820: 
                   5821: @item restore
                   5822: Restores a backup of @emph{object}
                   5823: 
                   5824: @item migrate
                   5825: Migrates an instance of @emph{object} from an older FreeM version to the current version
                   5826: 
                   5827: @item edit
                   5828: Edits an instance of @emph{object}
                   5829: 
                   5830: @end table
                   5831: 
                   5832: The @emph{object} keyword can be one of the following:
                   5833: 
                   5834: @table @emph
                   5835: 
                   5836: @item lock
                   5837: The FreeM @code{LOCK} table.
                   5838: 
                   5839: Supported actions are @code{list} and @code{remove}.
                   5840: 
                   5841: @item journal
                   5842: FreeM after-image journaling.
                   5843: 
                   5844: Supported actions are @code{examine} and @code{restore}.
                   5845: 
                   5846: The @code{examine} action will dump the after-image journal entries for the selected namespace in human-readable format.
                   5847: 
                   5848: The @code{restore} action will play after-image journals forward for the selected namespace.
                   5849: 
                   5850: @item namespace
                   5851: FreeM namespaces (collections of M routines and globals).
                   5852: 
                   5853: No actions yet implemented.
                   5854: 
                   5855: @item global
                   5856: The data files representing each FreeM @emph{global}.
                   5857: 
                   5858: Supported actions are @code{list}, @code{examine}, @code{remove}, and @code{verify}.
                   5859: 
                   5860: @item routine
                   5861: An M routine, stored as a @code{.m} file.
                   5862: 
                   5863: Supported actions are @code{list}, @code{examine}, @code{remove}, @code{import}, @code{export}, @code{backup}, and @code{edit}.
                   5864: 
                   5865: @item job
                   5866: A UNIX process representing an instance of the FreeM runtime.
                   5867: 
                   5868: Supported actions are @code{list} and @code{examine}.
                   5869: 
                   5870: @end table
                   5871: 
                   5872: 
                   5873: @node FreeM Legacy Utilities
                   5874: @appendix FreeM Legacy Utilities
                   5875: @cindex utilities, legacy
                   5876: 
                   5877: @section Global Compactor (gcompact)
                   5878: @cindex utilities, legacy, gcompact
                   5879: 
                   5880: Compacts the specified global in place.
                   5881: 
                   5882: @emph{Syntax}
                   5883: 
                   5884: @example
                   5885: gcompact @emph{/path/to/global/file}
                   5886: @end example
                   5887: 
                   5888: @section Block Examiner (gfix)
                   5889: @cindex utilities, gfix
                   5890: 
                   5891: The @emph{gfix} interactive utility program permits navigation of the B-tree structure of the specified global a block at a time.
                   5892: 
                   5893: @emph{Syntax}
                   5894: 
                   5895: @example
                   5896: gfix @emph{</path/to/global/file>}
                   5897: @end example
                   5898: 
                   5899: @section Global Repair Tool (grestore)
                   5900: @cindex utilities, legacy, grestore
                   5901: 
                   5902: This utility will fix problems with the specified global.
                   5903: 
                   5904: @emph{Syntax}
                   5905: 
                   5906: @example
                   5907: grestore @emph{</path/to/global/file>}
                   5908: @end example
                   5909: 
                   5910: @node FreeM VIEW Commands and Functions
                   5911: @appendix FreeM VIEW Commands and Functions
                   5912: 
                   5913: @section VIEW 16: Total Count of Error Messages/View Single Error Message
                   5914: @cindex VIEW commands/functions, 16, total count of error messages/view single error message
                   5915: 
                   5916: Unknown semantics
                   5917: 
                   5918: @section VIEW 17: Intrinsic Z-Commands
                   5919: @cindex VIEW commands/functions, 17, intrinsic Z-commands
                   5920: 
                   5921: Allows the user to retrieve or specify the list of intrinsic Z-commands that FreeM will attempt to run internally, allowing intrinsic Z-commands implemented internally to be replaced with M equivalents implemented as %-routines in the @code{SYSTEM} namespace.
                   5922: 
                   5923: @section VIEW 18: Intrinsic Z-Functions
                   5924: @cindex VIEW commands/functions, 18, intrinsic Z-functions
                   5925: 
                   5926: Allows the user to retrieve or specify the list of intrinsic Z-functions that FreeM will attempt to run internally, allowing intrinsic Z-functions implemented internally to be replaced with M equivalents implemented as %-routines in the @code{SYSTEM} namespace.
                   5927: 
                   5928: @section VIEW 19: Intrinsic Special Variables
                   5929: @cindex VIEW commands/functions, 19, intrinsic special variables
                   5930: 
                   5931: Allows the user to retrieve or specify which special variables are implemented internally.
                   5932: 
                   5933: @section VIEW 20: Break Service Code
                   5934: @cindex VIEW commands/functions, 20, break service code
                   5935: 
                   5936: Allows the user to view or specify the code that will be run when a @code{BREAK} is encountered.
                   5937: 
                   5938: @section VIEW 21: View Size of Last Global
                   5939: @cindex VIEW commands/functions, 21, view size of last global
                   5940: 
                   5941: Allows the user to view the size of the last referenced global.
                   5942: 
                   5943: @section VIEW 22: Count VIEW 22 Aliases
                   5944: @cindex VIEW commands/functions, 22, count VIEW 22 aliases
                   5945: 
                   5946: Retrieves the number of VIEW 22 aliases in effect.
                   5947: 
                   5948: @section VIEW 23: View Contents of Input Buffer
                   5949: @cindex VIEW commands/functions, 23, input buffer contents
                   5950: 
                   5951: Retrieves the contents of the I/O input buffer.
                   5952: 
                   5953: @section VIEW 24: Maximum Number of Screen Rows
                   5954: @cindex VIEW commands/functions, 24, maximum number of screen rows
                   5955: 
                   5956: Retrieves the maximum number of screen rows supported in the current FreeM build.
                   5957: 
                   5958: @section VIEW 25: Maximum Number of Screen Columns
                   5959: @cindex VIEW commands/functions, 25, maximum number of screen columns
                   5960: 
                   5961: Retrieves the maximum number of screen columns supported in the current FreeM build.
                   5962: 
                   5963: @section VIEW 26: DO/FOR/XECUTE Stack Pointer
                   5964: @cindex VIEW commands/functions, 26, DO/FOR/XECUTE stack pointer
                   5965: 
                   5966: Retrieves the @code{DO}, @code{FOR}, and @code{XECUTE} stack pointer.
                   5967: 
                   5968: @section VIEW 27: DO/FOR/XECUTE Stack Pointer (On Error)
                   5969: @cindex VIEW commands/functions, 27, DO/FOR/XECUTE stack pointer, on error
                   5970: 
                   5971: Retrieves the @code{DO}, @code{FOR}, and @code{XECUTE} stack pointer (on error).
                   5972: 
                   5973: @section VIEW 29: Copy Symbol Table
                   5974: @cindex VIEW commands/functions, 29, copy symbol table
                   5975: 
                   5976: Copies the symbol table? We aren't currently aware of what this means.
                   5977: 
                   5978: @section VIEW 30: Inspect Arguments
                   5979: @cindex VIEW commands/functions, 30, inspect arguments
                   5980: 
                   5981: Retrieves the arguments passed to the @code{freem} executable.
                   5982: 
                   5983: @section VIEW 31: Count Environment Variables
                   5984: @cindex VIEW commands/functions, 31, count environment variables
                   5985: 
                   5986: Allows the user to inspect the number of variables in the process environment table.
                   5987: 
                   5988: @emph{Syntax}
                   5989: 
                   5990: @example
                   5991: WRITE $VIEW(31),!
                   5992: @end example
                   5993: 
                   5994: @node Implementation Limits
                   5995: @appendix Implementation Limits
                   5996: 
                   5997: @cindex limitations, memory
                   5998: @cindex maximum size, routine
                   5999: @cindex maximum size, global
                   6000: @cindex maximum size, string
                   6001: 
                   6002: @node US-ASCII Character Set
                   6003: @appendix US-ASCII Character Set
                   6004: 
                   6005: @multitable {Code} {Character} 
                   6006: @item Code @tab Character
                   6007: @item 000 @tab @code{<NUL>}
                   6008: @item 001 @tab @code{<SOH>}
                   6009: @item 002 @tab @code{<STX>}
                   6010: @item 003 @tab @code{<ETX>}
                   6011: @item 004 @tab @code{<EOT>}
                   6012: @item 005 @tab @code{<ENQ>}
                   6013: @item 006 @tab @code{<ACK>}
                   6014: @item 007 @tab @code{<BEL>}
                   6015: @item 008 @tab @code{<BS>}
                   6016: @item 009 @tab @code{<HT>}
                   6017: @item 010 @tab @code{<LF>}
                   6018: @item 011 @tab @code{<VT>}
                   6019: @item 012 @tab @code{<FF>}
                   6020: @item 013 @tab @code{<CR>}
                   6021: @item 014 @tab @code{<SO>}
                   6022: @item 015 @tab @code{<SI>}
                   6023: @item 016 @tab @code{<DLE>}
                   6024: @item 017 @tab @code{<DC1>}
                   6025: @item 018 @tab @code{<DC2>}
                   6026: @item 019 @tab @code{<DC3>}
                   6027: @item 020 @tab @code{<DC4>}
                   6028: @item 021 @tab @code{<NAK>}
                   6029: @item 022 @tab @code{<SYN>}
                   6030: @item 023 @tab @code{<ETB>}
                   6031: @item 024 @tab @code{<CAN>}
                   6032: @item 025 @tab @code{<EM>}
                   6033: @item 026 @tab @code{<SUB>}
                   6034: @item 027 @tab @code{<ESC>}
                   6035: @item 028 @tab @code{<FS>}
                   6036: @item 029 @tab @code{<GS>}
                   6037: @item 030 @tab @code{<RS>}
                   6038: @item 031 @tab @code{<US>}
                   6039: @item 032 @tab @code{<space>}
                   6040: @item 033 @tab !
                   6041: @item 034 @tab ``
                   6042: @item 035 @tab #
                   6043: 
                   6044: 
                   6045: @end multitable
                   6046: 
                   6047: @node FreeM Project Coding Standards
                   6048: @appendix FreeM Project Coding Standards
                   6049: 
                   6050: @section Module Headers
                   6051: @cindex coding standards, module headers
                   6052: 
1.4       snw      6053: Module headers should adhere to the following format (where @code{Dollar} should be replaced with a dollar sign):
1.1       snw      6054: 
                   6055: @verbatim
                   6056: /*
1.4       snw      6057:  *   DollarIdDollar
1.1       snw      6058:  *    Function prototypes, structs, and macros for FreeM
                   6059:  *    binding library
                   6060:  *
                   6061:  *  
                   6062:  *   Author: Serena Willis <jpw@coherent-logic.com>
                   6063:  *    Copyright (C) 1998 MUG Deutschland
1.4       snw      6064:  *    Copyright (C) <Year> Coherent Logic Development LLC
                   6065:  *
                   6066:  *   This file is part of FreeM.
                   6067:  *
                   6068:  *   FreeM is free software: you can redistribute it and/or modify
                   6069:  *   it under the terms of the GNU Affero Public License as published by
                   6070:  *   the Free Software Foundation, either version 3 of the License, or
                   6071:  *   (at your option) any later version.
                   6072:  *
                   6073:  *   FreeM is distributed in the hope that it will be useful,
                   6074:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
                   6075:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                   6076:  *   GNU Affero Public License for more details.
                   6077:  *
                   6078:  *   You should have received a copy of the GNU Affero Public License
                   6079:  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
                   6080:  *
                   6081:  *   DollarLogDollar
1.1       snw      6082:  *
1.4       snw      6083:  * SPDX-FileCopyrightText:  (C) 2025 Coherent Logic Development LLC
                   6084:  * SPDX-License-Identifier: AGPL-3.0-or-later
1.1       snw      6085:  **/
                   6086: @end verbatim
                   6087: 
                   6088: @section Variable Naming
                   6089: @cindex coding standards, variable naming
                   6090: 
                   6091: Variables should be named in all lowercase letters, and words within them delimited by underscores, such as @code{my_useful_variable}. @code{PascalCase} and @code{camelCase} are not to be used in this codebase under any circumstances.
                   6092: 
                   6093: Constants defined via the C preprocessor should be in all uppercase letters, with words within them likewise delimited by underscores, such as:
                   6094: 
                   6095: @verbatim
                   6096: #define MY_USEFUL_CONSTANT 1
                   6097: @end verbatim
                   6098: 
                   6099: @section Indentation and General Layout
                   6100: @cindex coding standards, indentation
                   6101: @cindex coding standards, layout
                   6102: 
                   6103: This project uses four spaces for indentation. Tabs are not to be used under any circumstances, and all source files must use a linefeed character to delineate lines. If you are working on a Windows machine, you must take care to follow this, as Windows will use a carriage return followed by a linefeed by default.
                   6104: 
                   6105: This project follows a modified version of what is known as the Stroustrup indentation style.
                   6106: 
                   6107: @section Brace Placement (Functions)
                   6108: @cindex coding standards, brace placement, functions
                   6109: 
                   6110: We use modern, ANSI-style function prototypes, with the type specifier on the same line as the function name. You may encounter other styles in the code, but we are transitioning to the new style as time permits.
                   6111: 
                   6112: Below is a correct example:
                   6113: 
                   6114: @verbatim
                   6115: int main(int argc, char **argv, char **envp)
                   6116: {
                   6117: 
                   6118: }
                   6119: @end verbatim
                   6120: 
                   6121: @section Brace Placement (if-for-while-do)
                   6122: @cindex coding standards, brace placement, if-for-while-do
                   6123: 
                   6124: The @code{if} keyword should be followed by one space, then the opening paren and conditional expression. We also use Stroustrup-style @code{else} blocks, rather than the K&R 'cuddled' @code{else}:
                   6125: 
                   6126: @verbatim
                   6127: if (x) {
                   6128: ...
                   6129: }
                   6130: else {
                   6131: ...
                   6132: }
                   6133: 
                   6134: while (1) {
                   6135: ...
                   6136: }
                   6137: 
                   6138: for (i = 1; i < 10; i++) {
                   6139: ...
                   6140: }
                   6141: 
                   6142: do {
                   6143: ...
                   6144: } while (x);
                   6145: @end verbatim
                   6146: 
                   6147: Single-statement if blocks should be isolated to a single line:
                   6148: 
                   6149: @verbatim
                   6150: if (x) stmt();
                   6151: @end verbatim
                   6152: 
                   6153: not:
                   6154: 
                   6155: @verbatim
                   6156: if (x)
                   6157:     stmt ();
                   6158: @end verbatim
                   6159: 
                   6160: Notice that there is a space between @code{if} and @code{(x)}, and also between @code{stmt} and @code{()}. This should be followed throughout the code.
                   6161: 
                   6162: If an @code{if} block has an @code{else if} or @code{else}, all parts of the construct must be bracketed, even if one or more of them contain only one statement:
                   6163: 
                   6164: @verbatim
                   6165: if (x) {
                   6166:     foo();
                   6167: }
                   6168: else if (y) {
                   6169:     bar();
                   6170: }
                   6171: else {
                   6172:     bas();
                   6173: }
                   6174: @end verbatim
                   6175: 
                   6176: @section Labels and goto
                   6177: @cindex coding standards, labels
                   6178: @cindex coding standards, goto
                   6179: 
                   6180: Labels must begin in column 1, and have two lines of vertical space above and one beneath.
                   6181: 
                   6182: @section Preprocessor Conditionals
                   6183: @section coding standards, preprocessor conditionals
                   6184: 
                   6185: I have struggled with this, but have settled upon the standard practice of keeping them in column 1.
                   6186: 
                   6187: @section Overall Program Spacing
                   6188: @cindex coding standards, spacing of programs
                   6189: 
                   6190: @itemize @bullet
                   6191: @item
                   6192: Variable declarations fall immediately beneath the opening curly brace, and should initialize the variable right there whenever initialization is used.
                   6193: 
                   6194: @item
                   6195: One line between the last variable declaration and the first line of real code.
                   6196: 
                   6197: @item
                   6198: The @code{return} statement of a function (when used as the last line of a function) should have one blank line above it and none below it.
                   6199: 
                   6200: @item
                   6201: Really long functions (those whose entire body is longer than 24 lines) should have a comment immediately following the closing curly brace of the function, telling you what function the closing brace terminates.
                   6202: @end itemize
                   6203: 
                   6204: @section The switch() Statement
                   6205: @cindex coding standards, switch()
                   6206: 
                   6207: We indent @code{case} one level beneath @code{switch()}, and the code within each @code{case} beneath the @code{case}. Each @code{case} should have one line of vertical whitespace above it:
                   6208: 
                   6209: @verbatim
                   6210: switch(foo) {
                   6211: 
                   6212:     case some_const:
                   6213:         foo();
                   6214: 
                   6215:         break;
                   6216: 
                   6217:     case some_other_const:
                   6218:         bar();
                   6219: 
                   6220:         break;     
                   6221: 
                   6222:     default:
                   6223:         exit(1);
                   6224: 
                   6225:         break;
                   6226: }
                   6227: @end verbatim
                   6228: 
                   6229: @section Comments
                   6230: @cindex coding standards, comments
                   6231: 
                   6232: We use C-style comments (@code{/* comment */}) exclusively, even on single-line comments. C++ comments (@code{// comment}) are not permitted.
                   6233: 
                   6234: @node Index
                   6235: @unnumbered Index
                   6236: 
                   6237: @printindex cp
                   6238: 
                   6239: @bye

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>