A: Command Line Syntax

 

 

The command line is used to control the program. Command lines can be typed in the input line of the text window or placed in a script file and read into the program with the script file mechanism.

 

Script file have the “.scp” extension.

 

A script file is composed of a number of command lines.

 

 

The syntax of the command line is:

 

Everything on a line following a "#" is a comment and is discarded by the program.

 

The command lines are used to input statements.

 

Statements are composed of words, keywords and operators separated from each other by spaces, tabs or end of lines. They MUST be separated from each other to be recognized. If a word contains a space or a special character, it should be protected with double quotes.

ex:          Read: path C:\Program Files\toto   is invalid

          Read: path "C:\Program Files\toto"   is valid

 

Each statement should be on a line by itself.

 

Multiple statements can be grouped together with the {} syntax. All the statements between the opening bracket "{" and the closing bracket "}" are considered as 1 statement.

ex:          echo: Bonjour       is 1 statement.

 

{

          Echo: 1

          Echo: 2

          Echo: 3

}                                        is also 1 statement.

 

The order of operations inside a statement can be changed with the uses of "()".

Example:  $a = 1 + ( 2 * 3 )  is different than  $a = ( 1 + 2 ) * 3

 

 

The variables

 

Variables can be used anywhere in a script instead of an actual value. The first character of a variable must be "$". A value is assigned to a variable with the "=" character

ex:          $a = Bonjour           will assign the string "Bonjour" to the variable $a

          echo: $a           will echo the string "Bonjour"

 

Variables values can be either a character string, an integer value, a float value or a vector of values.

ex:          $a = Bonjour

          $b = 124

          $c = 3.1416

          $d = 1  2  3.25  126

 

Variables can be used in mathematical expressions. The following operators can be used: "+", "-", "/", "*". Each operator and its operand must be separated from the others by spaces.

 

ex:          $b = ( $a + 3 ) * 2

 

There are 2 kind of variables: system variables and user variables.

 

System variables are already defined by the program. They can be used both to access a system value or to change a system value. Some system variables are read-only, and some are only defined under certain conditions.

 

For example, the variable $TAG is used to represent the TAG value of the pixel under the cursor. This variable is only defined when the cursor is over an image. You can use: "echo: $TAG" to get the pixel’s TAG value, or "$TAG = 1" to assign

 the value 1 to the TAG value. And "$TAG = $TAG + 1" will increment the tag value.

 

If the user attempts to assign a value to a read-only variable, a warning message will be displayed.

 

The name of all system variables are in uppercase characters. We suggest that you use lowercase characters for the names of your local variables.

 

A list of all the defined system variables is given further down.

 

 

The macros

 

A statement can be assigned to a macro. The syntax is:

 

@macro_name = statement

 

The first character of a macro must be "@". A macro is executed simply by entering its name.

ex:          @toto = echo: Bonjour          

will assign the statement "echo: Bonjour" to the macro @toto

 

          @toto                

          will execute the macro @toto

 

 

The commands statements

 

A command statement is composed of a command keyword followed by its associated values. Command keywords are terminated by a ":" character. The syntax is:

 

keyword:  value_1 [...]

 

The identification of keywords is not case sensitive. The number of values associated with a keyword depends on the keyword.

 

A list of all the available command statements and their associated templates is given further down.

 

 

The control statements

 

The "for" loop

 

for variable in ( value [...] )

          statement

 

ex:          for $a in ( 1 2 3 4 5 )

                    echo: $a

will echo the successive values taken by the variable $a, these are: 1, 2, 3, 4 and 5

 

ex:      for $IMAGE_CUR in ( $IMAGE_ALL )

                    snapshot: c:\temp\snap_$IMAGE_CUR

 

will take a snapshot of the screen for all the images in the current group and name these snapshot C:\temp\snap_1 to c:\temp\snap_n (where n is the last image). In this example, $ALL_IMAGES is a vector of values, and $IMAGE_CUR will successively be assigned each of these values. Each time, the assignment will cause the current image to be changed and the window to be redrawn to reflect these changes. (Also see system variable assignment.)

 

 

The "if" statement

 

if ( expression )

          statement

 

If the value of expression is evaluated to a value different than "0" then the test is valid and the statement is executed.

 

A number of comparison operators are available for the tests: "==", "<", ">", "<=" and ">=". These operators will be evaluated to "0" if the test fails and "1" otherwise.

 

Adding  "else" to the "if" statement

 

if ( expression )

          statement1

else

          statement2

 

ex:      if ( $a >= 1 )

                    echo: a

          else

                    echo: b

will only echo "a" if the value of the variable $a is greater or equal to 1, otherwise it will echo "b".

 

 

Keyboard mapping

 

You can assign predefined operations to a keyboard key with the command statement:  "Key: key_def map action". The available "actions" are listed after each tool and mode in this manual and in Appendix B: The available keyboard shortcuts.

 

But also, you can assign a statement or a macro to a keyboard key with the syntax:

 

key: key_def macro statement

 

ex:  key: a macro flood: $TAG + 1

will cause the TAG value under the cursor to be incremented when the key "a" is pressed.

 

Or:

 

key: key_def macro macro_name

 

ex: key: b macro @toto 

will cause the macro @toto to be executed when the key "b" is pressed.

 

 

The templates

 

Some commands can accept templates to match one or multiple entities. They use a "wild cards" syntax similar to the one used by UNIX:

 

?          replaces one character

          ex:  toto_?   Will match toto_1, toto_a but not toto or toto_12

 

*          replaces 0 to many characters

          ex:  toto_*   Will match toto_1, toto_a,  toto_12 but not toto

 

[abc]          replaces one character by a, b or c

          ex:  toto_[12]   Will match toto_1, toto_2 but not toto_a or toto_12

 

[!abc]          replaces one character by any character but a, b or c

          ex:  toto_[!12]   Will match toto_1 but not toto_1 or toto_2

 

[a-c]          replaces one character by a character from a to c

          ex:  toto_[0-9]   Will match toto_1 and toto_2 but not toto_a or toto_12

 

 

So if, for example, you to delete all the Tags between 20 and 59 on the presently selected images, you could replace the "t_tag" in the following command:

          Tag: t_tag del

with the string "[2-5]?"

          Tag: [2-5]? del

 

 

The templates used in sliceOmatic’s command statements are:

 

"t_file" stands for "file template".  It is a template to match the names of the files read in the program (without the path).

 

"t_frame" stands for "frame template".  It is a template to match the names of the frames. "*" will match all frames.

 

"t_geom" stands for "geometry template".  It is a template to match the names of either the TAG derived geometries (names "1" to "256") or the geometries read from files.

 

"t_light" stands for "light template"  The valid light names are: "amb", "1" to "4".

 

"t_mask" stands for "mask template", this template is used to identify one or more geometries in the Geometrical Mask mode.

 

"t_merge" stands for "merge template", this template is used to identify one or more merge values in the Morpho mode. The valid merge values are: "1", "2", "3" and "4".

 

 "t_point" stands for "point template", this template is used to identify one or more points.

 

"t_tag" stands for "tag template", this template is used to identify one or more tags. A tag name can be either it’s number (from "0" to "256") or its label if one has been associated with the tag through a "tag: label" command. The value "cur" stand for the currently selected TAG value.

 

"t_wind" stands for "window template".  A window name is its ID ("1" to "4"). The value "cur" stand for the currently selected window