MQL Modes

MQL acts an interpreter for 3DSpace and can be used in interactive, script, or tcl mode.

This page discusses:

Interactive

When you use MQL in interactively, you type in one MQL command at a time. As each command is entered, it is processed. This mode is typically used when you have only a few modifications to make or tests to perform.

Interactive mode is useful if you have only a few commands to enter or want more freedom and flexibility when entering commands. However, interactive mode is inefficient for building large databases or to input large amounts of information.

When using the MQL window on a UNIX system (not the Run MQL tool provided by Collaboration and Approvals and not available for Windows), you can use these control characters to edit the text on the command line:

Control Character Description
Ctrl-A Moves the cursor to the beginning of the line.
Ctrl-B Moves the cursor to the left (back) one column.
Esc-B Moves the cursor back one word.
Ctrl-D Deletes the character to the right of the cursor.
Ctrl-E Moves the cursor to the end of the line.
Ctrl-F Moves the cursor right (forward) one column.
Esc-F Moves the cursor forward one word.
Ctrl-H Deletes the character to the left of the cursor.
Ctrl-I Jumps to the next tab stop.
Ctrl-J Returns the current line.
Ctrl-K Kills from the cursor to the end of the line (see Ctrl-Y).
Ctrl-L Redisplays the current line.
Ctrl-M Returns the current line.
Ctrl-N Fetches the next line from the history list.
Ctrl-O Toggles the overwrite/insert mode, initially in insert mode.
Ctrl-P Fetches the previous line from the history list.
Ctrl-R Begins a reverse incremental search through the history list. Each printing character typed adds to the search substring (which is empty initially). MQL finds and displays the first matching location. Typing Ctrl-R again marks the current starting location and begins a new search for the current substring.
Type Ctrl-H Or press the Del key to delete the last character from the search string. MQL restarts the search from the last starting location. Repeated Ctrl-H or Del characters, therefore, unwind the search to the match nearest to the point where you last typed Ctrl-R or Ctrl-S (described below).Type Esc or any other editing character to accept the current match and terminate the search.
Type Ctrl-H Or press the Del key until the search string is empty to reset the start of the search to the beginning of the history list. Type Esc or any other editing character to accept the current match and terminate the search.
Ctrl-S Begins a forward incremental search through the history list. The behavior is like Ctrl-R but in the opposite direction through the history list.
Ctrl-T Transposes the current and previous character.
Ctrl-U Kills the entire line (see Ctrl-Y).
Ctrl-Y Yanks the previously killed text back at the current location.
Backspace Deletes the character left of the cursor.
Del Deletes the character right of the cursor.
Return Returns the current line.
Tab Jumps to the next tab stop.

Script

You can use scripts to combine commands and also to have a repeatable history of commands. You should use MQL scripts as long as you are in the building process. Adding information and files into 3DSpace requires additional MQL commands. Rather than entering them interactively, you can create a new script to handle the new modifications.

When working in the script (or batch) mode, you use a text editor to build a set of MQL commands contained in an external file (a script), that can be sent to the command interface. The interface then reads the script, line by line, and processes the commands just as it would in the interactive mode.

Working in script mode has many advantages, such as:

  • It gives you a written record of all your definitions and assignments. This enables you to review what you have done and make changes easily while you are testing the database. When you are first building the database, you may experiment with different definitions to see which one works best for your application. A written record saves time and aggravation since you do not have to print definitions when there is a question.
  • You can use text editor features to duplicate and modify similar definitions and assignments. Rather than entering every command, you can copy and modify only the values that must change. This enables you to build large and complicated databases quickly.
  • Testing and debugging the database is simplified. MQL databases can be wiped clean so that you can resubmit and reprocess scripts. This means you can maintain large sections of the MQL commands while easily changing other sections. Rather than entering commands to modify the database, you can simply edit the script. If you are dissatisfied with any portion of the database, you can change that portion of the script without eliminating the work you did on other portions. Since the script contains the entire database definition and its assignments, there is no question as to what was or was not entered.

Tcl/Tk

Tool Command Language (Tcl) is a universal scripting language that offers a component approach to application development.. With Tcl embedded in MQL, common programming features such as variables, flow control, condition testing, and procedures are available.

To enter Tcl mode, enter the following in MQL:

tcl;

In Tcl mode, the default Tcl prompt is % and MQL will accept only Tcl commands. Native MQL commands are accessed from Tcl by prefixing the command with the keyword mql. For example:

% mql print context;

Tcl command syntax must be followed. This table summarizes the differences between Tcl and MQL:

Command Item Difference
Comments
If the first nonblank character is #, all the characters up to the next new line are treated as a comment and discarded. The following is not a comment in Tcl:
set b 101; #this is not a comment 
Command Separators New lines are treated as command separators. They must be preceded by a backslash ( \ ) to not be treated as such. A semi-colon ( ; ) also is a command separator.
Commas For MQL to properly parse commands with commas, the commas must be separated with blanks. For example:
access read , write , lock 
Environment Variables Environment variables are accessible through the env array. For example, to access the environment variable MATRIXHOME, use env(MATRIXHOME).
History Tcl has its own history mechanism.

The Tcl command exit returns you to native MQL.