Limit to SPIN elseif construct
ags
Posts: 386
Merry Christmas.
I probably need to refactor my implementation of a web server. Until then, I'm battling an issue with a limitation to "elseif" in SPIN. Seems that there is a limit to 16 consecutive "elseif" statements in a single conditional clause. (sounds like spin only reserves 4 bits?). I am comparing a string against a list of possible values, so I don't think there is a way for me to replace this with a "case" statement - and that may have the same limit. I looked and didn't see any mention of limit in the Propeller documentation. Where, if anywhere, does documentation of this limit (for "elseif" as well as "case") exist?
How can I get around this? Thanks.
I probably need to refactor my implementation of a web server. Until then, I'm battling an issue with a limitation to "elseif" in SPIN. Seems that there is a limit to 16 consecutive "elseif" statements in a single conditional clause. (sounds like spin only reserves 4 bits?). I am comparing a string against a list of possible values, so I don't think there is a way for me to replace this with a "case" statement - and that may have the same limit. I looked and didn't see any mention of limit in the Propeller documentation. Where, if anywhere, does documentation of this limit (for "elseif" as well as "case") exist?
How can I get around this? Thanks.
Comments
How about:
1) Define the strings you are testing against, the possible values, in a DAT section.
2) Have a array of pointers to those strings, also in the DAT section.
3) Create a loop in Spin that tests the input sting against the strings in DAT and exits when it finds a match. Producing a number indicating the match.
4) Do a "case" on that loops output value. I forget what the limit on "case" is but I thought it was a lot more than 16.
5) You can always split the value you are performing a case on into two parts and then use nested "case" to get what you want.
Merry Christmas.
Although, I like the cleaner loop construct suggested by Heater.