Difference between revisions of "Semicolon"

From NWN Lexicon
Jump to: navigation, search
Line 8: Line 8:
  
 
<nwscript>
 
<nwscript>
+
 
int bCondition = TRUE; // single line statement
+
int bCondition = TRUE; // single line statement
if (bCondition)
+
if (bCondition)
      PrintString("bCondition is TRUE."); // multiline statement
+
    PrintString("bCondition is TRUE."); // multiline statement
// below should be handled with "else if" instead
+
// below should be handled with "else if" instead
if (!bCondition)
+
if (!bCondition)
{
+
{
      // multiple statements in a code block
+
    // multiple statements in a code block
      PrintString("bCondition is FALSE.");
+
    PrintString("bCondition is FALSE.");
      bCondition = TRUE;
+
    bCondition = TRUE;
}
+
}
 
</nwscript>
 
</nwscript>
  

Revision as of 01:45, 26 August 2012

Semicolon

Semicolons are used to end a logical line in a statement. A logical line is called logical because it can span across multiple real lines to increase readability.


The start and end of code block statements, with the exception of code block delimiter .

int bCondition = TRUE; // single line statement
if (bCondition)
     PrintString("bCondition is TRUE."); // multiline statement
// below should be handled with "else if" instead
if (!bCondition)
{
     // multiple statements in a code block
     PrintString("bCondition is FALSE.");
     bCondition = TRUE;
}




 author: Charles Feduke, editor: Jasperre, additional contributor(s): Ryan Hunt, Frank Succardi, Heikki