Hack-a-Day / basic-badge

2018 Hackaday Belgrade Hardware Badge
MIT License
36 stars 8 forks source link

Add parameters for LIST word in BASIC #15

Closed szczys closed 6 years ago

szczys commented 6 years ago

If user wants to examine a specific line of code, it would be helpful to do so directly with the list command. Basic functionality might work like this:

jaromir-sukuba commented 6 years ago

This is not that trivial as I anticipated - the list function would have to make the same syntax check as the interpreter itself in order not to get lost in the program. As a workaround, I implemented MORE function since v 0,40. After invoking, it outputs first 19 lines of code - the same as list function - but then it emits "---hit any key for more, q to quit---" line. Printing of program is suspended until user hits a key; if it's q, everything returns back to CLI, or prints another 19 lines for any other key.

szczys commented 6 years ago

The proposed behavior is good, but 'q' is not working for me. It causes 19 more lines to be listed.

Also, your sample program has invalid command at line 1. If I try to type in a new line 1 the badge resets: 1 goto 3

Do you see this behavior as well.

jaromir-sukuba commented 6 years ago

Yes, the basic program was broken, with few non-functional parts, especially the part "1 poinless long program\n\2 to sport MORE function\n\" in first two lines, it was intended just as model to show MORE functionality.

I fixed the 'q' bug, it should work OK in 0.41

jaromir-sukuba commented 6 years ago

V 0.42 is out, should fix both the reset after adding the "1 goto 3" line, as well as subsequent incorrect insertion.

szczys commented 6 years ago

More function works great! 'q' is now working. Nice.

There's still something funky with getting rid of a line. If you just type the number with nothing after it you sometimes get junk. If you type number with nothing after it twice in a row it gets removed.