RosettaCodeData/Task/Call-a-function/Cubescript/call-a-function.cube

17 lines
610 B
Plaintext

// No arguments
myfunction
// All functions can take a variable number of arguments.
// These can be accessed from within the function with the aliases:
// $arg1, $arg2, $arg3... $numargs tells the amount of args passed.
myfunction word "text string" 1 3.14
// Getting a function's return value
retval = (myfunction)
// Trying to do a variable lookup on a builtin function will return an empty
// string. This can be used to distinguish builtin functions from user-defined
// ones.
if (strcmp $echo "") [echo builtin function] // true
if (strcmp $myfunction "") [echo builtin function] // false