Jump to content

MexScript

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 217.122.0.33 (talk) at 06:25, 29 June 2012 (→‎Design). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

MexScript
Paradigmdomain-specific:functional:structured:end-user
Designed byMike Zuurman
DeveloperMike Zuurman
First appeared1997
Typing disciplinedynamic
Major implementations
MultiEx Commander, and others

MexScript[1] is a multi-paradigm computer scripting language used in a number of game resource archive file handlers. It was originally created for the 16-bit command-line tool multiex, and later 32-bit versions of MultiEx Commander. It is a script that enables the end user to have the interpreting program perform a number of tasks needed to access file contents, as well as to replace file contents. The MexScript has since become one of the standards to process game archives, as is indicated by the implementation of the script (also referred to as multiex, MexCom3, BMS) in similar programs, such as Dragon UNpack[2], Game Extractor[3], OpenMEX[4], FusePAK[5], and the more recent dialect QuickBMS[6].

History

MexScript was created in 1997 for multiex by Mike Zuurman and fed to the tool using .INI files[7][8]. The script was improved upon in later releases of MultiEx Commander. The name stems from the abbreviation of multiex to 'mex', though it is also referred to as Binary MultiEx Script (BMS) which in essence is a compiled version of MexScript[9][10][11]. MexScript is interpreted by a Dynamic-link library called "multiex.dll" for the Windows version of MultiEx Commander, and a public version was released on the 24th of July 2003[12].

Implementations

Besides MultiEx Commander, the MexScript has been implemented in a number of other applications. The multiex Dynamic-link library was used after initial release in a similar game archive file handler called Dragon UNpack[13]. The scripting language itself was also implemented in the linux tool Fusepak[14], the Python application OpenMEX[15] and the Java application Game Extractor[16]. A dialect of MexScript/BMS also first appeared on the Xentax Foundation's Game Research Forum on April 16th 2009[17] in the form of the QuickBMS console application.

Design

MexScript is a domain specific, structured functional scripting language designed for the end-user. The primary domain is the processes required to handle game resource archive formats (GRAF). GRAF is a term first coined in November 2003[18]. The purpose of writing in the MexScript scripting language is to manipulate the contents of GRAs in order to MOD a computer game.

Script

An extensive description of MexScript is found at the developer's site, while the dialect is explained here.

The last release of the 16-bit implementation in 1998 of MultiEx Commander featured statements and commands as follows[19]:

ID, EVENTS, NOFILENAMES, GetLong, FlipLong, GetInt, GetString, WriteLong, GetDString, GetNullString, StrCReplace, StrEReplace, LOOP, ENDLOOP, SavePos, GoTo, SET, SETFILECNT, ADD, SUBST, SETBYTESREAD, MULTIPLY, UP, DOWN, PROMPTUSER, ExtractFILE, SETPATH, FindFileID, Case, SeparateHeader.

Later versions were much evolved to the current documentation, with greater functionality.

Data

Depending on the dialect or original implementation, the data types can differ substantially. MexScript for MultiEx Commander has the following:

  • Long --> 32-bit value (4 bytes, Little endian)
  • Int --> 16-bit value (2 bytes, Little endian)
  • Byte --> 8-bit value (1 byte)
  • ThreeByte --> 24-bit value (three bytes, Little endian)
  • String --> null-terminated string of characters (a string ending with a 0 byte)

Scoping

Variables do not have to be declared before use; their scope is then global, except when a variable that has not been used before is involved in some kind of calculation. In such a case it is declared using a SET <variable> statement. All variables can be changed at run-time, allowing for self-modifying code.

Output

The scripting language typically outputs a list of files contained in a game resource archive, along with the offsets and sizes, along with information on their name and putative compression. This is done in 32-bit MultiEx Commander and other implementations using the Log statement, or CLog statement[20].

Control structure commands

MexScript provides several common control structures.

  • ifelse test [ do_if_true list ] [do_if_false list]
  • do-while condition [instruction list]
  • for-next loops

Recursion is MexScript's preferred processing paradigm.

I/O

Output of the original multiex.exe was either extraction or importation of files contained in archives. The 32-bit implementation would output a list of files contained in the processed archive, along with information on their position, size, name and compression type. This list would then be fed to MultiEx Commander, or similar tools.

Syntax

In the original 16-bit version, commands were to be written on one line, but later versions allowed more. Anything written after the # (hash) is ignored, allowing the coder to insert comments. Each line ends with a ; (semicolon), though it is not obligatory in the latest implementation.

References