ianatha / bababasic

QuickBASIC 4.5 revival on Android
https://play.google.com/store/apps/details?id=io.atha.quickbasic
MIT License
94 stars 4 forks source link

code fails silently #3

Closed ianatha closed 10 months ago

ianatha commented 10 months ago

The following code fails silently:

10 REM 29-10-2023
20 DIM A(2)
30 A(0)=6:A(1)=A(0)+11
35 A(2)=A(1)+10
40 FOR I%=1 TO 2
50 PRINT "A(",I%,")=",A(I%)
60 NEXT I%

The output was:

REM --- OUTPUT START
REM --- OUTPUT END
ianatha commented 10 months ago

From logcat:

2023-10-29 22:22:20.910  5018-5018  INFO                    io.atha.quickbasic                   I  Running script: 10 REM 29-10-2023
                                                                                                    20 DIM A(2)
                                                                                                    30 A(0)=6:A(1)=A(0)+11
                                                                                                    35 A(2)=A(1)+10
                                                                                                    40 FOR I%=1 TO 2
                                                                                                    50 PRINT "A(",I%,")=",A(I%)
                                                                                                    60 NEXT I%
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W  org.puffinbasic.error.PuffinBasicRuntimeError: [ARRAY_INDEX_OUT_OF_BOUNDS] Index 2 is out of range for dimension[0]=2
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W  Line: [editor.bas:35(56-59)]
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W  A(2)
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W      at org.puffinbasic.runtime.PuffinBasicRuntime.run(PuffinBasicRuntime.java:117)
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W      at org.puffinbasic.PuffinBasicInterpreterMain.run(PuffinBasicInterpreterMain.java:195)
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W      at org.puffinbasic.PuffinBasicInterpreterMain.interpretAndRun(PuffinBasicInterpreterMain.java:176)
2023-10-29 22:22:21.210  5018-5018  System.err              io.atha.quickbasic                   W      at io.atha.quickbasic.MainActivity.onOptionsItemSelected(MainActivity.kt:595)
ianatha commented 10 months ago

The fix here is surfacing the PuffinBasicRuntimeError to the UI and displaying it.