Statements: command, call
A command statement is similar to a function definition except it does not return a result and can only be instigated with a call statement. Optionally, arguments can be passed to the command which can then be used as local variables. When calling the command, these augments may be given values or omitted. An argument can be given a default value when the command is defined.
Statement command Format |
---|
command name { statements ... } call name; |
command name(arg=value, arg=value) { statements ... } call name(value1, value2); |
Statement command Format | |
---|---|
Example | Output |
command wr_today { write string.g:dmy today; } ... call wr_today; | 21 May 2017 |
Written when today = "g:dmy# 21 May 2017" | |
object complex { values real imaginary; } command write_complex( c ) { if v[.object] = complex if c[imaginary] < 0 write c[real] + " - " + c[imaginary] + "i"; elseif c[imaginary] = 0 write c[real]; else write c[real] + " + " + c[imaginary] + "i"; endif endif } call write_complex( {complex 20, -25} ); | 20 - 25i |