• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Is there an "In Case of" syntax in JASS?

Status
Not open for further replies.
Level 17
Joined
Apr 13, 2008
Messages
1,597
Hi, I was wondering if there is an In Case of syntax in JASS.
In other programming languages (delphi, for example) this serves as many ifs, for example:

In Case of YourInteger
1: yourcodeshere
2: here too please

Would have the same effect as:

If YourInteger == 1 then
yourcodeshere
else
If Youriteger == 2 then
your codes here too again please
endif
endif

Just the in case of syntax is much shorter, and much easier on the eye.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
JASS:
if YourInteger == 1 then
yourcodeshere
else
if Youriteger == 2 then
your codes here too again please
endif
endif

JASS:
if YourInteger == 1 then
yourcodeshere
elseif Youriteger == 2 then
your codes here too again please
endif

if != If :cwink:
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Last time I checked, it was (in C)

Code:
switch (YourInteger) {
    case 1:
        blahblah
        break;
    case 2:
        blahblah
        break;
    case 3:
        blahblah
        break;
    ...
}

Or replacing switch with case and case with when, for Ruby. (And also, block syntax instead of brace syntax).

Never seen it like that, though.

While it might be sort of nice, it is a kind of feature which is pretty much useless in terms of application in Wc3 other than pretty code.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
hmm lets see

if a == 1 then
actions
elseif a == 2 then
actions
endif

switch (a)
{
case 1;
actions;
break;
case 2;
actions;
break;
}

dont think there is more to say
 
Status
Not open for further replies.
Top