Unreachable Codes ? Help me please!
#3

It's :

pawn Код:
if ( blah )
{
  //do something here
  return;
}
Not :

pawn Код:
if ( blah )
// do something here
{
  return;
}
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:

pawn Код:
//one
if ( blah ) //do something here (single line, single instruction)

//two
if ( blah )
  // do something here (single statement, single instruction)
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 Код:
{ //open first scope
  { //open second scope
  } //close second scope
} //close first scope
Reply


Messages In This Thread
Unreachable Codes ? Help me please! - by Lynax - 11.11.2009, 15:13
Re: Unreachable Codes ? Help me please! - by Striker_Moe - 11.11.2009, 15:22
Re: Unreachable Codes ? Help me please! - by Donny_k - 11.11.2009, 15:30
Re: Unreachable Codes ? Help me please! - by (.Aztec); - 11.11.2009, 15:30

Forum Jump:


Users browsing this thread: 1 Guest(s)