MexScript

From XentaxWiki
Revision as of 07:12, 31 December 2005 by imported>Multimedia Mike (→‎Basics)
Jump to navigation Jump to search

BMS stands for Binary MultiEx Scripts. It is the format used by MultiEx Commander to take apart an impressive array of GRAFs. The file format consists of a text file which a series of instructions to be run through an interpreter. The interpreter uses the instructions to traverse through a GRAF file and search for key data such as names, offsets, and sizes of various constituent files.

Basics

Each line of a BMS script contains a single statement. The statement can be broken down into a series of tokens.

Questions: Are all statements constrained to one line? or can they span multiple lines? If the former, then the semi-colon at the end of each line seems superfluous. Or can there be comments after the semi-colon?

Another question: There always seems to be a space between the last token and the semi-colon. Does that space need to be there? --Multimedia Mike 02:12, 31 Dec 2005 (EST)

Statements

The first token on a statement line indicates what operation that line is to perform. These are the known statement types:

  • Do
  • FindLoc
  • For
  • Get
  • GetDString
  • GoTo
  • IDString
  • ImpType
  • Log
  • Math
  • Next
  • SavePos
  • Set
  • While

Comments

Does BMS make provision for comments?

Case Sensitivity

Is BMS case sensitive? Does it have to be written as IDString, or will idstring or iDstrINg both work?

Variables

BMS scripts can declare variables and perform basic arithmetic operations on them and control operations with them.

Control Structures

BMS scripts are executed in order from top to bottom unless an alternate control structure is encountered. These control structures include Do..While and For..Next loops.

Question: Is there any equivalent to the 'while {}' C structure or WHILE..WEND structure in BASIC? IOW, a pre-evaluation control structure instead of just the post-evaluation version?

Do..While

The structure of the Do..While loop is as follows:

Do ;
statement 1 ;
--
statement n ;
While condition ; 

Condition compares 2 values, e.g., a variable and a constant, and branches execution back to statement 1 if the condition is evaluated to be true. The available comparison operators are:

< - less than
> - greater than
<> - not equal o
What are all the operators?

For..Next

The structure of the For..Next loop is as follows:

For I = 1 to M;
statement 1 ;
--
statement n ;
Next I ;

This example performs the sequence of statement between the the For and Next statements for M iterations.

Statement Reference

Do

FindLoc

For

Get

GetDString

GoTo

GoTo pos unknown ;

The GoTo statement causes the interpreter to jump to a specified offset with the GRAF file.

* pos: The offset to jump to.
* unknown: this always seems to be 0 but I do not know its true function --Multimedia Mike 02:11, 31 Dec 2005 (EST)

IDString

ImpType

I have absolutely no clue what this is for... --Multimedia Mike 02:07, 31 Dec 2005 (EST)

Log

Log name offset size unknown1 unknown2 ;

The Log statement signals to the interpreting engine that it has found the information for a particular file including the file's name, absolute offset within the GRAF file, and the number of contiguous bytes it occupies in the GRAF.

  • name: A text string indicating the filename. If the filename can not be determined, set this to NULL ("").
  • offset: The absolute offset of the file within the GRAF.
  • size: The number of contiguous bytes that the file occupies in the GRAF beginning from offset.
  • unknown1:
  • unknown2:

obviously, those last 2 arguments are a bit fuzzy to me; someone please help me out on those

Math

Math var1 op var2 ;

The Math statement performs an arithmetic operation on a variable.

  • var1: The variable to be modified.
  • op: The arithmetic operation to be performed. Known operations include:
    • += : Add var2 to var1 and store the sum in var1.
    • *= : Multiply var1 by var2 and store product in var1.
    • /= : Integer divide var1 by var2 and store the quotient in var1.
    • are there any other operations? I suspect there is also -= but I did not want to put it in until I am sure--Multimedia Mike 02:06, 31 Dec 2005 (EST)
  • var2: The value to apply to first variable. Note that this can be either an variable or a constant value.

Next

SavePos

Set

While