![]() |
Forum Index : Microcontroller and PC projects : MMBASIC Error Line Number?
Author | Message | ||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 442 |
The following program ends with "Error in line 16: No DATA to read" Shouldn't the error be in line 5? 90 PRINT 95 PRINT "PRIME DEN";@(120);"LEAST EXP" 97 PRINT "##### ###";@(120);"##### ###" 99 PRINT 100 READ D 105 IF D=5 THEN 100 110 LET X=10 120 LET N=1 130 LET X=INT((X/D-INT(X/D))*D+.5) 140 IF X=1 THEN 180 150 LET X=X*10 160 LET N=N+1 170 GOTO 130 180 IF N=D-1 THEN PRINT D;" **";@(120);N 181 IF N<>D-1 THEN PRINT D;@(120);N 190 GOTO 100 260 DATA 3,5,7,11,13,17,19,23,29,31,37,41,43,47,53 270 DATA 59,61,67,71,73,79,87,89,97 280 END |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
I am assuming you are om a Maximite (the @ prints needed tweaking to run on my desk micromite with 5.0408) However... > RUN PRIME DENLEAST EXP ##### ######## ### 3 1 7 ** 6 11 2 13 6 17 ** 16 19 ** 18 23 ** 22 29 ** 28 31 15 37 3 41 5 43 21 47 ** 46 53 13 59 ** 58 61 ** 60 67 33 71 35 73 8 79 13 87 28 89 44 97 ** 96 [5] 100 Read D Error: No DATA to read > as expected I believe? so something peculiar to the flavour of MMBasic you have - more details? . Edited 2021-10-18 04:56 by CaptainBoing |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 442 |
I'm running MMBasic 5.07.01 on a 504MHz Colour Maximite 2 G2 |
||||
Tinine Guru ![]() Joined: 30/03/2016 Location: United KingdomPosts: 1646 |
IF X=1 THEN 180 This is legal? Damn, as huge fan and defender of the BASIC language, even I regard this listing as plain offensive ![]() |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
In many BASICs, no. (You'd have to use GOTO instead of, sometimes as well as, THEN.) In others, yes. Ugly. John Edited 2021-10-18 15:38 by JohnS |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2640 |
Early computers had no room for excess verbosity. If it works it's perfect. |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3292 |
It is legal in MMBasic although depreciated. Geoff Graham - http://geoffg.net |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Looking at MMB4L it shares the same issue (and 99% the same code), it looks like following a GOTO may not update "CurrentLinePtr", which thus still points at the line containing the GOTO statement - it's a bug, nothing that you are doing wrong. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Looks like a core MMBasic issue. One for you Geoff? 480MHz Colour Maximite 2 G2 MMBasic Version 5.07.02b1 Copyright 2011-2021 Geoff Graham Copyright 2016-2021 Peter Mather > list "goto_test.bas" 10 Print "Hello" 20 Goto 30 30 On Error Skip : Error "foo" : Print Mm.ErrMsg$ + " -- should say line 3" 40 Gosub 60 50 End 60 On Error Skip : Error "foo" : Print Mm.ErrMsg$ + " -- should say line 6" 70 Return > run "goto_test.bas" Hello Error in line 2: foo -- should say line 3 Error in line 4: foo -- should say line 6 Best wishes, Tom Edited 2021-10-18 19:10 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 442 |
It is legal in most '70s and '80s BASIC interpreters. IF X=1 THEN 180 IF X=1 GOTO 180 IF X=1 THEN GOTO 180 were all legal. Edited 2021-10-18 20:33 by toml_12953 |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Best wishes, Tom Peter, Geoff, it looks like the fix is simple as adding: CurrentLinePtr = nextstmt; to the end of cmd_goto() and cmd_gosub(). There is however another issue in that TRACE won't log a visit to a line that you GOTO or GOSUB using a line number (but will if you use a label): > list "trace_test.bas" Trace On ' 1 ' 2 GoSub 10 ' 3 GoSub label ' 4 End ' 5 ' 6 10 Print : Print "Hello" ' 7 Return ' 8 ' 9 label: Print : Print "Goodbye" ' 10 Return ' 11 > run [3] Hello [8][4][10] Goodbye [11][5] Observe how visiting line 10 is logged, but visiting line 7 is not. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |