HistoryCal - V0.0.7 Manual
function & call

Home Development V0.0.7 Manual Script function & call

function And call Statements

A function statement defines a function that can either be called from a call statement or used in an expression with the function operator '@'. Optionally, arguments can be passed to the function which can then be used as local variables. When calling the function, these augments may be given values or omitted. An argument can be given a default value when the function is defined.

When the function is run, the arguments are treated as local variables. An addition local variable named 'result' is created, and this is the value given to the function when it used in an expression. Additional variables that are created within the function will be local and their values lost when the function completes. Variables created outside of the function cannot be seen whilst inside.

function Statement
FormatExampleOutput
function name {
statements ...
}

call name;
function wr.today { write string,g:dmy today; } ... call wr.today; 21 May 2017
function name {
... result = expr
}

write @name;
function get.today { return "("+string,g:dmy today+")"; } ... write @get.today; 21 May 2017
function name(arg=value, arg=value) {
statements ...
}

call name(value1, value2);
function wr.range.plus(start, duration){ write string,g:dmy( start ~ start + duration ); } ... call wr.range.plus(date,g:dmy "19sep1948", 7); 19 Sep 1948 ~ 26 Sep 1948
function name(arg=value, arg=value) {
... result = expr
}

write @name(value1, value2);
function range.plus(start, duration){ result = start ~ start + duration; } ... write string,g:dmy @range.plus(2432814, 7); 19 Sep 1948 ~ 26 Sep 1948
Written when today = "g:dmy# 21 May 2017"

Valid XHTML 1.0 Strict

29th April 2017