Author Topic: Multiple responses to cases?  (Read 623 times)

So I'm wondering if there is a way to use
Code: [Select]
  switch$(lalala)
  {
      case "1":
      %Declartion = randomcrap:
      commandToServer('messagesent',"alalala");
    }

You know?
So I can declare variables in the case, AND send a message with that variable in it


Yes, you can do that.
Is that the correct way of writing it?

If so I'm stupid and that isn't the syntax error I'm looking for :/

Is that the correct way of writing it?

If so I'm stupid and that isn't the syntax error I'm looking for :/
I suppose but "lalala" is not "1" and since you have no default it won't do anything, but there's nothing syntactically wrong with it. Though, it's proper format to indent after the case declaration.

I suppose but "lalala" is not "1" and since you have no default it won't do anything, but there's nothing syntactically wrong with it. Though, it's proper format to indent after the case declaration.

Your wrong.

having the : at the end of two lines with a third line being ; is syntactically wrong.

Such as

Code: [Select]
  switch$(%msg)
  {
     case "hi":
     %hithere = true:
     commandToServer('messagesent',"hi there " @ %hithere);
  }

That is not correct.

Your wrong.

having the : at the end of two lines with a third line being ; is syntactically wrong.

Such as

Code: [Select]
  switch$(%msg)
  {
     case "hi":
     %hithere = true:
     commandToServer('messagesent',"hi there " @ %hithere);
  }

That is not correct.
That was probably a typo and is really unnoticeable.

Your wrong.

So this topic is a trick question? If you already know the answer, what's the point of this topic?

So this topic is a trick question? If you already know the answer, what's the point of this topic?
lol, didn't notice he made the topic

So this topic is a trick question? If you already know the answer, what's the point of this topic?

No, I didn't know the answer when I first made it, then I learned it, now I want to know if there is a way to get it to work

Okay, sorry, I missed the like two pixel difference from : and ;. Forgive me for my horrible injustice to humankind.

Your wrong.

You're wrong.

Having the word spelled as your is grammatically wrong.

Such as
Code: [Select]
Your a friend

That is not correct.
« Last Edit: September 01, 2012, 08:25:33 PM by TripNick »

If you plan on using that for a massive number of cases for, say, a chatbot, then you're barking up the wrong tree. Cases are wonderful for menus, but they're really not as good as an if/elif/else tree for conditionals, or arrays for adaptive chatbots.

There's also nothing a case can do that an if statement can't, it's just that they're easier to read.