Page 2 of 2

Re: BASIC ROLL command?

Posted: Fri Oct 27, 2023 12:16 am
by kelli217
Yeah, here's another tidbit for you. The 80-character line length limitation is from the screen editor, not the BASIC parser. Lots of people have built long lines by using 'abbreviations.'

Perhaps you're familiar with the use of '?' to represent PRINT... or, if you're familiar with TRS-80 BASIC, the use of the apostrophe (') to represent REM.

What you may not know about is that many other BASIC keywords have abbreviations in CBM BASIC as well. The trick is to find the fewest non-ambiguous characters that identify a BASIC keyword, and hold down Shift while typing the last letter.

For example, DATA can be abbreviated as D♠ (in upper/lower PETSCII mode, this will look like dA). And since technically, the PRINT# keyword is a different command, you can't use ?# for it, but you can use P followed by Shift-R, and this abbreviates the entire thing; you don't even need the # sign. You get a six-character keyword for only two characters entered.

The practical limitation for a BASIC line length is 250 entities (whether characters in literals or keyword tokens). I don't know if BASLOAD checks for that maximum. But yeah, it should work as long as you stay at or under that maximum, though as you've noted, you're going to have trouble editing that once it's been tokenized.

Re: BASIC ROLL command?

Posted: Fri Oct 27, 2023 2:14 am
by MarkTheStrange
The abbreviation is not always what you expect; it's based on the order the keywords appear in the table in ROM, first match wins. So, for instance, iN is INPUT#, not INPUT. In fact, so are inP, inpU, and inpuT; there is no way to abbreviate INPUT at all.

But yes, BASIC will handle a line of 250 bytes: after adding 2 bytes for the pointer to the next line, 2 for the line number, and 1 for the zero byte end-of-line terminator, you get 255.

Re: BASIC ROLL command?

Posted: Fri Oct 27, 2023 3:20 am
by DragWx
Just popping in to confirm, RND(.) is slightly faster than RND(π), but I don't know how much of that is due to RND(0) differing from RND(1), and how much is due to the parsing speed of dot vs pi. Whatever the case is, this is the net result.

Edit: Parsing a dot is negligibly slower than parsing pi (like, not even 1% slower), but RND(0) itself is about 47% faster than RND(1). Sometimes I forget the tool to benchmark BASIC is BASIC. :P

Edit 2: For some reason, A*RND() is slightly faster than RND()*A.