« first day (1 day earlier)      last day (42 days later) » 

12:06 AM
@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.
 
@DLosc dosbox works, it's just not commandline :|
 
Meaning...? That you can't pipe input in and output out? That would be a limitation of QBasic in general, since its I/O doesn't use the stream model.
 
@DLosc yeah. so it can't be put on TIO :P
 
Pretty much. On the plus side: sound and graphics!
 
 
3 hours later…
3:06 AM
@DLosc hmm. is it possible to define commands?
 
 
1 hour later…
4:27 AM
@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?
 
@DLosc >_> I'm trying to write an interpreter for a subset of QBasic, just wondering how to tell the difference between a command and an expression
(also, can subs have names in all caps)
 
4:51 AM
i.e. how to differentiate a line with assignment and a line with sub call
 
5:21 AM
@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.
 
5:43 AM
@DLosc Hmm. so every line is either an assignment or sub call right?
(or looping construct)
 
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).
 
@DLosc oh. also, is there a list of keywords (excluding subs/functions) anywhere?
 
@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.)
 
6:17 AM
@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.
 
@DLosc double I think?
according to explain xkcd :P
 
Oh, which one?
 
@DLosc >_> that makes sense. variables and functions can have the exact same names (since you have to assign to a function to return it anyway)
I'm assuming subs can't have sigils?
@DLosc 1306
 
@ASCII-only I think that's right. It wouldn't make sense for them to, since they don't have/return values.
 
6:28 AM
(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
 
i.e. REM ((( doesn't mess anything up
 
Right. Comments AFAIK behave just the same as single-line comments in C++ or Python or whatever. They can also be started with ' instead of REM.
 
Hmm. and is there anything that has to be at the start of a line?
e.g. according to wikipedia comments have to be at the start of a line?
 
No, that's not true.
PRINT "Hi" REM This prints stuff#)(@$@ works just fine
Line numbers or labels have to be at the start of a line, though, if you have them.
@ASCII-only I wouldn't try to treat , and ; like binary operators. Consider the following examples:
PRINT x; y;
LINE (0, 0)-(10, 10), , , 255
 
6:42 AM
@DLosc can't you just insert nulls in between
since they basically just mean lack of a value there
(also, in that case: what about treating it as an optional suffix on an expression)
 
@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.
 
@DLosc so basically it looks like the builtin can just check for null values, I think?
 
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.)
 
6:56 AM
Hmm, okay. another question: you can't leave out , right (and can you have multiple builtins on one line?)
 
1) No, you can't do something like LOCATE 5 10 when you meant LOCATE 5, 10
2) Only if you use the : statement separator between statements.
Unless you're talking about something like IF x=42 THEN PRINT "yes" ELSE PRINT "no"
Oh, another exception: on the question of leaving out separators, there is apparently semicolon inference in PRINT statements.
 
@DLosc apparently this is because QBasic has an insane number of statements (vs functions)
so all of those will have to be handled individually in the parser. rip
 

« first day (1 day earlier)      last day (42 days later) »