Author Topic: Proper syntax for switch$  (Read 2554 times)

0 Members and 1 Guest are viewing this topic.

DeathAdder

  • Orc Thrasher
  • ***
  • Posts: 137
  • Reputation: +0/-0
    • http://www.los.planetubh.com
Proper syntax for switch$
« on: May 28, 2005 01:56 am CDT »
I can't seem to find any info on this on the net...

Whats the proper syntax for using a switch$?
« Last Edit: December 31, 1969 06:00 pm CST by DeathAdder »
<img src="http://www.pcrpg.org/pics/hosted/dadder.jpg">

GStricto

  • Elvin Legion
  • *****
  • Posts: 463
  • Reputation: +0/-0
(No subject)
« Reply #1 on: May 28, 2005 02:03 pm CDT »
Code: [Select]
switch(int) {
   case int1:
      code;
   case int2:
      code;
      break;
   default:
      break;
}

The switch only takes int variables that I am aware of.  If you do not use break at the end of the case, it will cascade through the rest of the cases after the first true case found.  Default is what will happen if none of the cases evaluate to be true.  If you already knew this and are asking in terms of Tribes (which seems likely), then I will tell you that I have never seen switch used or been able to make it work.  You are stuck with lines of if(num==1) etc.
« Last Edit: December 31, 1969 06:00 pm CST by GStricto »

Quote from: "Artorius"
Gnight.... Gstricto is obviously picking on you because he is a dirty racist.
So ironic that a heart made by man, when broken is easily fixed.   But a human hurt can last a lifetime.

DeathAdder

  • Orc Thrasher
  • ***
  • Posts: 137
  • Reputation: +0/-0
    • http://www.los.planetubh.com
(No subject)
« Reply #2 on: June 4, 2005 12:26 am CDT »
Hey thanx man, Yea i've used a switch before in T1 codig i'm pretty sure... Might have been T2, meh, I'll make it work ^_^ Thanx for the info!!
« Last Edit: December 31, 1969 06:00 pm CST by DeathAdder »
<img src="http://www.pcrpg.org/pics/hosted/dadder.jpg">