Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get ELSE IF working? #166

Open
dansanderson opened this issue Sep 10, 2024 · 2 comments
Open

Get ELSE IF working? #166

dansanderson opened this issue Sep 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dansanderson
Copy link
Collaborator

We have IF ... ELSE ... THEN, and we can make their statements into blocks with BEGIN ... BEND. However, for some reason ELSE comes with syntax restrictions that prevents ELSE IF from working properly. We should look into this.

10 X=1
20 IF X=0 THEN BEGIN
30   PRINT "ZERO"
40 BEND:ELSE IF X=1 THEN BEGIN
50   PRINT "ONE"
60 BEND:ELSE IF X=2 THEN BEGIN
70   PRINT "TWO"
80 BEND

This prints "ONE" and "TWO". It should only print "ONE".

The documentation for ELSE implies a bunch of odd syntax restrictions. If this is an inherent limitation, we should try to understand and document it better.

@dansanderson dansanderson added the enhancement New feature or request label Sep 10, 2024
@dansanderson
Copy link
Collaborator Author

@dansanderson
Copy link
Collaborator Author

Notably, it is expected behavior for BEND to demarcate a line, not a statement position. The rest of the line is ignored. It's counterintuitive but it has existed since BASIC 7.

Also notably, putting the ELSE IF clauses on separate lines from the BENDs doesn't fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant