Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Switch..case statement???

1 replies · 1,088 views · Started 05 June 2007

from what i understand zscript is basically the C language with built in functions, so why does it not seem to understand a switch statement?

example of code i wrote:

 
switch (best_dir)
{
case 1:
for (int n = 1 ; n<16 ; n+=4)
{
this_ffc->y-=4
Waitframe();
}
break;
case 2:
for (int n = 1 ; n<16 ; n+=4)
{
this_ffc->x-=4
Waitframe();
}
break;
case 3:
for (int n = 1 ; n<16 ; n+=4)
{
this_ffc->y+=4
Waitframe();
}
break;
case 4:
for (int n = 1 ; n<16 ; n+=4)
{
this_ffc->x+=4
Waitframe();
}
break;
}


Am i useing this wrong or is it not possible to use switch
(or is it select..case, i always get confused when useing different languages 🙄 )

Because I haven't implemented it yet.

Switch is very nasty to implement in a compiler, as it's complex both in terms of syntax and semantics, and so didn't make ZScript's first cut. Which is not to say I won't get around to it in the future.