To ; or not to ; that is the question! Simple answer is, if in doubt, do it. Let me explain. Semicolon is used in SQF scripts to tell the engine where one command ends and another starts. If you miss ; where it is required the script will abort and write an error message to .rpt file, telling you that you missed a semicolon.
You may omit the last semicolon before closing code bracket } since it is the end of the code scope. You can also omit semicolon on the very last line of the code for the same reason, end of file is the end of the code scope. Really it wouldn’t hurt if you put extra semicolon even if you don’t have to.
But be careful when passing arguments, extra semicolon could be a code breaker.
Same goes for (). Parentheses are used to tell the engine the order in which it has to process expression. The most inner expression is processed first, then its parent, then grandparent and so on (((1) 2) 3). For example, you want to select array within array. (EDIT: With select statement you can omit () in some simple cases: _eight = _array select 3 select 4 select 0; works just fine.)
You can achieve the same result as above by using intermediate variables:
Use parentheses generously to logically separate ArmA commands or you might face some unpredictable results. Compare the following expressions.
Although the first expression does not result in error, the actual output result is a few random numbers and is not what is expected. What expected is a list of objects within 50 metres of player position and second expression does exactly that, thanks to parentheses.
Ah well, might as well mention how to call a function in the same post. But first you have to make one and it is pretty straight forward as function is nothing more but a variable with a code assigned to it. Variable could be either private or public. To call a function you can use call command (more about other commands later).
Functions can take arguments as well as return results. To pass arguments to a function using call command, precede it with a variable containing arguments. If you have multiple arguments you can pass array. Passed arguments will get assigned to special variable _this inside the function. To pass the result back from function you will need to end the code with a single variable or unassigned expression.
Note the use of parentheses in second example, it simply will not work without. This is it for the basics, hope it helps.