Below I show commands to control program flow, like, conditions, loops, define script arguments and so on. Other commands can be found in chapters MathGL core and Data processing. Note, that some of program flow commands (like define, ask, call, for, func) should be placed alone in the string.
'path'
¶Changes the current directory to path.
$N 'question'
¶Sets N-th script argument to answer which give the user on the question. Usually this show dialog with question where user can enter some text as answer. Here N is digit (0...9) or alpha (a...z).
$N smth
¶Sets N-th script argument to smth. Note, that smth is used as is (with ‘'’ symbols if present). Here N is digit (0...9) or alpha (a...z).
name smth
¶Create scalar variable name
which have the numeric value of smth
. Later you can use this variable as usual number.
$N smth
¶Sets N-th script argument to character with value evaluated from smth. Here N is digit (0...9) or alpha (a...z).
$N smth
¶Sets N-th script argument to number with value evaluated from smth. Here N is digit (0...9) or alpha (a...z).
'funcname' [ARG1 ARG2 ... ARG9]
¶Executes function fname (or script if function is not found). Optional arguments will be passed to functions. See also func.
'funcname' [narg=0]
¶Define the function fname and number of required arguments. The arguments will be placed in script parameters $1, $2, ... $9. Note, script execution is stopped at func
keyword, similarly to stop command. See also return.
'filename'
¶Load additional MGL command from external module (DLL or .so), located in file filename. This module have to contain array with name mgl_cmd_extra
of type mglCommand
, which describe provided commands.
val
then CMD
¶Executes command CMD
only if val
is nonzero.
val
¶Starts block which will be executed if val
is nonzero.
dat 'cond'
¶Starts block which will be executed if dat satisfy to cond.
val
¶Starts block which will be executed if previous if
or elseif
is false and val
is nonzero.
dat 'cond'
¶Starts block which will be executed if previous if
or elseif
is false and dat satisfy to cond.
Starts block which will be executed if previous if
or elseif
is false.
Finishes if/elseif/else
block.
$N v1 v2 [dv=1]
¶Starts loop with $N-th argument changing from v1 to v2 with the step dv. Here N is digit (0...9) or alpha (a...z).
$N dat
¶Starts loop with $N-th argument changing for dat values. Here N is digit (0...9) or alpha (a...z).
Finishes for
loop.
Starts infinite loop.
val
¶Continue loop iterations if val is nonzero, or finishes loop otherwise.
dat 'cond'
¶Continue loop iterations if dat satisfy to cond, or finishes loop otherwise.
val
¶The code between once on
and once off
will be executed only once. Useful for large data manipulation in programs like UDAV.
Terminate execution.
val
¶Set variant of argument(s) separated by ‘?’ symbol to be used in further commands.
eq1;... var1;... [dt=1
]
¶Make one step for ordinary differential equation(s) {var1’ = eq1, ... } with time-step dt. Here variable(s) ‘var1’, ... are the ones, defined in MGL script previously. The Runge-Kutta 4-th order method is used for solution.