Navigation Banner
 

function Batch language command
  User defined function declaration.
Syntax  function id (param1,param2,...,paramN) {...body...}
Notes param's are passed by value - i.e. changes to parameters within the function will not affect the variables passed as arguments.

To pass parameters by reference use "param&" in function declaration and pass the name of the variable as a string.

Examples
function sqr (by_value)
{
  by_value = by_value * by_value;
  return by_value;
}

function sqr2(by_ref&)
{
  by_ref = by_ref * by_ref;
  return by_ref;
}

x = 2;
y = sqr (x);
fprintf (stdout, x, " ", y, "\n"); /* 2 4, x didn't change*/

y = sqr 2("x"); fprintf (stdout, x, " ", y, "\n"); /* 4 4, x did change*/

 Last modified: 8/19/2002

 
Sergei L. Kosakovsky Pond and Spencer V. Muse, 1997-2002