MOX Coding and Programing Language Syntax Documentation

The MOX coding and programming language pays heritage to BASIC, but has been crafted for the specific type of work and environment that is demanded of Moxie.Build.

Notable Aspects of the MOX Language

Some of the following items may catch developers experienced in other languages off guard; trust us, they are good for you :)

Lines of Code

In the following rules, a line of code is one executable item as viewed by the compiler. A line of text refers to one line in a text editor.


If Req.IsPost : And List.Edit : List.Edit.Proc Job.Edit, "", ""
If condition (Req.IsPost) And (List.Edit) are True, execute the Method (List.Edit.Proc), which has three parameters (Job.Edit, "", "")




All executable code in Moxie.Build is stored in Procedures, each with a unique name, in the Database Tables. There are many different types of Procedures, each with a specific purpose, and are described in detail on the Types of Procedures page.

Memory Scope

Memory scopes in Moxie.Build are called Queries. Each Query may contain zero or more Fields, and one or more Records; similar to a table structure. There is always at least one Record, even if that Record only contains blank Fields. It is valid to conceptually think of a Query as an object; under the hood it is. A Procedure may use up to 64 queries per instance at a time. One of these Queries will be set as the current Top Query, and one of these Queries will be set as the current Work Query.

To better visualize what your memory scope looks like, you can use the ListQueries command followed by the HtmlTable command to display a list of all queries and their respective fields.

To help understand memory usage: The $MaxMem builtin value returns the current maximum memory usage of the process so far and more details can be loaded using the LoadMemUsage command. If the LogMOX Moxie.cfg option is set, the increase in $MaxMem during compilation and running is logged. When using the TRON command, the current value of $MaxMem is shown on each line. Note that in a multi-threaded system like Moxie.Build, the MaxMem value is shared by all threads, and multiple threads running at the same time can all contribute to any growth in MaxMem. When troubleshooting excessive memory usage, always test offline with a single user.


All Procedures (other than Includes) start with two queries, named Input and Output. What these Queries contain at the start of a Procedure is described in further detail on the page for each Procedure Type.

Private Methods & Functions

Within a Procedure, each Private Method/Function starts two Queries, named Me.Input and Me.Output.



Top Query & Work Query

The Top Query and Work Query are how you select which Query objects are referenced line by line. This context saves typing the name of an object in front of every line of code.

Some examples to illustrate:


Text Operators

Math Operators

All math inputs are cleaned up using the following rules:

First Record Only Operators

In most use cases, the Top Query will only have one record in it. However, in atypical use cases with more than one record in the Top Query the assignments using any of the above Operators will assign the value to all records. If required for logic or optimization, the assignment may be limited to the first record only by instead using one of the following operators: ==, +==, &==, ==@, and ||

Operator Precedence

Global Glyphicons & PNG Icons

In any output to the end user, regardless of source, and including text literals within MOX code, you can make use of the Template system's Glyphicons shorthand. The available Glyphicons are those of Bootstrap V3. Note the Bootstrap documentation calls for a space between a Glyphicon and any text.

Instead of using the full bootstrap HTML with class of:

<span class='glyphicon glyphicon-search' aria-hidden='true'></span>

Just use the following instead:

<? i search ?>

Also, PNG icons can be referenced using the following syntax:

<? ii Folder/FileName ?>

Which will be expanded into the following HTML:

<img class='FileIcon' src='/Icon/Folder/FileName.png' />

The value provided for FileName may not be larger than 64 bytes, and valid characters in the file name are limited to the following:

The class of FileIcon is not defined anywhere by default, it is just there in case you need it. Moxie.Build does not come with any icons in the /Public/Icon folder; it is up to you to provide you own. Note that most PNG icon libraries that can be sourced will include different sized icons in different folders, therefore, selecting the icon of the size you want is part of the provided FileName.

Builtin Values

The following Text and Numeric Values are built into the language and may be used anywhere a Top Query Field may otherwise be used. When used by self as a value for a Work Query Parameter, they will need to be solved with ( ). Note that builtin text and number values all start with a leading $ or %, in contrast to builtin Top Query Functions that all end with a trailing $ or %

Request Query

The following values are built into the Request Query, and may be pulled into other queries to be utilized. It is not recommended to work with these values in the Request Query itself.

  • Head.  All HTTP Headers start with this prefix
  • Cookie.  All HTTP Cookies start with this prefix
  • Req.Addr  IP Address of client
  • Req.Accept  HTTP Accept header value
  • Req.AccJson  Accept is set to JSON only
  • Req.Body  HTTP Post Body, up to Cfg RAMRecvSize
  • Req.Boundary  HTTP Post Body Boundary
  • Req.Category  If page is a Category, the Alias of
  • Req.ClientRecv  Bytes Received by Server so far
  • Req.ClientSent  Bytes Send by Server so far
  • Req.Completed  Connections Closed by Server so far
  • Req.CurPage  Current Page File usage
  • Req.CurWork  Current Working Set size
  • Req.Current  Current Connections Open on Server
  • Req.Country  Country of IP per Cfg CountryInfo
  • Req.Details  Raw copy of HTTP Headers
  • Req.FileName  Name of file from /Recv
  • Req.FileSize  Size of file in /Recv
  • Req.HasFile  Is true if file data in /Recv
  • Req.Hits  Number of Requests to Server so far
  • Req.Host  Request Host Header value
  • Req.IsCmdMox  Set if running .mox file via cmd
  • Req.IsDelete  Set if Request mode set to Delete
  • Req.IsGet  Set if Request mode set to Get
  • Req.IsJson  Set if Content-Type is application/json
  • Req.IsPost  Set if Request mode set to Post
  • Req.IsPut  Set if Request mode set to Put
  • Req.Lang  Current client Language
  • Req.Mode  Request mode, such as Get or Post
  • Req.PageFaults  Number of Page Faults so far
  • Req.Path  Request path, no parameter, no leading /
  • Req.Path1  First path level, parsed by /
  • Req.Path2 to Req.Path7  Additional levels
  • Req.PathBase  Path without params, but preserves /Admin Report/Action params, and will always end with ? or &
  • Req.PathWithParams  Full URL, with leading /
  • Req.PeakPage  Highest Page File usage so far
  • Req.PeakWork  Highest Working Set size so far
  • Req.Peek  Highest Current Connections count so far
  • Req.Port  Server side completion port number
  • Req.Post  If page is a Post, the Alias of
  • Req.Protocol  Request protocol, such as http or https
  • Req.RelayHttpsHost  Cfg RelayHttpsHost
  • Req.ServerAddr  IP Address Server is listening on
  • Req.ServerHttpPort  HTTP Port Server
  • Req.ServerHttpsPort  HTTPS Port Server
  • Req.Type  Set to Content-Type
  • Req.Unique  Unique cookie value per visitor

Text Values

  • $B  ASCII 6 (internal flag for DB Backfill fields)
  • $Br  HTML line break < br/ > (no spaces)
  • $Cr  ASCII 13 (carriage return)
  • $CrLf  ASCII 13, 10 (carriage return, line feed)
  • $CTID  Moxie spec. time ordered unique id
  • $CUID  Moxie spec. unique id
  • $DQ  ASCII 34 (double quote)
  • $Day  Day of the month, 2 digits
  • $DayOfWeek  Sunday, Monday, etc.
  • $Delimiters  ASCII 0 to 7 (4 and 5 are user defined)
  • $F  ASCII 1 (internal DB field delimiter)
  • $Greg  Day as a Gregorian number
  • $Gt  ASCII 62 (greater than)
  • $GUID  Microsoft spec. unique id
  • $I  ASCII 2 (item separated in field data or #Attr list)
  • $JNull ASCII 3 (Used to indicate a Null value instead of a blank string in MOX for JSON)
  • $Lf  ASCII 10 (line feed)
  • $Lt  ASCII 60 (less than)
  • $MaxMem Maximum Memory of Process
  • $Month  Month of the year, 2 digits
  • $NbSp  HTML non-breaking space
    • Display data created date and time in the above format.
  • $NowX  YYYY-MM-DD HH:MM:SS.sss
    • Display existing data modified date and time in the above format.
  • $NowXFile  YYYY-MM-DD-HHMMSSsss
  • $Null  ASCII 0 (null)
  • $QCQ  ASCII 34, 44, 24 (dq comma dq)
  • $R  ASCII 0 (internal DB record delimiter)
  • $RootPath  Full disk path to DBStore folder
  • $SQ  ASCII 39 (single quote)
  • $SessionGroupTypes  $I separated list
  • $SessionID  Unique session id for logged in user
  • $SessionIsBad  Contains reason session isn't good
  • $SessionName  FirstName && LastName
  • $SessionTable  eg. MemTab.Person
  • $SessionUser  Alias of user in $SessionTable
  • $Spc  ASCII 32 (space)
  • $Tab  ASCII 9 (tab)
  • $Time  HH:MM:SS
  • $Timer  CPU Counter, accurate to 0.001s
  • $Today  YYYY-MM-DD
  • $ValidAlias  Characters valid for a DB Record Alias
  • $ValidDBField  Characters valid for a DB Field Name
  • $ValidTable  Characters valid for a DB Table Name
  • $Version  Currently-running version of Moxie.Build
  • $WhiteSpace ASCII 32, 13, 10, 9 (space, crlf, tab)
  • $Year  YYYY
  • $XmlHead  Shorthand for XML header string, UTF-8

Numeric Values

  • %‍Day  Day of the month, 2 digits
  • %‍DayOfWeek  Day of the week, Sunday = 1
  • %Greg  Today as a Gregorian number
  • %MaxMem Maximum Memory of Process
  • %Month  Month of the year, 2 digits
  • %Pi  3.14159265358979323
  • %Time  HHMMSS
  • %Timer  CPU Counter, accurate to 0.001s
  • %Today  YYYYMMDD
  • %Year  YYYY





Using the Backtick `

Some Work Query command parameters can accept a source of either a Work Query Field name or a text literal. Text literals in these cases are prefixed with a backtick ` character.