Case limit of 64 statements?
JBWolf
Posts: 405
Hello,
I am making a large 'shuffle mode' list for running led's.
This is being approached by generating a random number and then using a 'case' statement.
Problem is, I just started on #65 and get error "Case limit of 64 statements exceeded".
Any way to increase the case limit ? I would like to have 75.
Thanks
I am making a large 'shuffle mode' list for running led's.
This is being approached by generating a random number and then using a 'case' statement.
Problem is, I just started on #65 and get error "Case limit of 64 statements exceeded".
Any way to increase the case limit ? I would like to have 75.
Thanks
Comments
-Phil
wasnt sure if there was some way to increase the cases limit though, just a spin limitation then?
I think it's what Phil means by nesting.
Yes, it's a limit in Spin.
It seems like the above technique is a relatively simple work around.
im just going to do as phil mentioned... which is exactly what you are giving an example of duane.
I can group them into general categories anyways.
was just hoping there would be some buffer i could increase for case.
you know, like : CON Case[75]
A kludge is a hack which is ugly, but works.
If you happened to have, say, 128 cases. Numbered nicely from 0 to 127. You could arrange make an "if" branch from the first bit of the case. Then "if" branches on the second bit. And so on. In 7 tests you have arrived at your case.
Kind of verbose, but must be quicker on average.
or did you mean something more like a single case statement with 4 possible results, with each of those 4 results calling a method which has another possible 20 cases each..... cutting down like that (that approach would reduce comparison count by 60).
I could actually redo the case structure with 'if' statements, but I think I like the idea of categorizing the many methods into types/genres and nesting cases
For example, say you stayed with CASE but in my example of 100 you go to the third root in stead of square; you need 4 or 5 cases per block then, but your worst case time is 15 compares -- not much better than 20 with the square root, and with more code and setup cost for the third level.
In other languages it's not so clear. Perhaps each case is no longer a constant but an expression that needs to be evaluated. At that point a bunch of chained "if..elseif" is about the same performance wise.
Personally I would do whatever reads most nicely in the source code. Leave any performance tweaking until you know if you need it or not.