Raised This Month: $ Target: $400
 0% 

Can i add a case into other case? and how?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 04-06-2009 , 18:30   Can i add a case into other case? and how?
Reply With Quote #1

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
                                 
}
                   }

AlejandroSk is offline
Send a message via MSN to AlejandroSk
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-06-2009 , 18:35   Re: Can i add a case into other case? and how?
Reply With Quote #2

Sure.

Even if your indentation is bad, the syntax is right.
Arkshine is offline
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 04-06-2009 , 18:35   Re: Can i add a case into other case? and how?
Reply With Quote #3

whit the same index of the main switch?
AlejandroSk is offline
Send a message via MSN to AlejandroSk
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-06-2009 , 18:39   Re: Can i add a case into other case? and how?
Reply With Quote #4

I don't understand what you mean.
Arkshine is offline
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 04-06-2009 , 20:07   Re: Can i add a case into other case? and how?
Reply With Quote #5

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?
AlejandroSk is offline
Send a message via MSN to AlejandroSk
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-07-2009 , 08:08   Re: Can i add a case into other case? and how?
Reply With Quote #6

Quote:
Originally Posted by AlejandroSk View Post
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.
__________________
fysiks is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 04-06-2009 , 20:15   Re: Can i add a case into other case? and how?
Reply With Quote #7

yea u can, but i dont see why you would want to
__________________
minimiller is offline
Send a message via MSN to minimiller
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 04-07-2009 , 15:09   Re: Can i add a case into other case? and how?
Reply With Quote #8

Can you give me a example?
AlejandroSk is offline
Send a message via MSN to AlejandroSk
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-07-2009 , 16:28   Re: Can i add a case into other case? and how?
Reply With Quote #9

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?
__________________
fysiks is offline
TitANious
Veteran Member
Join Date: Feb 2009
Location: Denmark
Old 04-07-2009 , 16:45   Re: Can i add a case into other case? and how?
Reply With Quote #10

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?
__________________
I dislike this.

"A sneeze never comes alone!" <-- Important to remember.
TitANious is offline
Send a message via MSN to TitANious
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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