Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Nesting Statement? (https://forums.graalonline.com/forums/showthread.php?t=76241)

PrinceOfKenshin 08-12-2007 08:04 PM

Nesting Statement?
 
Does the elseif statement work as a nesting statement? Here is an example it is nothing just showing kinda what i mean.

PHP Code:

Function onCreated(){
if (
rawr ==rawr){
blah;
} elseif (
rawr == 2){
woot;
} elseif (
rawr == 5){
woot;


The way it works is which ever if statement is true it will run first without stopping to look at the others

Inverness 08-12-2007 08:52 PM

The answer is yes.

if can be used after else but they're not joined like you're doing.
PHP Code:

function onPlayerChats() {
  if (
player.chat == "/reconnect") {
    
System.reconnect();
    
player.chat "";
  }
  else if (
player.chat == "/disconnect") {
    
System.disconnect();
    
player.chat "";
  }
  else {
    
player.chat "ZOMG TEXT";
  }



PrinceOfKenshin 08-12-2007 10:24 PM

Thanks i wasn't sure if it was true. Because i know in Visual Basics it works like that and makes things easier = )

zokemon 08-13-2007 06:16 PM

Actually nesting is like this:
PHP Code:

if (blah == blah) {
  if (
foo == bar) {
    
doFooBar();
  }
  else if (
== b) {
    
doFoolessBar();
  }
}
else {
  
doOtherthings();


Notice the
PHP Code:

  if (foo == bar) {
    
doFooBar();
  }
  else if (
== b) {
    
doFoolessBar();
  } 

is nested inside the
PHP Code:

if (blah == blah) { 

?


All times are GMT +2. The time now is 10:41 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.