Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
switch...case without break; #330463
06/27/10 19:03
06/27/10 19:03
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
I found out that in Lite-C, a switch...case without break doesn't behave like in standard C/C++. You can see that in this example:

Code:
#include <acknex.h>

var x;
void main ()
{
	while (1)
	{
		x = 0;
		switch(key_lastpressed)
		{
			case 16: // q
			x += 1;
			case 17: // w
			x +=10;
			case 18: case 19: // e or r
			x+=100;
			break;
		}
		wait(1);
	}
}

PANEL* debug_pan =
{
	digits(10,10,"%f",*,1,x);
	flags = SHOW;
}



In standard C/C++, the code shouldn't be stopped being executed if there is no break, but a new case. This means, when you press Q, x should be 111, but it's 1! It seems that Lite-C stops at the next case. But the E and R key behave the same, so it seems that it doesn't stop if there is no code inbetween. If this is some kind of "noob-protection", in case the user forgot a break; please make a define or something to turn it off.

Also, an empty switch...case, like this
Code:
switch(something)
{

}


returns a syntax error. It also returns a syntax error if there is only a default case. It would be nice if the compiler didn't give an error, because sometimes it can be useful to comment out some cases for debugging and it's just annoying if you comment out the last not commented case and you get an error and have to comment out the whole switch.


This happens with 7.85 and 8.00.6.

Re: switch...case without break; [Re: Lukas] #347835
11/19/10 20:57
11/19/10 20:57
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Bump.

Re: switch...case without break; [Re: Lukas] #348076
11/22/10 14:40
11/22/10 14:40
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Thanks, I have somehow overlooked this.

There seems indeed something to be non-standard with switch/case. We'll check if this can be corrected quickly, otherwise it will be documented.

Re: switch...case without break; [Re: jcl] #348082
11/22/10 15:54
11/22/10 15:54
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Ok, thanks.

Re: switch...case without break; [Re: Lukas] #350028
12/13/10 11:49
12/13/10 11:49
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Any news about this?

Re: switch...case without break; [Re: Lukas] #350034
12/13/10 12:23
12/13/10 12:23
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
We have a list of similar small issues for the compiler - they'll all be addressed when the next compiler improvement step is due.

Re: switch...case without break; [Re: jcl] #350041
12/13/10 13:31
12/13/10 13:31
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline OP

Programmer
Lukas  Offline OP

Programmer

Joined: May 2007
Posts: 2,043
Germany
Ok...


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1