| OpendTect User Documentation version 4.2 | ||
|---|---|---|
| Prev | Next | |
Around 2006, it became clear that OpendTect was growing so fast that extensive testing of every part was becoming a real big task. This is a well known issue in the Agile development literature. The usual approach is to implement automated testing.
When designing the implementation, the main issues we had to cope with were:
This resulted in a Command Driver based on the following principles:
ListClick "Calculated attri*" "F03-2" Double Include "$SCRIPTSDIR$/EvalutionEnergyAttrib.odcmd"
Almost immediately we noticed that finding out the names of the fields was very hard without some tool. Therefore, we made the 'Tooltip name guide', which will put OpendTect in a state where the name of a field is shown as a tool tip (overriding any existing tool tip). When it became clear that our automated test facility would be used as a scripting system for power users, we implemented a tool to record actions.
A webinar held in March 2010 gave an extensive overview on the use of OpendTect's Command Driver plug-in. A forty-minutes flash video is available here: Command Driver webinar
Utilities->Tools->Command Driver ...
Secondly, this so-called Command Controller also pops up when pressing Ctrl-R with the mouse pointer inside any OpendTect window or dialog. This is particularly useful if the Command Driver menu bar is greyed out or menu access is blocked after a modal dialog has been popped up. Only a few Qt-borrowed QDialogs like the QMessageBox, QFileDialog and QColorDialog will nevertheless prevent any user input to the Command Controller, and have to be clicked away first.


The Command Controller has a combobox to switch between two appearances. One for running and one for recording a command file. The TooltipNameGuide checkbox can be (un)checked at both appearances. It sets a tooltip mode that displays the hidden name of any uiObject pointed to. Tooltip names are displayed double-quoted on a cyan background. Go to the Survey->Select/Setup window for a small demo-example. Click the '(X,Y) <=> I/C' -button and unveil the hidden names of buttons and input fields with your mouse point er. OpendTect (plugin) developers might have a look in the file $WORK/src/uiIo/uiconvpos.cc to see how these names are annotated in the code.
Running the Command Driver requires selecting an input command file with the extension '.odcmd', or the obsolete '.cmd'. Filenames without a full path are defined relative to the 'Proc'-directory of the current survey. The 'Edit'-button launches a simple text editor to view and edit the input command file directly from OpendTect. One can also specify an output log file to have the Command Driver write its progress and error messages. The 'Examine'-button launches a scroll window to view this log file even while running. The Command Driver starts running when pushing the 'Go'-button, after which 'Pause' and 'Abort'-buttons allow a temporary stop or premature termination.
The Command Recorder is able to record a sequence of user interface actions performed by the user. One has to specify an output command file with the extension '.odcmd'. Filenames without a full path are defined relative to the 'Proc'-directory of the current survey. The 'Examine'-button launches a scroll window to view which commands are written during recording. Recording starts after pushing the 'Start'-button. Next perform a sequence of user actions and push the 'Finish'-button. The Command Controller will automatically switch to run-mode afterwards, so that one can play back the recorded script in order to verify its correct operation. View the log file for eventual errors. Finally, the recorded script can be edited to avoid these errors, improve robustness and general applicability, and insert auxiliary commands.
One does not necessarily have to run a command script from OpendTect's user interface. One or more scripts can also run straight from the command line, and with that they might be called from shell scripts as well. An example of the command line syntax on Linux:
start_dtect cmd=/full_path_1/my_script_1.odcmd ... cmd=/full_path_N/my_script_N.odcmdThis line opens a new instance of OpendTect and starts running the given scripts in there. OpendTect will not automatically close when all scripts are finished. If necessary, this must be done from the last script using the 'Close All' command. Note that command line execution is only possible if your OpendTect auto-loads the Command Driver plug-in at startup.
The user can also create command scripts named 'autoexec.odcmd'. If available, these scripts will be run at start-up before any script specified on the command line. The first autoexec-script to be run is searched in the settings directory. This is the '.od'-subdirectory of your personal home directory, unless the DTECT_SETTINGS or DTECT_WINSETTINGS environment variable specifies otherwise. The second autoexec-script to be run is searched in the 'Proc'-directory of the start-up survey. Next, the command line scripts will be run in order. Moreover, every time a new survey is selected in OpendTect, the 'Proc'-directory of this new survey will also be searched for an autoexec-script to be run at that moment.
Apart from the availability of autoexec-scripts, their execution can always be disabled by adding 'cmd=noautoexec', 'cmd=nosettingsautoexec' or 'cmd=nosurveyautoexec' as an extra argument on the command line. Command line argument 'cmdlog=/full_path/my_odcmdlog.txt' will override the location of the output log file. Its default name is 'odcmdlog.txt' and it is located in the 'Proc'-directory of the start-up survey, if writable, or in the personal user directory otherwise.
To run a command file other than 'autoexec.odcmd' on Windows, one has to create a DOS batch file. That file must contain a command line similar to this:
X:\full_path_0\bin\win64\od_main cmd="X:\full_path_1\my_script_1.odcmd" ...Go to your OpendTect installation folder to ascertain the right name and location of the OpendTect executable (i.e. which disk, bin-path, win32 / win64, and '.exe'-file name?). Executing your DOS batch file will open a new instance of OpendTect and run the given script at startup.
Commands always apply to the current window. This is OpendTect Main Window when starting the driver. Any modal window popping up will automatically become the current window. Modeless windows that pop up can be appointed current window by using the Window-command. In case a modal current window closes, its parent will become the current window. If a modeless current window closes, the latest former current window still existing will be restored as current window. Subwindows in the workspace of another window cannot become current window. No commands can be addressed to the progress window popped up by a uiTaskRunner, since the driver will await its decease before executing a next command. Neither addressible are the Command Controller window and its descendants.
QDialog windows popping up are a special case. OpendTect is borrowing the QMessageBox, QFileDialog, QFontDialog, and QColorDialog from Qt. It is impossible for the command driver to manipulate the contents of these windows. The only QDialog parts that can be manipulated by the driver are those buttons resulting in closing the QDialog. One may use the standard commands Button, Ok, Cancel and Close for this aim. The special commands ColorOk, FileOk and FontOk will be available to specify the desired color, file, or font from the command script directly, meanwhile closing the QDialog.
Neither can the command driver manipulate the contents of windows popped up by batch programs that were launched from OpendTect. An example of this is the multi-machines processing window. Except for manual intervention, there is no workaround yet.
A higher form of window management is provided by the so-called window assertions. These are square-bracketed window names in between the command lines. All commands succeeding a window assertion are expected to be executed in the asserted window. If the current window does not match the latest window assertion, this results into the detection of an error. A window assertion is cancelled either by the next window assertion or by an empty assertion: [].
The benefit of window assertions is in error recovery. If OpendTect does not pop up a window that was expected by the command file or does pop up a window that was not expected by the command file, the Command Driver is able to proceed under guidance of these window assertions. This already solves a lot of cases in which the flow of OpendTect happens to be mildly data or environment dependent. For example, if an error message like "File already exist! Overwrite?" appears but is not handled in the command file (or the other way around), the Command Driver can continue as it was most probably intended by the user: close the window and write the file. Another example is any command to switch on/off a button or menu item. If it happens to be switched on/off already, window assertions enable the Command Driver to skip all commands following from that switch as well.
Although not compulsory, it is advised to make systematical use of window assertions. It also improves the readability of your command file. See any file generated by the Command Recorder to get an idea.
When using window assertions in combination with control flow commands, the most easy-going and efficacious method is having each individual command (If, ElseIf, Then, Fi, For, Rof, DoWhile, Od, Do, OdUntil) both preceded and succeeded by the window assertion in force. Wrongly omitting a window assertion around a control flow command will not result in an assertion violation error, but it does severely reduce the possibilities of the Command Driver to recover in case of other errors.
Many commands supported by the Command Driver use search keys to address window names, names of buttons, input fields and other GUI-elements, item names of menus, lists, trees and tables, etc. The matching of these search keys is strict where necessary and accommodating where practical. The matching process honors the following principles:
The asterisk '*' is used as a wildcard character. It may appear any number of times in the search key to match an arbitrary substring.
Any sequence of white space characters like spaces, tabs, newlines, etc. will be removed at the beginning and at the end of both the match name and search key, and compressed into one single space when found in between.
The ellipses found at the end of menu item names and button texts are ignored. Any dot after the last non-white space character of the match name and search key is removed.
Underscores denoting keyboard shortcuts in menu item names, tab item names and button texts are ignored. The ampersands denoting these shortcuts in Qt-interface programming code should not appear in your search key, unless you want to match an actual ampersand of course.
If the name to match contains a symbol interpreted by the Command Driver as something special, the symbol must be preceded by the escape character '@' in your search key. Symbols for which this may apply include '*', '#', '$', '`', '"', '[' and ']', depending on the context in which the search key occurs. Escaping of symbols that do not have a special meaning is unnecessary but harmless. In the rare case that the match name happens to contain '@' characters preceding a symbol, these themselves have to be escaped in the search key. Alpha-numerical and white space characters are not considered symbols, so a single '@' character in a search key like "jaap.glas@dgbes.com" does not have to be escaped.
One example to demonstrate the use of escape characters. The table column header "* [All lines]" will be matched exactly by the search key "@* [All lines]". The asterisk must be escaped to prevent it from being interpreted as a wildcard for postfix matching, while the brackets do only need escapes when occurring inside window assertions.
Any pair of bracket-like characters enclosing a name to match are ignored, unless the search key does explicitly specify them. Outer character pairs that may be stripped include "...", [...], <...>, and >...<. This matching protocol is recursive. If the match name and search key do not match, eventual outer brackets of the match name are removed, and the whole matching process is repeated.
The Case-command allows the user to determine whether upper-case and lower-case alphabetical characters will match each other. The default is case-insensitive.
Command scripts may contain identifiers to store data and (re)use its values. Every identifier consists of a letter followed by any sequence of letters, digits and underscores ('_'). Identifiers are treated case insensitive. Identifiers can represent constants, script variables, environment variables, built-in function names, or user-defined procedure names.
The Command Driver has only one internal data type. All identifier values are represented as character strings. The string can be a boolean value, an integer value (even octal or hexadecimal), a fixed or floating point value, one single character or indeed a whole character string. The operator or built-in function using the identifier will define into which data type the string has to be converted, and will produce an error if the conversion fails. User-defined procedures should do the same. Boolean values are actually mapped onto numbers, where 0 is false and 1 is true, and any other number is also interpreted as true.
Predefined identifier constants include FALSE==0, TRUE==1, PI==3.14159265..., and UNDEF==1e30. Command actions may assign either SUCCESS==1, FAILURE==0, or WARNING==-1 as return value. Any 'Is...On'-question command returns ON==1, OFF==0, or UNSWITCHABLE==-1 as an answer.
Expressions are assembled from identifiers, numbers, string constants ( "..." ), parentheses, built-in functions, and about twenty mathematical and logical operators (see Expressional specifications). The assign command ( <ident> = <expr> ) stores the evaluated result of an expression into an identifier.
The value of an identifier can be substituted anywhere in the command script by putting the identifier between dollar-signs ( $<ident>$ ). Identifier substitution is the only and most flexible method to give command actions a variable meaning. Multiple substitutions in one command are allowed, but nested substitutions will be misinterpreted. Assign the result of the inner substitution to an auxiliary identifier, and use that one in the outer substitution.
In order to keep the parsing of command actions tractable, few commands will directly accept expressions as argument(s). Apart from the assign command, the only ones are control flow commands: If, ElseIf, For, DoWhile, OdUntil, Return, and any user-defined procedure call with value parameters. If you want to use an expression in an arbitrary command action, assign the expression result to an identifier and substitute its value.
Identifier substitution can also be used to simulate array variables (e.g. array[index]). The Command Driver does not explicitly support them, but index substitution can be applied for that purpose: array_$index$.
The predefined directory identifiers BASEDIR, DATADIR, PROCDIR, APPLDIR, USERDIR, SCRIPTSDIR, SNAPSHOTDIR, IMPORTDIR and EXPORTDIR are environment variables that can be substituted in file-path specifications. Their purpose is defining a file-path relatively to either OpendTect, the current survey, user directories, etc. The Command Driver will automatically change Unix-style file-paths into Windows-style file-paths on Windows-platforms and vice versa. The special identifier IDX (to be called FILEIDX after OpendTect 4.2) represents an integer variable that is automatically incremented after every occurrence in the command stream. It may be substituted in file-paths to generate unique filenames, although meanwhile more sophisticated methods exist as well (see Repetitive task example).
The scope of any identifier used in the body of a command script is global. The scope of any identifier used inside a user-defined procedure is local by default, and may shadow a global identifier with the same name. Attach the scope operator '@' in front of an identifier to force access to its global namesake. That is all for (re)assigning an identifier or (re)defining a procedure. Two extra scope rules apply for reading an identifier or calling a procedure. If an unscoped identifier value is locally undefined, the search will continue at the global scope level directly. If an unscoped procedure call is locally undefined, the search will continue at the previous scope level, and recursively descend to the global level as long as no definition is found.
dTect V4.0 OpendTect commands Mon Apr 20 09:20:09 2009 !The Command Driver expects one command per line and one line per command by default. Multiple commands on one line must be separated by a semicolon (';'). Long commands exceeding the width of one line may be broken by adding a backslash ('\') as last non-white character on the line. Never put a break before white space, since preceding white space on the next line will be considered indentation. Instead of using a backslash break, one can also leave the Enter-key unpressed at all and simply have the line run through the right margin. Empty lines and (commentary) lines starting with a '#'-symbol are allowed and ignored.
One can make a quick start by having the first command file generated by the Command Recorder, and start editing from there.
| <abc> | syntax placeholder |
| | | exclusive-or between alternatives |
| ? | zero or one occurrences |
| * | zero or more occurrences |
| + | one or more occurrences |
| <action> | I. Basic commands (also generated by Command Recorder) |
| Window "<winname>" <winname> = <searchstr><disambiguator>? <searchstr> = (<wildcard>?<textstr>)*<wildcard>? <wildcard> = '*' <disambiguator> = '#'<selnr> <selnr> = <posint> | <negint> |
Switches the focus between different windows on screen. Any window not having a modal child displayed may be specified as the new current window. This command is needed to access modeless windows, since only modal windows that pop up will automatically become the current window. Window names may contain one or more wildcards to match arbitrary substrings. If a (wildcarded) window name matches more than once, a number can be attached to disambiguate the search. Windows are numbered in order of appearance. A negative number will count the windows in reverse. |
| '[' <winname>? ']' |
This window assertion tells the Command Driver what is supposed to be the current window when the commands succeeding the assertion are processed. A mismatch will result into an error. The latest assertion is cancelled by either a next assertion or the empty assertion: [ ]. If a window assertion refers to a modeless window, it will be set as the new current window. This makes the Window-command above obsolete in case window assertions are used. |
| Menu "<menupath>" <onofftag>? <onofftag> = (On | 1) | (Off | 0) <menupath> = <pathstr> <pathstr> = <itemname>( <sep><itemname> )* <sep> = '`' <itemname> = <searchstr><disambiguator>? |
Selects a menu (sub)item by providing the whole menu path. Checkable menu items are toggled, unless the optional On/Off-argument specifies their desired state. Any search name provided to the Command Driver, including menu (item) names, may contain one or more wildcards to match arbitrary substrings. If a (wildcarded) item name matches more than once in a (sub)menu or any other list, a number can be attached to disambiguate the search. A negative number will count the matching items in reverse. To give a few exotic examples: the menu path "Survey`*#-1" would select the last item of the Survey-menu, while the path "Survey`#1" would refer to its first empty-named item. |
| Button "<keystr>" <onofftag>? <keystr> = <objname>( <sep><objname> )*<disambiguator>? <objname> = <searchstr> |
Press a (push/radio/check/tool)-button by providing one or more search keys. Multiple search keys are not allowed for QDialog windows. Checkable buttons are toggled, unless the optional On/Off-argument specifies their desired state. The best search key is of course the button name, but some objects do not have a (visible) name and lots of times names are not unique. Therefore, a key may just as well refer to another object in the neighbourhood of the button to click. The list of possible buttons will be narrowed down for every next key provided. If the referred object is closer to one button than another, the latter will be dropped. The vicinity criterion is based on the youngest common ancestor of referred object and button in the object tree. If the user is unable to specify a set of keys that leaves exactly one button, as a last resort one of the remaining buttons can be selected by attaching a disambiguation number after the last key. Beware that the order of those buttons will be fixed, but unlike menus not always in a left-right top-down fashion. The buttons will be counted in reverse in case the disambiguator is negative. |
| ButtonMenu "<keystr>" "<menupath>" <onofftag>? |
Selects an item from the menu attached to a button. Some tool-buttons contain a left-clickable arrow part to have such a menu appeared. Checkable menu items are toggled, unless the optional On/Off-argument specifies their desired state. Selection of the button is analogous to the button selection described above. Selection of the menu (sub)item is analogous to the Menu-command. |
| Input "<keystr>" <inpdata>? <entertag>? <entertag> = Enter | Hold <inpdata> = "<inputstr>" | <number> | FilePath "<filepathstr>" |
Inputs a string or number into one of the fields of the current window. The field selection is analogous to the button selection described above. The Hold-option only triggers actions defined on changing the input field, while the Enter-option also triggers actions defined on pressing the enter/return-key afterwards. The latter is the default. If no input data is provided, the current contents of the selected field will be entered. The FilePath-option forces the input string to be treated as a file-path concerning platform independence. This will happen automatically in case the input string contains any directory identifier substitute ( $...DIR$ ), or in case the input field comes together with a Select-button and perhaps an Examine-button into a graphical element called uiFileInput. |
| Spin "<keystr>" <spinsteps> <entertag>? <spinsteps> = <posint> | <negint> |
Clicks a spinbox any number of steps upward (positive) or downward (negative). The spinbox selection is analogous to the button selection described above. The Hold-option only triggers actions defined on changing the spinbox value (after each step), while the Enter-option also triggers actions defined on the spinbox losing its focus afterwards. The latter is the default. If no number of steps is provided, the spinbox will keep its current value while losing its focus. Multiple steps are only supported as long as no action triggered in between does pop up a modal window. One can also edit the input field of the spinbox directly by using the Input-command instead. |
| Slider "<keystr>" <percentage> <nrsteps>? <nrsteps> = <posint> |
Shifts a slider towards the specified percentage of its range displayed on screen. Beware that the relationship between this percentage and the actual scale represented by the slider is not necessarily linear. It is optional to perform the shift in more than one step, but it may yield nice animations on screen. Multiple steps are only supported as long as no action triggered in between does pop up a modal window. Selecting the slider is analogous to the button selection described above. |
| Wheel "<keystr>" <degrees> <nrsteps>? |
Rotates a thumbwheel a specified number of degrees upwards/downwards or leftwards/rightwards. The number of degrees will only have a direct meaning if the thumbwheel represents an angular scale. It is optional to perform the rotation in more than one step, but it may yield nice animations on screen. Multiple steps are only supported as long as no action triggered in between does pop up a modal window. Selecting the thumbwheel is analogous to the button selection described above. |
| Combo "<keystr>" <itemsel> <itemsel> = "<itemname>" | <selnr> |
Sets the selected item of a combobox, either by its name or by its ordinal number in the list. The list will be traversed in reverse if the number is negative, so for instance -1 refers to the last item. Using a selection number is just a shortcut for composing an item name "*#<selnr>" from merely a wildcard and a disambiguator. The selection of the combobox itself is analogous to the button selection described above. The Input-command may be applied to edit the input field of the current item of an editable combobox. |
| ListClick "<keystr>" <itemsel> <mousetag>? <mousetag> = <ctrlclick>?<doubleclick>?<leftrightclick>? <ctrlclick> = Ctrl <doubleclick> = Double <leftrightclick> = Left | Right |
Clicks and (de)selects precisely one item in a listbox. Selection possibilities for listbox and item are analogous to combobox selection. The optional mousetag is defining whether the item is (de)selected by means of optional control- or double-clicking of either the left or right mouse button. Left is default in all cases. Beware that the mousetag is one united word and order counts. Some listboxes pop up a menu when (right)-clicking on an item, in which case one has to apply the ListMenu-command instead. Single-selection listboxes will only select the clicked item and deselect all others. Multi-selection listboxes act different in the following cases. Control-clicking toggles the selected state of the clicked item, while any other item keeps its current state. Right-clicking an already selected item leaves the whole selection unchanged. |
| ListButton "<keystr>" <itemsel> <mousetag>? <onofftag>? |
(Un)checks the button in front of a listbox item. The check-button is toggled unless the optional On/Off-argument specifies its desired state. (De)selection of item and listbox is fully analogous to the ListClick-command. Beware that mousetags with Double or Right are known not to have a (lasting) effect on the check-button. |
| ListMenu "<keystr>" <itemsel> <mousetag>? "<menupath>" <onofftag>? |
Selects a (sub)item from the menu attached to a listbox item. Checkable menu items are toggled, unless the optional On/Off-argument specifies their desired state. The selection of both listbox and item is analogous to the ListClick-command. However, since OpendTect is normally hiding its popup menus under the right mouse button, the default for no mousetag at all is set Right over here. Selection of the menu (sub)item is analogous to the Menu-command. |
| ListSelect "<keystr>" <firstitemsel> <lastitemsel>? <onofftag>? <firstitemsel> = <lastitemsel> = <itemsel> |
Selects any number of items in a multi-selection listbox. Selection possibilities are more comprehensive than those at the ListClick-command. Now all items matching a given (wildcarded) item name can be specified. One can also specify the whole range between a first and a last item at once. The list will be traversed cyclically in case the first item succeeds the last. Without the optional On/Off-argument, all specified items will be selected and all other items deselected. With the On/Off-argument set however, only specified items will be selected/deselected respectively, while unspecified items keep their current state. |
| TableClick "<keystr>" <tableitemsel> <mousetag>? <tableitemsel> = <headitemsel> | <cellsel> <headitemsel> = <headtag> <itemsel> <headtag> = RowHead | ColHead <cellsel> = <rowsel> <colsel> | Cell <itemsel> <rowsel> = <colsel> = <itemsel> |
Clicks either a row-head, col-head or cell in a table, and select precisely the one row, column or cell attached to it. Selection possibilities for the RowHead-, ColHead- and Cell-options are analogous to the item selection for list- and comboboxes. The Cell-option puts all cells row-after-row in a virtual list for this purpose. Another way to address a single cell is by selecting both its row and its column. Also these row and column selections are analogous to the item selection just mentioned. If the row or column selection is not made by number but by name, then the search for a match will start in its header. In case the table shows no header or no row/col-head is matching, then the search will proceed in the next column/row until a match is found. The selection of the table itself is analogous to the button selection described above. The option specifying a left, right or double mouse-click will be Left by default. Some tables pop up a menu when right-clicking a cell, in which case one has to apply the TableMenu-command instead. |
| TableFill "<keystr>" <cellsel> <inpdata> |
Fills one cell in a table with new text data. Alike the Input-command, this might be a text string, a file-path string or a number. The selection of both table and cell is analogous to the TableClick-command, except that table headers cannot be filled. |
| TableMenu "<keystr>" <cellsel> <mousetag>? "<menupath>" <onofftag>? |
Selects a (sub)item from the menu attached to a table cell. Checkable menu items are toggled, unless the optional On/Off-argument specifies their desired state. The selection of both table and cell is analogous to the TableFill-command. Selection of the menu (sub)item is analogous to the Menu-command. |
| TableExec "<keystr>" <cellsel> <action> |
Executes a local command driver action within one cell of a table (instead of within the current window). The selection of both table and cell is analogous to the TableFill-command. Only those commands accepting a keystring argument might be appropriate actions to execute within a cell. For example, if the top-left cell of a table contains a single combobox, its selection can be made as follows: TableExec "my table" 1 1 Combo "*" "my item" Tables with cells containing multiple user-interface objects of the same or different kind can be handled too. |
| TableSelect "<keystr>" <tableitemrangesel> <onofftag>? <tableitemrangesel> = <headitemrangesel> | <cellrangesel> <headitemrangesel> = <headtag> <firstitemsel> <lastitemsel>? <cellrangesel> = <firstcellsel> <lastcellsel>? <firstcellsel> = <lastcellsel> = <cellsel> |
Selects any number of rows, columns or cells in a table. This command is the table-equivalent of the ListSelect-command. Selection possibilities are more comprehensive than those at the TableClick-command. Now all row-heads, col-heads or cells matching a given (wildcarded) item name can be specified. One can also specify the whole block between a first and a last row, column, or cell at once. The table will be traversed cyclically in case the first (cell) row or (cell) column succeeeds the last. Without the optional On/Off-argument, all specified cells will be selected and all other cells deselected. With the On/Off-argument set however, only specified cells will be selected/deselected respectively, while unspecified cells keep their current state. |
| Tab "<keystr>"? "<tabname>" <tabname> = <itemname> |
Puts a tab on top of the stack by name. Since windows with more than one tab-stack will be rare, its selection is optional. The selection is analogous to the button selection described above. |
| TreeClick "<keystr>"? <treenodesel> <mousetag>? <treenodesel> = "<treepath>" | PathCol "<treepath>" <colsel> <treepath> = <pathstr> |
Clicks and selects precisely one node in a tree. The selection of a tree node is analogous to the selection of a menu (sub)item. In which column to click is optional, but it will be the first one by default. This column selection is almost analogous to the column selection for tables. If the selection is not made by number but by name, then the search for a match will start in the column header, and next proceed at the selected tree node if not successful. Selection of the tree itself is analogous to the button selection described above. It is optional because the current window will often contain only one (data) tree. The data tree with the lowest scene number is guaranteed to be the default for OpendTect Main Window. The option to specify a left, right or double mouse-click will be Left by default. Any tree node might pop up a menu when right-clicking on one of its columns, in which case the TreeMenu-command has to be applied instead. |
| TreeExpand "<keystr>"? "<treepath>" <onofftag>? |
(Un)expands the subtree of a node in a tree. The expander is toggled unless the optional On/Off-argument specifies its desired state. The selection of both tree and node is analogous to the TreeClick-command, except that column selection is not an issue here. |
| TreeButton "<keystr>"? "<treepath>" <mousetag>? <onofftag>? |
Presses the button in front of a node in a tree. The button is toggled unless the optional On/Off-argument specifies its desired state. The selection of both tree and node is analogous to the TreeClick-command, except that column selection is not an issue here. |
| TreeMenu "<keystr>"? <treenodesel> <mousetag>? "<menupath>" <onofftag>? |
Selects a (sub)item from the menu attached to a column of a tree node. Checkable menu items are toggled, unless the optional On/Off-argument specifies their desired state. The selection of tree, node and column is analogous to the TreeClick-command. Selection of the menu (sub)item is analogous to the Menu-command. |
| CanvasMenu "<keystr>" "<menupath>" <onofftag>? |
Selects a (sub)item from the menu popping up at a canvas area. Checkable menu items are toggled, unless the optional On/Off-argument specifies their desired state. Selection of the canvas area is analogous to the button selection described above. Selection of the menu (sub)item is analogous to the Menu-command. |
| Ok Cancel |
These are special commands that 'Ok' or 'Cancel' a dialog. Usually, this has the same effect as pressing the Ok- or Cancel-button. |
| Close <closeoption>? <closeoption> = All | <subwinsel> <subwinsel> = "<keystr>"? "<winname>" |
Clicks on the Close-button in the title bar of the current window. The All-option will close all OpendTect windows at once. This option is compulsory in case OpendTect Main Window is the current window, so that OpendTect cannot be killed by accident. The optional subwindow selection is available to close a window in the workspace of the current window by name. Since windows with more than one workspace will be rare, selection of the workspace is optional. This selection is analogous to the button selection described above. |
| Show <subwinsel>? <showtag> <showtag> = Minimized | Maximized | Normal |
Clicks on the Minimized-, Maximized- and Restore-buttons in the title bar of the current window. The optional subwindow selection is available to resize a window in the workspace of the current window by name. Since windows with more than one workspace will be rare, selection of the workspace is optional. This selection is analogous to the button selection described above. |
| ColorOk <colorsel> <colorsel> = "<rgbtcolorstr>" | <color> <transparency>? <color> = "<rgbcolorstr>" | <R> <G> <B> | <colortag> <rgbtcolorstr> = <rgbstr><sep><transparency> <rgbcolorstr> = <R><sep><G><sep><B> <R> = <G> = <B> = <transparency> = <byte> <colortag> = Black | Blue | Brown | Cyan | Green | Grey | Lilac | Lime | Magenta | Olive | Orange | Purple | Pink | Red | White | Yellow |
Specifies the desired color while closing a QColorDialog window. One may specify a color either by its RGB-values (0-255) or a color tag. In case the QColorDialog offers the possibility to specify transparency, the value of the optional t-channel (0-255) is passed as well. Its default value is 0 (non-transparent). The RGB-values and optional t-channel can also be specified in one composite RGB(t) color string. |
| FileOk "<filepathset>" <filepathset> = <filepathstr>( <sep><filepathstr> )* |
Specifies one, or more file-paths while closing a QFileDialog window. The command will yield an error message if their number, type (file/directory), extension, and/or writability is not in agreement with the current mode of the QFileDialog. File-paths will be interpreted platform independently. Both absolute and relative file-paths are accepted. The current directory of the QFileDialog will be taken as base directory in the latter case. Also a set of directory identifiers has been predefined for substitution ( $...DIR$ ) in file-paths. The FileOk-command does not provide the functionality of the QFileDialog-button "Create new folder". If a file-path specifies a non-existing file or directory, its parent directory must exist. |
| <action> | II. Auxiliary commands (to be inserted by the user) |
| Include "<filepathstr>" |
Inserts another command file into the command stream. The file-path will be interpreted platform independently. In order to specify the file-path relative to either OpendTect, current survey, or user directories, one of the predefined directory identifiers can be substituted ( $...DIR$ ). |
| GreyOuts <greyoutstag> <greyoutstag> = Count | Skip |
Specifies whether to count or skip disabled (greyed out) user interface objects, tabs, menu and tree items. 'Skip' is the default. 'Count' means that also grey-outs will be counted when using selection numbers. Furthermore, it allows (question) commands to retrieve information from grey-outs. Command actions trying to manipulate a grey-out will be penalized. |
| Case <casetag> <casetag> = Sensitive | Insensitive |
Switches between case-sensitive and case-insensitive searching in menus, windows, lists, etc. Insensitive is the default. The command parsing itself (command names and options, function names, identifier names) is case-insensitive by nature and will ignore this setting. |
| OnError <errortag> <errortag> = Stop | Recover |
Switches between different procedures to handle an error. The Stop-option will exit the driver immediately. The Recover-option will make use of window assertions to safely proceed execution in specific cases. The default option is Recover. |
| LogMode <logtag> <logtag> = Basic | Normal | All |
Regulates the amount of warning and error messages in the log file. The All-option will show any message generated. The Normal-option is the default. It shows all parsing messages, but action messages are only shown if the action result is not assigned to an identifier. The Basic-option will also omit all warning messages. |
| Snapshot "<imagefilepathstr>" <frametag>? <frametag> = CurWin | ODMain | Desktop <imagefilepathstr> = <filepathstr><imageext> <imageext> = .bmp | .jpg | .jpeg | .png | .ppm | .xbm | .xpm |
Writes a snapshot of the current window (and its environment) to file. The default grabbing area is bounded by the CurWin-frame, but can optionally be enlarged towards the ODMain-frame or the whole Desktop-frame. The snapshot filename must have one of the prescribed image extensions. The file-path will be interpreted platform independently. Both absolute and relative file-paths are accepted. Also one of the predefined directory identifiers may be substituted ( $...DIR$ ) in the file-path. |
| Sleep <seconds> <sleeptag>? <sleeptag> = Regular | Extra |
Sleeps a period of time so that spectators can distinguish the consecutive steps from a command file on screen. The Regular-option will sleep until further notice between every two commands with a visual effect. The Extra-option is the default and will take an (additional) nap only once. |
| Wait <seconds> <sleeptag>? |
Tells the next command to wait a period of time only if it is uncertain whether it has finished processing. This can happen to any command closing a modal dialog that was already open when the Command Driver started. The Regular-option will allow this waiting time to every command until further notice. The Extra-option is the default and will allow an (additional) wait only to the next command. |
| Pause "<textlines>"? <textlines> = <textstr>( <sep><textstr> )* |
Temporarily hold the execution of the command script and have the Command Controller pop up a message dialog with a 'Resume'-button so that the user can decide when to continue. Specifying lines of text is optional. |
| Guide "<textlines>" ( <guidetag> "<winname>" )? <guidetag> = Existent | Inexistent | Accessible | Inaccessible |
Temporarily hold the execution of the command script and have the Command Controller pop up a dialog requesting the user to take action. The text lines describe which actions the user has to perform. The Command Driver will automatically resume if some window matching a given name is no longer (in)existent or (in)accessible. If this option is not specified, the user gets a 'Done'-button to have the Command Driver resume manually. |
| Comment "<textlines>" |
Inserts comment lines into the log file. Command lines starting with a '#'-symbol are containing comments that are not shown in log files. |
| <action> | III. Control flow commands (to be inserted by the user) |
| Assign <ident> <expr> <ident> '=' <expr> <ident> = <scope>?<identstr> <identstr> = <letter><identchars>* <identchars> = <letter> | <digit> | '_' <scope> = '@' <expr> = <ident> | <number> | "<textstr>" | '(' <expr> ')' | <functioncall> | <operatorexpr> <functioncall> = <funcname>'(' <expressions>? ')' <funcname> = <ident> <expressions> = <expr> ( ',' <expr> )* |
Assigns the evaluated result of an expression to an identifier. The command syntax is available in both procedural style and operator style. Identifiers consist of a letter followed by any sequence of letters, digits and underscores. Expressions are assembled from identifiers, numbers, string constants, parentheses, built-in functions, and about twenty mathematical and logical operators. Notice that a function call allows no space between the function name and its opening parenthesis. All functions, operators and predefined identifiers are listed below in Expressional specifications. |
|
Executes a number of command actions if a boolean expression evaluates to true. The ElseIf- and Else-branches are optional, but note that the terminating Fi-command is compulsory. | |
|
Initializes an identifier with the evaluated result of a numerical expression and repeats a number of command actions as long as the identifier value does not exceed the evaluated result of the optional To-expression. After every loop iteration, the identifier is incremented by the evaluated result of the optional Step-expression. The default step is 1, but even negative values are allowed. Only the Break-command can escape from a For-loop in absence of a To-expression. Note that the terminating Rof-command is compulsory. | |
|
Repeats the execution of a number of command actions as long as a boolean expression evaluates to true. Note that the terminating Od-command is compulsory. | |
|
Repeats the execution of a number of command actions until a boolean expression evaluates to true. | |
| Break |
Escapes immediately from the innermost For-, While-, or Until-loop. |
| Continue |
Skips the remaining actions in the current iteration of the innermost For-, While-, or Until-loop. |
| Try <ident> <action> <ident>? '~' <action> |
Tries to execute a command action and assigns its result to an identifier. The command syntax is available in both procedural style and operator style. The possible outcomes are success (1), failure (0) and warning (-1), for which the identifier constants SUCCESS, FAILURE and WARNING have been predefined. The operator style syntax is also usable without identifier for the side-effect, because error messages will be temporarily ignored. |
| <questioncmd> <ident> <questionargs> <ident> '?' <questioncmd> <questionargs> |
Stores the answer from a question command into an identifier. The command syntax is available in both procedural style and operator style. All question commands implemented so far are listed below in Table IV to VII. |
|
Specifies a user-defined procedure in which a number of command actions are executed. Note that the terminating Fed-command is compulsory. Nested procedure definitions are allowed. A definition may occur anywhere, as long as it precedes the first call to it. The course of a procedure depends on an optional number of value parameters (between the parentheses) and variable parameters (behind the parentheses). Procedure names can only be overloaded if there is a difference in the number of value or variable parameters. Distinction on data type is not possible, having only one internal (string) type. The optional return parameter is not counted at overloading, but acts like a variable parameter apart from that. It can be applied to give the procedure a more function-like appearance. Unlike built-in functions however, this does not at all mean that procedure calls can be used as (sub)expressions. |
| Return <expr>? |
Escapes immediately from the current procedure. In case its definition includes a return parameter, it will be assigned with the optional expression that is returned. |
| ( <ident> '?' )? <procname>'(' <expressions>? ')' <ident>* |
Calls a user-defined procedure specified earlier by means of the Def-command above. Its optional value parameters will accept expressions. Its optional return and variable parameters only accept identifiers, and these might be modified. Notice that a procedure call allows no space between the procedure name and its opening parenthesis. |
| End |
Finishes the command stream immediately. |
| <questioncmd> <questionargs> | IV. Question commands (to be inserted by the user) |
| IsMatch "<searchstr>" "<textstr>" <casetag> |
True (1) if the text string matches the search key according to the rules described in the Search keys paragraph, false (0) otherwise. The identifier constants TRUE and FALSE have been predefined for convenience. If the optional case-sensitivity of the match is not specified, the global settings defined by the Case-command will apply. The options are 'Insensitive' or 'Sensitive'. |
| IsWindow "<winname>"? <winproptag>? <winproptag> = Existent | Accessible | Modal | QDialog | <showtag> |
True (1) if a specified window has a particular boolean property, false (0) otherwise. The optional property tells whether the window is either existent (default), accessible, modal, maximized, minimized, normal or a QDialog. The optional selection of the window is analogous to the Window-command. By default, the current window will be selected. |
| IsMenuItemOn "<menupath>" |
On (1) if the selected menu (sub)item is checked, off (0) if it is unchecked, and unswitchable (-1) if it is not checkable at all. The identifier constants ON, OFF and UNSWITCHABLE have been predefined for convenience. The selection of the menu (sub)item is analogous to the Menu-command. |
| NrMenuItems "<menupath>?" |
Returns the number of (enabled) items in the selected (sub)menu. The GreyOuts-command defines whether disabled items are counted as well. Selection of a sub-menu is analogous to the selection of menu items in the Menu-command. The root menu is denoted by an empty menu-path (""). Zero is returned if the menu-path leads to a leaf menu item. |
| GetMenuItem "<menupath>" <formtag>? <formtag> = Text | Number |
Returns the text or number of a selected menu (sub)item. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. Selection of the menu (sub)item is analogous to the Menu-command. |
| IsButtonOn "<keystr>" |
On (1) if the selected radio-, check-, or toolbar button is checked, off (0) if it is unchecked, and unswitchable (-1) in case of a push button or a non-checkable toolbar button. The identifier constants ON, OFF and UNSWITCHABLE have been predefined for convenience. The button selection is analogous to the Button-command. |
| GetButton "<keystr>" <buttonformtag>? <buttonformtag> = Text | Color |
Returns the text or color of a (push/radio/check/tool)-button. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. If the button has no text or color, an empty string or transparent white is returned respectively. The button selection is analogous to the Button-command. |
| IsButtonMenuItemOn "<keystr>" "<menupath>" |
On (1) if the selected menu (sub)item of a button is checked, off (0) if it is unchecked, and unswitchable (-1) if it is not checkable at all. The selection of button and menu (sub)item is analogous to the ButtonMenu-command. |
| NrButtonMenuItems "<keystr>" "<menupath>?" |
Returns the number of (enabled) items in the selected (sub)menu of a button. The GreyOuts-command defines whether disabled items are counted as well. The selection of button and sub-menu is analogous to the ButtonMenu-command. The root menu is denoted by an empty menu-path (""). Zero is returned if the menu-path leads to a leaf menu item. |
| GetButtonMenuItem "<keystr>" "<menupath>" <formtag>? |
Returns the text or number of the selected menu (sub)item of a button. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. Selection of button and menu (sub)item is analogous to the ButtonMenu-command. |
| GetInput "<keystr>" <inputformtag>? <inputformtag> = Text | FilePath |
Returns the current content of a selected input field. In which form is optional and 'Text' by default. Selection of the input field is analogous to the Input-command. In case the input field comes together with a Select-button and perhaps an Examine-button into a graphical element called uiFileInput, the 'FilePath' option forces the current filename to be preceded by the absolute file path to the current selection directory. Otherwise an empty string will be returned. |
| GetSpin "<keystr>" <spinformtag>? <spinformtag> = Text | Value | Minimum | Maximum | Step |
Returns the text, value, minimum, maximum or step of the selected spinbox. In which form is optional and textual by default. Selection of the spinbox is analogous to the Spin-command. |
| GetSlider "<keystr>" <sliderformtag>? <sliderformtag> = Text | Value | Minimum | Maximum | Percentage |
Returns the text, value, minimum, maximum or percentage of the selected slider. In which form is optional and textual by default. Beware that the returned percentage of the range displayed on screen will not necessarily have a linear relationship with the returned value. Selection of the slider is analogous to the Slider-command. |
| GetWheel "<keystr>" <wheelformtag>? <wheelformtag> = Text | Angle |
Returns the text or angle (in degrees) of the selected thumbwheel. In which form is optional and textual by default. Selection of the thumbwheel is analogous to the Wheel-command. |
| NrComboItems "<keystr>" |
Returns the number of items in a selected combobox. The selection of the combobox is analogous to the Combo-command. |
| CurComboItem "<keystr>" <formtag>? |
Returns the text or number of the current combobox item. In which form is optional and textual by default. The selection of the combobox is analogous to the Combo-command. |
| IsComboItemOn "<keystr>" <itemsel> |
On (1) if the specified combobox item is currently selected, and off (0) if it is currently deselected. Specification of the combobox and its item is analogous to the Combo-command. |
| GetComboItem "<keystr>" <itemsel> <formtag>? |
Returns the text or number of a selected combobox item. In which form is optional and textual by default. Selection of the combobox and its item is analogous to the Combo-command. |
| NrTabs "<keystr>"? |
Returns the number of (enabled) tabs in a selected tab-stack. The GreyOuts-command defines whether disabled tabs are counted as well. The optional selection of the tab-stack is analogous to the Tab-command. |
| CurTab "<keystr>"? <formtag>? |
Returns the text or number of the current tab. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled tabs are counted as well. The optional selection of the tab-stack is analogous to the Tab-command. |
| IsTabOn "<keystr>"? "<tabname>" |
On (1) if the selected tab is currently on top, and off (0) if it is currently underneath. Selection of tab-stack and tab-name is analogous to the Tab-command. |
| GetTab "<keystr>"? "<tabname>" <formtag>? |
Returns the text or number of a selected tab. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled tabs are counted as well. Selection of tab-stack and tab-name is analogous to the Tab-command. |
| IsCanvasMenuItemOn "<keystr>" "<menupath>" |
On (1) if the selected menu (sub)item in the pop-up menu of a canvas area is checked, off (0) if it is unchecked, and unswitchable (-1) if it is not checkable at all. The selection of canvas area and menu (sub)item is analogous to the CanvasMenu-command. |
| NrCanvasMenuItems "<keystr>" "<menupath>?" |
Returns the number of (enabled) items in the selected (sub)menu popping up at a canvas area. The GreyOuts-command defines whether disabled items are counted as well. The selection of canvas area and sub-menu is analogous to the CanvasMenu-command. The root menu is denoted by an empty menu-path (""). Zero is returned if the menu-path leads to a leaf menu item. |
| GetCanvasMenuItem "<keystr>" "<menupath>" <formtag>? |
Returns the text or number of the selected menu (sub)item in the pop-up menu of a canvas area. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. The selection of canvas area and menu (sub)item is analogous to the CanvasMenu-command. |
| IsShown <subwinsel>? <showtag> |
True (1) if a selected subwindow in the workspace of the current window is minimized, maximized, or normal size respectively, and false (0) otherwise. Specification of size property and optional subwindow is analogous to the Show-command. Not selecting a subwindow will yield the size properties of the current window itself. |
| <questioncmd> <questionargs> | V. List question commands (to be inserted by the user) |
| NrListItems "<keystr>" |
Returns the number of items in a selected listbox. The selection of the listbox is analogous to the ListClick-command. |
| CurListItem "<keystr>" <curtag>? <listformtag>? <curtag> = Framed | Selected <listformtag> = Text | Number | Color |
Returns the text, number or background color of the current listbox item. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. If there is no current listbox item, an empty string, zero or transparent white is returned respectively. By default, the current listbox item is the one that is 'Framed'. Optionally, if precisely one item is 'Selected' (i.e. highlighted), it can be requested as current listbox item instead. The selection of the listbox is analogous to the ListClick-command. |
| IsListItemOn "<keystr>" <itemsel> |
On (1) if a specified item in a listbox has been selected (i.e. highlighted), off (0) if it has been deselected, and unswitchable (-1) if the listbox does not support item selection at all. The specification of listbox and item is analogous to the ListClick-command. |
| GetListItem "<keystr>" <itemsel> <listformtag>? |
Returns the text, number or background color of a selected listbox item. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. Selection of both listbox and item is analogous to the ListClick-command. |
| IsListButtonOn "<keystr>" <itemsel> |
On (1) if the button in front of a listbox item is checked, and off (0) if it is unchecked. Selection of both listbox and item is analogous to the ListButton-command. |
| IsListMenuItemOn "<keystr>" <itemsel> "<menupath>" |
On (1) if the selected menu (sub)item of a listbox item is checked, off (0) if it is unchecked, and unswitchable (-1) if it is not checkable at all. The selection of the listbox, its item and the menu (sub)item is analogous to the ListMenu-command. |
| NrListMenuItems "<keystr>" <itemsel> "<menupath>?" |
Returns the number of (enabled) items in the selected (sub)menu of a listbox item. The GreyOuts-command defines whether disabled items are counted as well. Selection of the listbox, its item and a sub-menu is analogous to the ListMenu-command. The root menu is denoted by an empty menu-path (""). Zero is returned if the menu-path leads to a leaf menu item. |
| GetListMenuItem "<keystr>" <itemsel> "<menupath>" <formtag>? |
Returns the text or number of the selected menu (sub)item of a listbox item. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. The selection of the listbox, its item and the menu (sub)item is analogous to the ListMenu-command. |
| <questioncmd> <questionargs> | VI. Table question commands (to be inserted by the user) |
| NrTableRows "<keystr>" |
Returns the number of rows in the selected table. The selection of the table is analogous to the TableClick-command. |
| NrTableCols "<keystr>" |
Returns the number of columns in the selected table. The selection of the table is analogous to the TableClick-command. |
| CurTableItem "<keystr>" <curtag>? <tableformtag>? <tableformtag> = Text | Number | Color |
Returns the text, number or background color of the current table item. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. If there is no current table item, an empty string, zero or transparent white is returned respectively. Like the CurListItem-command, the current table item is by default the one that is 'Framed'. Optionally, if precisely one item is 'Selected' (i.e. highlighted), it can be requested as current table item instead. The selection of the table is analogous to the TableClick-command. |
| CurTableRow "<keystr>" <curtag>? <tableformtag>? |
Returns the row-header text, number or background color of the current table row. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. If the table has no row header or no current row, an empty string, zero or transparent white is returned respectively. Like the CurListItem-command, the current table row is by default defined by the item that is 'Framed'. Optionally, if precisely one (entire row of) item(s) is 'Selected' (i.e. highlighted), the row at issue can be requested as current table row instead. The selection of the table is analogous to the TableClick-command. |
| CurTableCol "<keystr>" <curtag>? <tableformtag>? |
Returns the column-header text, number or background color of the current table column. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. If the table has no column header or no current column, an empty string, zero or transparent white is returned respectively. Like the CurListItem-command, the current table column is by default defined by the item that is 'Framed'. Optionally, if precisely one (entire column of) item(s) is 'Selected' (i.e. highlighted), the column at issue can be requested as current table column instead. The selection of the table is analogous to the TableClick-command. |
| IsTableItemOn "<keystr>" <tableitemsel> |
On (1) if a specified item in a table has been selected (i.e. highlighted), off (0) if it has been deselected, and unswitchable (-1) if the table does not support item selection at all. The specification of table and item is analogous to the TableClick-command. A row-head or col-head item is considered selected only if all table cells in that row or column are selected. |
| GetTableItem "<keystr>" <cellsel> <tableformtag>? |
Returns the text, number or background color of a selected table cell. In which form is optional and 'Text' by default. In the 'Number' case, the table cells are counted row-by-row. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. Selection of both table and cell is analogous to the TableFill-command. |
| GetTableRow "<keystr>" <tableitemsel> <tableformtag>? |
Returns the row-header text, number or background color of a selected table item. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. Selection of both table and item is analogous to the TableClick-command. If the selected item is not a row-head item itself, it refers to the row-head item straight above it. |
| GetTableCol "<keystr>" <tableitemsel> <tableformtag>? |
Returns the column-header text, number or background color of a selected table item. In which form is optional and 'Text' by default. The RGBt color string format returned in the 'Color' case is defined at the ColorOk-command. Selection of both table and item is analogous to the TableClick-command. If the selected item is not a col-head item itself, it refers to the col-head item left next to it. |
| IsTableMenuItemOn "<keystr>" <cellsel> "<menupath>" |
On (1) if the selected menu (sub)item of a table cell is checked, off (0) if it is unchecked, and unswitchable (-1) if it is not checkable at all. The selection of the table, its cell and the menu (sub)item is analogous to the TableMenu-command. |
| NrTableMenuItems "<keystr>" <cellsel> "<menupath>?" |
Returns the number of (enabled) items in the selected (sub)menu of a table cell. The GreyOuts-command defines whether disabled items are counted as well. Selection of the table, its cell and a sub-menu is analogous to the TableMenu-command. The root menu is denoted by an empty menu-path (""). Zero is returned if the menu-path leads to a leaf menu item. |
| GetTableMenuItem "<keystr>" <cellsel> "<menupath>" <formtag>? |
Returns the text or number of the selected menu (sub)item of a table cell. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. The selection of the table, its cell and the menu (sub)item is analogous to the TableMenu-command. |
| <questioncmd> <questionargs> | VII. Tree question commands (to be inserted by the user) |
| NrTreeItems "<keystr>"? "<treepath>?" |
Returns the number of (enabled) items in a selected tree node. The GreyOuts-command defines whether disabled items are counted as well. The optional selection of the tree is analogous to the TreeClick-command. This also holds for its tree node, except that column selection is not an issue here. The root node is denoted by an empty tree path (""). Zero is returned if the tree path leads to a leaf tree item. |
| NrTreeCols "<keystr>"? |
Returns the number of columns in a tree. The optional selection of the tree is analogous to the TreeClick-command. |
| CurTreeItem "<keystr>"? <curtag>? <formtag>? |
Returns the text or number of the current tree item. In which form is optional and textual by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. If there is no current tree item, an empty string or zero is returned respectively. Like the CurListItem-command, the current tree item is by default the one that is 'Framed'. Optionally, if precisely one item is 'Selected' (i.e. highlighted), it can be requested as current tree item instead. The optional selection of the tree is analogous to the TreeClick-command. |
| CurTreePath "<keystr>"? <curtag>? <formtag>? |
Returns the path to the current tree item. In which form is optional and textual by default. The 'Number' case is especially useful if 'Text' would yield an ambiguous tree path. The GreyOuts-command defines whether disabled items are counted as well. If there is no current tree item, an empty path ("") is returned. Like the CurListItem-command, the current tree item is by default the one that is 'Framed'. Optionally, if precisely one item is 'Selected' (i.e. highlighted), it can be requested as current tree item instead. The optional selection of the tree is analogous to the TreeClick-command. |
| CurTreeCol "<keystr>"? <formtag>? |
Returns the column text or number of the current tree item. In which form is optional and textual by default. Note that the current tree item is merely column-specific in case of the default 'Framed' setting. The optional selection of the tree is analogous to the TreeClick-command. |
| IsTreeItemOn "<keystr>"? "<treepath>" |
On (1) if a specified item in a tree has been selected (i.e. highlighted), off (0) if it has been deselected, and unswitchable (-1) if the tree does not support item selection at all. Specification of the tree and its node is analogous to the TreeClick-command, except that column selection is not an issue here. |
| IsTreeItemExpanded "<keystr>"? "<treepath>" |
True (1) if a specified item in a tree has been expanded, false (0) if it has been collapsed, and unexpandable (-1) if it is a leaf node. Beware that an expanded tree node can have a collapsed ancestor. Specification of the tree and its node is analogous to the TreeClick-command, except that column selection is not an issue here. |
| GetTreeItem "<keystr>"? <treenodesel> <formtag>? |
Returns the item number of a tree node or the text in one of its columns. In which form is optional and textual by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. The selection of the tree, its node and column is analogous to the TreeClick-command. |
| GetTreePath "<keystr>"? "<treepath>" <formtag>? |
Returns the path to a selected tree node. In which form is optional and textual by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. It can be used for converting a path from one form to another. Specification of the tree and its node is analogous to the TreeClick-command, except that column selection is not an issue here. |
| GetTreeCol "<keystr>"? <treecolsel> <formtag>? <treecolsel> = <colsel> | PathCol "<treepath>" <colsel> |
Returns the text or number of a selected tree column. In which form is optional and textual by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. Selection of the tree, its column and an optional node is analogous to the TreeClick-command. If the column selection is made by name, the search for a match will start in the column header. If not successful, it proceeds at the specified tree node in the 'PathCol' case, or traverses all tree nodes breadth-first otherwise. |
| IsTreeButtonOn "<keystr>"? "<treepath>" |
On (1) if the button in front of a tree node is checked, and off (0) if it is unchecked. Selection of both the tree and its node is analogous to the TreeButton-command. |
| IsTreeMenuItemOn "<keystr>"? <treenodesel> "<menupath>" |
On (1) if the selected menu (sub)item attached to a column of a tree node is checked, off (0) if it is unchecked, and unswitchable (-1) if it is not checkable at all. The selection of the tree, its node and column, and the menu (sub)item is analogous to the TreeMenu-command. |
| NrTreeMenuItems "<keystr>"? <treenodesel> "<menupath>?" |
Returns the number of (enabled) items in the selected (sub)menu attached to a column of a tree node. The GreyOuts-command defines whether disabled items are counted as well. Selection of the tree, its node and column, and a sub-menu is analogous to the TreeMenu-command. The root menu is denoted by an empty menu-path (""). Zero is returned if the menu-path leads to a leaf menu item. |
| GetTreeMenuItem "<keystr>"? <treenodesel> "<menupath>" <formtag>? |
Returns the text or number of the selected menu (sub)item attached to a column of a tree node. In which form is optional and 'Text' by default. In the 'Number' case, the GreyOuts-command defines whether disabled items are counted as well. The selection of the tree, its node and column, and the menu (sub)item is analogous to the TreeMenu-command. |
| Precedence | Associativity | <operatorexpr> | VIII. Logical and mathematical operators (to be used in expressions) |
| 1 | right-to-left | ! <expr> | Logical not |
| right-to-left | + <expr> | Unary plus | |
| right-to-left | - <expr> | Unary minus | |
| 2 | right-to-left | <expr> ^ <expr> | Raise to power |
| 3 | left-to-right | <expr> * <expr> | Multiplication |
| left-to-right | <expr> / <expr> | Real division | |
| left-to-right | <expr> | <expr> | Integer division | |
| left-to-right | <expr> % <expr> | Modulo | |
| 4 | left-to-right | <expr> + <expr> | Addition |
| left-to-right | <expr> - <expr> | Subtraction | |
| 5 | left-to-right | <expr> < <expr> | Less than |
| left-to-right | <expr> <= <expr> | Less than or equal | |
| left-to-right | <expr> > <expr> | Greater than | |
| left-to-right | <expr> >= <expr> | Greater than or equal | |
| 6 | left-to-right | <expr> == <expr> | Equality (numerical if possible, string otherwise) |
| left-to-right | <expr> != <expr> | Inequality (numerical if possible, string otherwise) | |
| 7 | left-to-right | <expr> && <expr> | Logical AND |
| 8 | left-to-right | <expr> || <expr> | Logical OR |
| 9 | right-to-left | <expr> ? <expr> : <expr> | Conditional operator (if-then-else) |
| <functioncall> | IX. Mathematical functions (to be used in expressions) |
| abs( <expr> ) | Absolute value |
| acos( <expr> ) | Arc cosine |
| asin( <expr> ) | Arc sine |
| atan( <expr> ) | Arc tangent between -PI/2 and PI/2 |
| atan2( <y_expr>, <x_expr> ) | Arc tangent of y/x between -PI and PI |
| ceil( <expr> ) | Smallest integer not less than |
| cos( <expr> ) | Cosine |
| exp( <expr> ) | Exponent |
| floor( <expr> ) | Largest integer not greater than |
| ln( <expr> ) | Natural logarithm |
| log( <expr> ) | Base-10 logarithm |
| rand( <max_expr>? ) | Uniform random value between 0 and optional maximum, 1 by default |
| randG( <stddev_expr>? ) | Gaussian random value with mean 0 and optional standard deviation, 1 by default |
| round( <expr> ) | Round to nearest integer |
| sgn( <expr> ) | Sign (1 if greater than zero, 0 if zero, -1 if less than zero) |
| sin( <expr> ) | Sine |
| sqrt( <expr> ) | Square root |
| tan( <expr> ) | Tangent |
| trunc( <expr> ) | Round to integer in direction of zero |
| <functioncall> | X. Statistical functions (to be used in expressions) |
| avg( <expressions> ) | Average |
| max( <expressions> ) | Maximum |
| min( <expressions> ) | Minimum |
| sum( <expressions> ) | Sum |
| var( <expressions> ) | Variance |
| med( <expressions> ) | Median |
| <functioncall> | XI. String functions (to be used in expressions) |
| curWindow() | Title of current window |
| isAlNum( <expr> ) | True (1) if all characters are alpha-numerical, false (0) otherwise |
| isAlpha( <expr> ) | True (1) if all characters are letters, false (0) otherwise |
| isDigit( <expr> ) | True (1) if all characters are digits, false (0) otherwise |
| isInteger( <expr> ) | True (1) if representing an integer, false (0) otherwise |
| isLower( <expr> ) | True (1) if all characters are lower-case letters, false (0) otherwise |
| isNumber( <expr> ) | True (1) if representing a number, false (0) otherwise |
| isSpace( <expr> ) | True (1) if all characters are white space, false (0) otherwise |
| isUpper( <expr> ) | True (1) if all characters are upper-case letters, false (0) otherwise |
| strCat( <expressions> ) | String concatenation |
| strLen( <expr> ) | String length in characters |
| strSel( <str_expr>, <firstpos_expr>, <lastpos_expr>? ) | Character selection. Last position is optional. Negative positions count in reverse. |
| sepStrCat( <expressions> ) | Concatenation of separation-strings (menu- and tree-paths, RGB(t) color strings) |
| sepStrLen( <expr> ) | Number of separated substrings |
| sepStrSel( <str_expr>, <firstpos_expr>, <lastpos_expr>? ) | Selection of separated substring(s). Last position is optional. Negative positions count in reverse. |
| toLower( <expr> ) | Converts all letters to lower-case |
| toUpper( <expr> ) | Converts all letters to upper-case |
| wildcard( <selnr_expr>? ) | Matching substring for a wildcard in the latest successful wildcarded command action. Default selection number is 1. A negative number counts the wildcards in reverse. |
| wildcardStr( <selnr_expr>? ) | The whole matching string around a wildcard in the latest successful wildcarded command action. Wildcard selection is analogous to the wildcard()-function above. |
| <ident> | $<ident>$ | XII. Predefined identifiers (to be used in substitution and expressions) |
| TRUE FALSE | 1 0 | Logical constants |
| PI | 3.14159265 ... | Trigonometric constant |
| UNDEF | 1e30 | OpendTect's undefined value. Treated as such by all logical, mathematical, and statistical operators and functions defined above. |
| SUCCESS FAILURE WARNING | 1 0 -1 | Possible results of 'Try'-command |
| ON OFF UNSWITCHABLE | 1 0 -1 | Possible results of any 'Is...On'-question command |
| BASEDIR | Base data directory ( setenv DTECT_[WIN]DATA ) | |
| DATADIR | $BASEDIR$/<cur_survey> | Survey directory |
| PROCDIR | $DATADIR$/Proc | Processing directory |
| APPLDIR | Installed software directory ( setenv DTECT_[WIN]APPL ) | |
| USERDIR | Personal home directory ( setenv DTECT_PERSONAL_DIR ) | |
| SCRIPTSDIR | $PROCDIR$ | Overruled by setenv DTECT_SCRIPTS_DIR |
| SNAPSHOTSDIR | $DATADIR$/Snapshots | Overruled by setenv DTECT_SNAPSHOTS_DIR |
| IMPORTDIR | $DATADIR$/Import | Overruled by setenv DTECT_IMPORT_DIR |
| EXPORTDIR | $DATADIR$/Export | Overruled by setenv DTECT_EXPORT_DIR |
| IDX (OpendTect 4.2) FILEIDX (OpendTect 4.3) | 1000++ | Integer variable that is automatically incremented after every occurrence in the command stream. It may be substituted in file-paths to generate unique filenames. |
One of the recurring user questions about OpendTect is whether there is a quick way to do some kind of repetitive task. Loading a huge amount of wells, importing multiple 2D line SEG-Y data, etc. Such a service can only be offered by OpendTect itself if the task is very simple, common and straightforward. For example, one does have the possibility to select multiple horizons with the mouse in order to load them in one go. However, if the repetitive task is more complex, unique, or variant, the workflow can be automatized by means of a command script.
The current Command Driver capabilities are demonstrated by automizing a case raised by Magnus Lidgren. His scene contained a big number of 2D lines, and a number of attributes on each line. He needed to generate a picture for every attribute of every 2D line, and wanted to avoid doing that manually.
Automizing a repetitive task consists of three stages. Firstly, the Command Recorder is applied to record the mouse and keyboard actions needed to perform the task once. Secondly, a text editor is used to modify the recorded script. Some of the recorded actions have to be generalized, and a few new commands have to be added to make the script iterative. These commands are listed in Table III. Thirdly, the Command Driver is applied to run the modified script, initially to debug it and finally to perform the repetitive task.
Listed below is the recorded command script that makes a snapshot of one attribute on one 2D line. The passages that need to be generalized have been printed in red.
[OpendTect Main Window] TreeMenu "2D Seismics`LS 5k`i5007`Seis" "Display in a 2D Viewer as`VD" [2D Viewer - Line: i5007] Button "Save image" [Create snapshot] Button "Screen" On Input "Select filename" "/d43/jaap/surveys/Demo2D/Snapshots/dump.png" Hold Button "Ok" [2D Viewer - Line: i5007] Close [OpendTect Main Window]
Listed below is the modified command script after it has been generalized and made iterative. All changes with regard to the originally recorded script have been printed in green.
Def res ? dumpAttribute( setnr, namenr, attrnr )
[OpendTect Main Window]
res ~ TreeMenu "2D Seismics`*#$setnr$`*#$namenr$`*#$attrnr$" \
"Display in a 2D Viewer as`VD"
If res==FAILURE ; Return ; Fi
pic_name = strCat( wildcard(1), "_", wildcard(2), "_" )
pic_name = strCat( pic_name, wildcard(3), ".png" )
[2D Viewer - Line: *]
Button "Save image"
[Create snapshot]
Button "Screen" On
Input "Select filename" "$SNAPSHOTSDIR$/$pic_name$" Hold
Button "Ok"
[2D Viewer - Line: *]
Close
[OpendTect Main Window]
Fed
For setidx = 1
For nameidx = 1
For attridx = 1
res ? dumpAttribute( setidx, nameidx, attridx )
If !res ; Break ; Fi
Rof
If attridx==1 ; Break ; Fi
Rof
If nameidx==1 ; Break ; Fi
Rof
The introduction of question commands allows the body of the previous script to be written in a different style. An identifier can take the answer to one of the many questions (Nr..., Cur..., Is..., Get...) from Table IV to VII about some property of a user-interface element. Instead of applying the Break-command to escape from loops when the procedure call to dumpAttribute(...,...) fails, now the number of items to iterate over can be asked and set before entering a loop ( nritems ? NrTreeItems ... ). Note that a procedure defined with a return parameter can also be called without. Listed below is the restyled body of the command script above.
nrsets ? NrTreeItems "2D Seismics"
For setidx = 1 To nrsets
nrnames ? NrTreeItems "2D Seismics`*#$setidx$"
For nameidx = 1 To nrnames
nrattrs ? NrTreeItems "2D Seismics`*#$setidx$`*#$nameidx$"
For attridx = 1 To nrattrs
dumpAttribute( setidx, nameidx, attridx )
Rof
Rof
Rof
In the 'doc' directory of the release, you can find a 'Scripts' subdirectory. It contains the standard test scripts for OpendTect. These test scripts all work on a survey 'F3_Demo', the demo data set for OpendTect.
The directory contains several scripts, many of which can be run stand-alone, but certainly not all. There is also an execute-all script: 'AllScripts.cmd'. Another composite script is 'AllAttributes.cmd', which will make snapshots in the Snapshots directory. This Snapshots directory is created automatically; the location is your_surveys/F3_Demo/Snapshots. The snapshots are created as an index followed by the file name.
Another script is 'ExportData.cmd'. While running this script an 'Export' directory is automatically created as a subdirectory of 'F3_Demo'. All the exported data will be stored in the above directory.
Some scripts are dependent on PlugIns like SSIS, VMB etc. These scripts are located in dgb/doc/Scripts. To run these scripts you should make sure the related plugins are loaded.
| Prev | Home | Next |
| Volume statistics | SEG-Y checklist |