11.11.2009, 15:30
It's :
Not :
The return only exits the function (end the routine), it's the scope which is at fault here.
Edit:
A little explination I thought I'd add.
These two here are valid scopes:
As the compiler has just ran a check (processed a statement) it is expecting to make an instruction but it will only process the next instruction or better said it only links the next instruction (line of code) with that statement unless told otherwise, we use braces (brackets, whatever they are bloody called hehe) to control our scope as the compiler will read from one to the next, it's like start to end, from '{' to '}'.
Although I would stick to the traditional method which runs all instructions inside the scope bounds (the { /*this is my scope*/ }) it is possible to script without them but you have to understand how it works.
pawn Код:
if ( blah )
{
//do something here
return;
}
pawn Код:
if ( blah )
// do something here
{
return;
}
Edit:
A little explination I thought I'd add.
These two here are valid scopes:
pawn Код:
//one
if ( blah ) //do something here (single line, single instruction)
//two
if ( blah )
// do something here (single statement, single instruction)
Although I would stick to the traditional method which runs all instructions inside the scope bounds (the { /*this is my scope*/ }) it is possible to script without them but you have to understand how it works.
pawn Код:
{ //open first scope
{ //open second scope
} //close second scope
} //close first scope