A function (or command) relates each of its inputs to exactly one output. In other words, a Function takes parameters (input) and give you a single result (output). Lets look at a function;
object GetObjectByTag(string sTag, int iNth = 0);
This function gives you the object anywhere in you module that has a matching tag defined by nString. It has 2 parameters (input) that must be provided to the function, a string and a int data type. But what does it all mean;
object - Is the data type (output of the function) returned to the script.
GetObjectByTag - is the Function Name.
( - Parameter List start. This is required by all functions. This more or less separates the Function name, from the function parameters.
string sTag - this parameter requires a string data type as it's input, in this case the TAG of the object. A string variable can be used here.
, - (comma) Seperator for the next parameter.
int iNth = 0 - This parameter requires a int data type as it's input, in this case a number from 0 to whatever. Note that this parameter has a "=0" this is a "Default" parameter and is not required by the scripter - it defaults to 0 unless otherwise specified. a int variable can be used here.
) - Perameter List end, this is also required by all functions.
; - End of line. All functions require a end of line.
As an example;
object oGuard = GetObjectByTag("GUARD");
Would return the object with the tag "GUARD" and store that object in the variable oGuard. Note that the iNth parameter was not specified, so the function would use the default of 0 - which would be the first object in the object list with that tag.
If a function has more than one default parameters, and we want to change the second default but not the first default, then we must specify the first before we can change the second. For example, look at this function;
void ActionCastSpellAtLocation(int nSpell, location lTargetLocation, int nMetaMagic = METAMAGIC_ANY, int bCheat = FALSE, int nProjectilePathType = PROJECTILE_PATH_TYPE_DEFAULT, int bInstantSpell = FALSE );
As you can see, there are a lot of default parameters and the ones that we must specify are nSpell and lTargetLocation. If we wanted to change the last parameter, bInstantSpell, we can't just skip the other defaults. Instead we must enter them in as well using the defaults specified in the function definition above.