ZNorQ 0 Posted August 28, 2007 I'm trying to use 'or' in a 'case' expression, but I can't quite make it work.. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">switch _mycounter do { case 1 or 4: {-do something here-;}; case 2 or 3: {-do something else here-;}; }; Am I doing something wrong, or isn't this possible? ZNorQ PS! Forget about the 'and' mentioned in the heading - that's a typo! Share this post Link to post Share on other sites
UNN 0 Posted August 29, 2007 I don't think you can use the Switch statement that way. At least in Arma, other languages used to use: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">case [1,4]:.... Probably the best you can do is pre-compile some common code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_14Code=Compile "Hint ""1 and 4 where called"""; _23Code=Compile "Hint ""2 and 3 where called"""; switch _mycounter do { Â Â Â Â case 1: {Call _14Code}; Â Â Â Â case 4: {Call _14Code}; Â Â Â Â case 2: {Call _23Code}; Â Â Â Â case 3: {Call _23Code}; }; ? Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted August 29, 2007 Or do some nasty if statement nesting, since arma dosen't have an elseif equivalent. Share this post Link to post Share on other sites
crashdome 3 Posted August 29, 2007 is this possible?: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> switch (value) { case 1: case 2: { }; }; Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted August 29, 2007 Good question, but I doubt it. Usually, languages where you can do that sort of thing require an exit command. Share this post Link to post Share on other sites
crashdome 3 Posted August 29, 2007 Yeah..it didn't work. Share this post Link to post Share on other sites
Synide 0 Posted August 29, 2007 if your variable is always a number, maybe try... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> for "_mycounter" from 0 to 3 do {}; for "_mycounter" from 4 to 4 do {}; for "_mycounter" from 5 to 99 do {}; maybe...? Share this post Link to post Share on other sites
ZNorQ 0 Posted August 29, 2007 Probably the best you can do is pre-compile some common code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_14Code=Compile "Hint ""1 and 4 where called"""; _23Code=Compile "Hint ""2 and 3 where called"""; switch _mycounter do { case 1: {Call _14Code}; case 4: {Call _14Code}; case 2: {Call _23Code}; case 3: {Call _23Code}; }; Yeah, that seems like a good idea, I'll implemend that concept. Good question, but I doubt it. Usually, languages where you can do that sort of thing require an exit command. Isn't it 'Break' that is used in C/C++?; <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">switch (evaluation) { case 1: -statements-; break; case 2: -more statements-; break; }; ZNorQ Share this post Link to post Share on other sites
ZNorQ 0 Posted August 29, 2007 if your variable is always a number, maybe try...<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> for "_mycounter" from 0 to 3 do {}; for "_mycounter" from 4 to 4 do {}; for "_mycounter" from 5 to 99 do {}; maybe...? It isn't, that was just an example. I'm creating a COOP game with 27 players, each with a specific weapons- and equipment configuration. There are 3 main teams with same setup ; Team Leader, Grenadier, Engineer, Medic, AT, MG. Then there are 2 smaller teams with 4 and 3 players with a very varied configuration, and last the 2 head officers who governs them all. I wanted to strip them of all standard weapons and equipment, and create my own standard. I'm using several 'switch-case' in forEach loops to do this.. I've created several arrays with the players ID, so it's objects I'm gonna use in the switch-case statements. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted August 29, 2007 Isn't it 'Break' that is used in C/C++?;<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">switch (evaluation) { case 1: -statements-; break; case 2: -more statements-; break; }; Yep, but there's more languages than just C . The wording will vary depending on what you're writing in. Considering that the people that know what I'm talking about will already know that, and the people that don't will largely not care, this info isn't really very useful to anybody around here. Share this post Link to post Share on other sites
ZNorQ 0 Posted August 29, 2007 Considering that the people that know what I'm talking about will already know that, and the people that don't will largely not care, this info isn't really very useful to anybody around here. Well, I was asking to expand my own knowledge, not everybody else. I was just trying to connect the dots as I'm not a C/C++ programmer at all. But I have done some programming in other languages, and the switch case / select case comes in many forms, as you yourself stated. ZNorQ Share this post Link to post Share on other sites