AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can i add a case into other case? and how? (https://forums.alliedmods.net/showthread.php?t=89465)

AlejandroSk 04-06-2009 18:30

Can i add a case into other case? and how?
 
Title say all
i want to know if its possible something like this:


PHP Code:


switch(key)
{
         case 
1:
                   {
                            switch(
key2)
                                {
                                            case 
1//bla
                                            
case 2// Bla 2
                                 
}
                   }



Arkshine 04-06-2009 18:35

Re: Can i add a case into other case? and how?
 
Sure.

Even if your indentation is bad, the syntax is right.

AlejandroSk 04-06-2009 18:35

Re: Can i add a case into other case? and how?
 
whit the same index of the main switch?

Arkshine 04-06-2009 18:39

Re: Can i add a case into other case? and how?
 
I don't understand what you mean.

AlejandroSk 04-06-2009 20:07

Re: Can i add a case into other case? and how?
 
PHP Code:

switch(key

         case 
1
                   { 
                            switch(
key2) .... 

as you can see, i need 2 switchs..
i need to use the same index (key) for both?

minimiller 04-06-2009 20:15

Re: Can i add a case into other case? and how?
 
yea u can, but i dont see why you would want to :?

fysiks 04-07-2009 08:08

Re: Can i add a case into other case? and how?
 
Quote:

Originally Posted by AlejandroSk (Post 799391)
PHP Code:

switch(key

         case 
1
                   { 
                            switch(
key2) .... 

as you can see, i need 2 switchs..
i need to use the same index (key) for both?

Not to be rude but you have two different "key" values, "key" and "key2".

If key == key2 then the second switch will only ever exucute the same case.

AlejandroSk 04-07-2009 15:09

Re: Can i add a case into other case? and how?
 
Can you give me a example?

fysiks 04-07-2009 16:28

Re: Can i add a case into other case? and how?
 
I'm saying if key = key2 then only use one switch. If key != key2 then you can use nested switches, I'm sure it will be rare to actually "need" nested switches.

What are you trying to do?

TitANious 04-07-2009 16:45

Re: Can i add a case into other case? and how?
 
I think you have to do:
PHP Code:

    switch(key
    { 
        case 
1
        { 
                              switch(
key2)
                         {
                           case 
1:
                           }
                           case 
2:
        } 
        case 
2
        {
 
        } 
        case 
3
        { 

Or am i wrong?


All times are GMT -4. The time now is 02:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.