Difference between revisions of "Call"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
imported>Bale
m (consistency)
Line 1: Line 1:
 +
{{DISPLAYTITLE:call}}
 
Syntax: call [''type''] <identifier>( param, ... );
 
Syntax: call [''type''] <identifier>( param, ... );
 
: ''type'' is an optional parameter which must match the return value of the function. If not specified, ''type'' defaults to void.
 
: ''type'' is an optional parameter which must match the return value of the function. If not specified, ''type'' defaults to void.

Revision as of 23:29, 1 July 2010

Syntax: call [type] <identifier>( param, ... );

type is an optional parameter which must match the return value of the function. If not specified, type defaults to void.

For instance:

int foo( int a, int b )
{
  return a + b;
}

String a = "foo";

float c = call float a( 2, 3 );

print( "c = " + c );

a = "hello world";

call a( "print 1" );

print( "done" );

will output the following to the CLI:

c = 5.0
hello world
done

Formatting Needed