switch - case works?

Discuss PocketC for Palm OS (including Desktop Edition)

Postby merlinman on Wed Mar 07, 2001 9:36 am

I started using pocketc recently my first poject being yet another "snake" clone. I read the language reference and the base pocketc language is very much like c itself (which I know very well).

I tried to check which hardkey the user had pressed in my main gaming loop using the standard switch-case statement. It doesn't work. I created a test program with the lowest possible denominators nessesary to make a switch-case statement and it still didn't compile. Why not? The PocketC langauge reference makes mention of it.

If it's not inplemented, why isn't it: it's one of the most usefull built in functions although admittedly it's just a "convenience" function and not vital.

Posts: 4
Joined: Mon Feb 26, 2001 1:51 pm
Location: United Kingdom

Postby Vilmos on Wed Mar 07, 2001 12:29 pm

Sorry it is back to IF, ELSE, rinse, repeat.

Posts: 174
Joined: Tue Dec 05, 2000 6:13 pm
Location: Canada

Postby jstadolnik on Wed Mar 07, 2001 2:55 pm

In C, switch-case constructs usually get implemented as if-else-if structures anyhow.

There are some special optimized case-switch cases, but you can pretty much fake them out in PocketC. Check out the optimization post I made in the Knowledge Base section. Specifically look at the "translate", "function select", and "block select" cases. They are all faster than traditional if-else constructs.

Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 6 guests