X11Basic
X11Basic copied to clipboard
[feature request] expressions in select case
In GFA basic you can also do:
SELECT i CASE 1 PRINT 1 CASE 2 TO 30 PRINT "its in 2...30" ENDSELECT
It would be nice to have this in X11-basic. Separating by comma is not feasible for large number ranges. Of course I can use an if-condition instead...
What do you think about it? Is almost-compatibility with GFA-basic still a goal in this project?
Almost-compatibility with GFA-basic is indeed still a goal. Yes, it would be nice if one could definde a range in the case statements. However the ... TO ... construct is very difficult to implement and also with FOR this construct causes a lot of overhead in the parser. TO is not an operator (like AND OR NOT) in BASIC. X11Basic uses lists (comma seperated) instaed. So the TO construct needs an individual treatment (currently only used for FOR). Hm. I would need a good idea how to efficiently implement this. Do you have any suggestions?
Have you tried CASE 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
i am not sure if it works but this is what I woud concider logical. To specify ranges the ":" operator is used (at least with the array indicies). But I know that even there things are not so straigt at the moment. See Issue #12
Have you tried CASE 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
Yes, that works.
Well, If this is not an urgend issue anymore I will not implement it and close.