The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
switch statements
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#1
switch statements

I just read a thread here. I decided to make a new thread because his question has already been answered.

basically, ive never used switch before, because ive never known how to use it, until now. But apparantly 'case' only works with integers, so i couldnt do for example: case asEntity:

but my question is: could i do this with a switch command
void RandomFunction()
{
AddTimer("1" , 1.0f , "Timer");
AddTimer("2" , 2.0f , "Timer");
AddTimer("3" , 3.0f , "Timer");
AddTimer("4" , 4.0f , "Timer");
}
void Timer(string &in asTimer)
{
switch(asTimer){
case 1:
// Do Stuff
break;
case 2:
// Do More Stuff
break;
case 3:
// Do Other Stuff
break;
case 4:
// Do Funky Stuff
break;
}
}
Or would i have to declare asTimer as an integer?
it would make timers much less boring - thanks!

(This post was last modified: 07-20-2011, 08:57 PM by DRedshot.)
07-20-2011, 08:00 PM
Find


Messages In This Thread
switch statements - by DRedshot - 07-20-2011, 08:00 PM
RE: switch statements - by Khyrpa - 07-20-2011, 08:24 PM
RE: switch statements - by Kyle - 07-20-2011, 08:31 PM
RE: switch statements - by Khyrpa - 07-20-2011, 08:38 PM
RE: switch statements - by DRedshot - 07-20-2011, 08:42 PM
RE: switch statements - by palistov - 07-20-2011, 08:46 PM
RE: switch statements - by DRedshot - 07-20-2011, 08:49 PM
RE: switch statements - by palistov - 07-22-2011, 10:34 AM



Users browsing this thread: 1 Guest(s)