Needed: 'case'- or 'switch'-style statements
Displaying 1-13 of 13 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
rune_darkfire

Hello community...

I have just recently looked through Verge and am trying to learn it to help out with some projects.

One thing I see sorely lacking that would help almost every demo I've seen *SO* much is the inclusion of Java-like or C++-like switch or case statements.

So instead of having ridiculous if-blocks, for example:

int amount = cost;

if(amount = a) {
b;
} else if(amount = c) {
d;
} else if(amonut = e) {
f;
} etc etc etc...

You can code the following:

switch (amount) {
a: b;
c: d;
e: f;
etc etc etc...
}

So much cleaner. If there is already Verge functionality similar to this that I am not aware of, please someone let know. Also can someone tell me how to tab text on this message board, so my pseudocode above is actually readable? Thanks for reading!

Posted on 2004-05-06 17:58:23

Rysen

No need to worry, switch statements are in, and work very much like they do in c/c++. As far as I know the only difference is that there is no "break;" or default case in verge's switches.

Posted on 2004-05-06 18:57:07 (last edited on 2004-05-06 18:58:32)

mcgrue


switch (amount) {
case a: b;
case c: d;
case e: f;
}


Is what you want. There are no breaks or default like Rysen said, so you can't have any "designed bleed-thru" action, and it only works for the specified cases.

Posted on 2004-05-06 20:35:51

blues_zodiakos

Switch/case statments are used quite a bit in the "Timeless" demo available in the Verge 3 files section under demos. That was one of the first available demos, and made by vecna no less. :D

Posted on 2004-05-06 21:26:39

mcgrue

Oh! I should link Timeless in the sidebar! :o

Posted on 2004-05-06 21:53:26

sabernet


these switches intrigue me:)

can you use operations like +, -, , >=, = 1: +1
blah

Posted on 2004-05-11 22:01:28

sabernet

these switches intrigue me:)

can you use operations like +, -, =, =


AAARGH

that's isn't what I posted at all!


I meant:

switch(variablex) {
a>=2: +1;
a>2: -1;
}

Posted on 2004-05-11 22:01:47 (last edited on 2004-05-11 22:05:43)

sabernet

or am I just misundertanding these switches?

Posted on 2004-05-11 22:05:19

Mythril

Quote:Originally posted by sabernet

or am I just misundertanding these switches?


switch (variable) {
case 0: Print( "Your variable is zero!" );
case 1: Print( "Your variable is one!" );
}

You can only check one and one variable at a time, no greater-than or less-than comparing. Unless Verge3 completely changed the way switch cases works.

(Though, they did change the way it work by not having break; Oh well.)
PS: No code tag? I tried <code> and <vc>, both were removed.

Posted on 2004-05-11 23:20:43

mcgrue

The bottommost sticky on this forum....

Edit: I might as well make an alias, tho...

Posted on 2004-05-12 03:10:34 (last edited on 2004-05-12 03:11:02)

RageCage

GRUE 0WnD J0!

Posted on 2004-05-12 03:12:19

Mythril

Quote:Originally posted by mcgrue

The bottommost sticky on this forum....

Edit: I might as well make an alias, tho...

OH LO, IM IGNORANT
I SUX0RS

Posted on 2004-05-12 12:17:17

Troupe

You both fail life.

Posted on 2004-05-12 15:14:36


Displaying 1-13 of 13 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.