[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
7.1 MGL definition
MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Command may have up to 1000 arguments (at least for now). Words are separated from each other by space or tabulation symbol. The upper or lower case of words is important, i.e. variables a and A are different variables. Symbol ‘#’ starts the comment (all characters after # will be ignored). The exception is situation when ‘#’ is a part of some string. Also options can be specified after symbol ‘;’ (see section Command options). Symbol ‘:’ starts new command (like new line character) if it is not placed inside a string or inside brackets.
If string contain references to external parameters (substrings ‘$0’, ‘$1’ ... ‘$9’) or definitions (substrings ‘$a’, ‘$b’ ... ‘$z’) then before execution the values of parameter/definition will be substituted instead of reference. It allows to use the same MGL script for different parameters (filenames, paths, condition and so on).
Argument can be a string, a variable (data arrays) or a number (scalars).
- The string is any symbols between ordinary marks ‘'’. Long strings can be concatenated from several lines by ‘\’ symbol. I.e. the string ‘'a +'\<br>' b'’ will give string ‘'a + b'’ (here ‘<br>’ is newline). Also you can concatenate strings and numbers using ‘,’ with out spaces (for example, ‘'max(u)=',u.max,' a.u.'’).
-
Usually variable have a name which is arbitrary combination of symbols (except spaces and ‘'’) started from a letter and with length less than 64. A temporary array can be used as variable:
-
sub-arrays (like in subdata command) as command argument. For example,
a(1)
ora(1,:)
ora(1,:,:)
is second row,a(:,2)
ora(:,2,:)
is third column,a(:,:,0)
is first slice and so on. Also you can extract a part of array from m-th to n-th element by codea(m:n,:,:)
or justa(m:n)
. -
any column combinations defined by formulas, like
a('n*w^2/exp(t)')
if names for data columns was specified (by idset command or in the file at string started with##
). -
any expression (without spaces) of existed variables produce temporary variable. For example, ‘sqrt(dat(:,5)+1)’ will produce temporary variable with data values equal to
tmp[i,j] = sqrt(dat[i,5,j]+1)
. - temporary variable of higher dimensions by help of []. For example, ‘[1,2,3]’ will produce a temporary vector of 3 elements {1, 2, 3}; ‘[[11,12],[21,22]]’ will produce matrix 2*2 and so on. Here you can join even an arrays of the same dimensions by construction like ‘[v1,v2,...,vn]’.
- result of code for making new data (see section Make another data) inside {}. For example, ‘{sum dat 'x'}’ produce temporary variable which contain result of summation of dat along direction ’x’. This is the same array tmp as produced by command ‘sum tmp dat 'x'’. You can use nested constructions, like ‘{sum {max dat 'z'} 'x'}’.
Temporary variables can not be used as 1st argument for commands which create (return) the data (like ‘new’, ‘read’, ‘hist’ and so on).
-
sub-arrays (like in subdata command) as command argument. For example,
-
Special names
nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1
are treated as number if they were not redefined by user. Variables with suffixes are treated as numbers (see section Data information). Names defined by define command are treated as number. Also results of formulas with sizes 1x1x1 are treated as number (for example, ‘pi/dat.nx’).
Before the first using all variables must be defined with the help of commands, like, new, var, list, copy, read, hist, sum and so on (see sections Data constructor, Data filling and Make another data).
Command may have several set of possible arguments (for example, plot ydat
and plot xdat ydat
). All command arguments for a selected set must be specified. However, some arguments can have default values. These argument are printed in [], like text ydat ['stl'='']
or text x y 'txt' ['fnt'='' size=-1]
. At this, the record [arg1 arg2 arg3 ...]
means [arg1 [arg2 [arg3 ...]]]
, i.e. you can omit only tailing arguments if you agree with its default values. For example, text x y 'txt' '' 1
or text x y 'txt' ''
is correct, but text x y 'txt' 1
is incorrect (argument 'fnt'
is missed).
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 21, 2014 using texi2html 5.0.