Function

A Function is a concept used in programming. All programming languages support functions in some way. A function takes a variable number of arguments as input and returns a certain value (usually one or none). Simply said: a function is a piece of code that performs a specific task. A function consists of one or more statements that form the function code. A function must be called before it is executed. A function call is generally done this way: function_name(argument0,argument1,...,argumentn);
 * function_name is the name of the function
 * the 's indicate that this is a function (it would be a variable, object id,... otherwise)
 * argument0 - argumentn are the arguments of the function. They are parameters that are passed to the function. These change the behaviour and output of the function.

Functions in Game Maker
When the function is called in a piece of code, the value returned by the function is used in that code. A simple example of this in Game Maker: (string((1,2,3)); is the same as show_message(string(3));

In GML, the format is like shown below.



The first part contains the definition of the function, after it are the functions. may be used as functions. With Game Maker 7's extension mechanism, you may use scripts and functions in dlls as functions as well. When using functions from dlls written in programming languages, one should be aware that GM supports only two data types: string and real. A real is a double in other programming languages. A string in GM is an array of characters (char variables).