Difference between revisions of "Call"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
m
imported>Bale
(http://kolmafia.us/showthread.php?1349-Can-I-sort-an-array-Can-I-call-a-method-if-given-a-reference&p=9021&viewfull=1#post9021)
Line 16: Line 16:
 
print( "c = " + c );
 
print( "c = " + c );
  
a = "hello world";
+
a = "print";
  
 
call a( "print 1" );
 
call a( "print 1" );
Line 24: Line 24:
 
will output the following to the CLI:
 
will output the following to the CLI:
 
  c = 5.0
 
  c = 5.0
  hello world
+
  print 1
 
  done
 
  done
 
{{Format}}
 
{{Format}}
  
 
[[Category:Scripting]]
 
[[Category:Scripting]]

Revision as of 21:55, 17 September 2014

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 = "print";

call a( "print 1" );

print( "done" );

will output the following to the CLI:

c = 5.0
print 1
done

Formatting Needed