@ASCII-only Sorry to hear that! I've never tried either QB64 or DOSBox on Linux (which one are you trying to use?). steenbergh has DOSBox experience, but I'm not sure if that's on Linux or Windows.
@ASCII-only Kinda. It sounds like you may want subprocedures, which are defined with SUB sub_name(param1, param2): statements: END SUB and called either with CALL sub_name(arg1, arg2) or just sub_name arg1, arg2. The latter syntax is golfier and more like a user-defined command. What use case are you thinking of?
@ASCII-only Oh, I see. A line with assignment has a variable name followed by an equal sign. A line with sub call has a variable name followed by an argument list. So yeah, not the most straightforward thing to parse. (Not to mention when you throw array subscripting into the mix.)
@ASCII-only QBasic is case-insensitive, so sub_name and Sub_Name and SUB_NAME are all the same name. In fact, the IDE will actually change the case of all occurrences of a name to match the way you typed it most recently.
It will also capitalize all keywords, so I always use lowercase for variables to distinguish them. It's like a rudimentary version of syntax highlighting.
Lessee. Every line is an assignment, a statement that starts with a keyword (this includes control flow constructs), a sub call, or empty. (I think that's all the possibilities.)
But also, a line can start with either a line number (which I just discovered can contain a decimal point, oddly enough) or a label (which is a name followed by a colon).
@ASCII-only Roughly. In original QBasic, go to Help > Table of Contents > Keywords by Programming Task (it's not alphabetized, but it should have all the reserved words listed). In QB64, Help > Keywords by usage is similar. There might be a list online somewhere. (I'm remembering one in an appendix in one of my QBasic books, but that won't help you.)
@DLosc hmm, also, when are sigils allowed after function names? only for builtin functions?
also, I'm not sure what the best way to parse , and ; would be. Can they be considered as binary operators (like + and friends)? maybe as an optional (or is it mandatory for all arguments other than the last) suffix for arguments?
@ASCII-only Sigils specify the function's return type, just like they specify the type of a variable. So I can write a function f# that returns a double or s$ that returns a string. (Incidentally, in the function body, you set the return value by assigning to s$.)
Without a sigil, I believe the implied type is single.
(offtopic: I don't know why I'm not learning QBasic by just trying it out in the interpreter since I have it installed >_> I guess I'm just too used to TIO)
also I'm writing the interpreter (which will almost certainly be abandoned within a week) on TIO which is clearly the best idea ever
also, comments are weird. they look like a sub but they essentially change parser behavior until the end of the line right?
@ASCII-only Yeah, a little testing shows that that's wrong. PRINT 1/3 prints .3333333 (single) but PRINT 1#/3 (coercing to double) prints .3333333333333333
@ASCII-only That's what's happening in the second example, yes. In PRINT statements, a trailing ; or , suppresses the trailing newline. In INPUT statements... well, I'll direct you to my writeup in the tips question.
I reckon. Then you get to decide how much of a stickler for proper syntax you want to be. (Some things aren't optional.) As far as I know, PRINT and INPUT and related statements are the only statements that use ; for anything.
QBasic really likes things being optional (nice for golf sometimes), and it really likes giving each command its own peculiar syntax.
The help file does a pretty good job of indicating which parts of which statements can be left out.
(Cool thing I found out just now: you can omit the first point in a LINE statement, in which case the line begins where the previous drawing command left off.)