X11Basic icon indicating copy to clipboard operation
X11Basic copied to clipboard

[feature request] expressions in select case

Open amaendle opened this issue 4 years ago • 3 comments

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?

amaendle avatar Oct 22 '20 22:10 amaendle

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?

kollokollo avatar Dec 24 '20 13:12 kollokollo

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

kollokollo avatar Dec 24 '20 14:12 kollokollo

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.

amaendle avatar Feb 18 '22 22:02 amaendle

Well, If this is not an urgend issue anymore I will not implement it and close.

kollokollo avatar Aug 18 '22 09:08 kollokollo