QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Pete on January 15, 2019, 11:16:38 am
-
IF INSTR(a$, x$) = 0 THEN ' Can be used here in an if/then block.
END IF
IF INSTR(a$, x$) = 0 THEN REM Cannot be used here in an if/then block.
END IF
I'm just sayin'... :D
I have to say THEN REM looks horrible, so I'm glad it can't be used; but since ' and REM mean the same thing, I'd thought I'd check it out. Up until a year or so ago, I never put a remark after THEN or similar block statements. A ways before that, I never put remark statements in my code at all, but things change with age. That reminds me, Steve, how is that constant I asked for coming along? You know... CONST wheredidpeteputhiscarkeys
Pete
-
I haven't tried it, but is ' really equivalent to REM at the end of a line, or is it equivalent to : REM?
-
IF INSTR(a$, x$) = 0 THEN ' Can be used here in an if/then block.
END IF
IF INSTR(a$, x$) = 0 THEN REM Cannot be used here in an if/then block.
END IF
I'm just sayin'... :D
I have to say THEN REM looks horrible, so I'm glad it can't be used; but since ' and REM mean the same thing, I'd thought I'd check it out. Up until a year or so ago, I never put a remark after THEN or similar block statements. A ways before that, I never put remark statements in my code at all, but things change with age. That reminds me, Steve, how is that constant I asked for coming along? You know... CONST wheredidpeteputhiscarkeys
Pete
This behavior was something the users wanted for QB64. I too also thought that REM and ‘ were interchangeable, but they’re not.
IF whatever THEN REM <— This is a perfectly valid standalone statement, as folks wanted.
IF whatever THEN ‘ <— This will require an END IF block to complete it.
REM is a *command*. ‘ is nothing more than a *comment*. <— at least this was how it was explained to me at the time, which is why REM isn’t colored the same as ‘ in the IDE.
Think of it as:
REM followed by the comment.
‘ is *part* of the comment.
REM, as a command, is very similar to LET in that it appears to be an optional command.
-
I figured Rob has his reasons, but I wish he would have implemented some sort of BLOCK remark ability. That isn't as easy as it sounds, because it requires the user ends it before going back to typing statements. The color changes in the IDE help that. The IDE is a bit annoying with the alerts, but I suppose if he had made one, it would keep reminding us we had a BLOCK remark statement without and END BLOCK remark statement.
Pete
-
When Steve says it's "as folks wanted" he's referring to syntax highlighting, not to how REM vs apostrophes work. That's been like that forever and was probably never discussed whether it should be done differently, or am I crazy?
-
When Steve says it's "as folks wanted" he's referring to syntax highlighting, not to how REM vs apostrophes work. That's been like that forever and was probably never discussed whether it should be done differently, or am I crazy?
The coloring and the behavior were both debated back over at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]. Some folks wanted the two to be 100% interchangeable, others liked the IF x THEN REM ability to quickly comment out code for testing. (Though why you wouldn’t just REM in front of the IF instead of after the THEN is beyond me...)
Arguments went back and forth for what the community wanted (I have no clue as to what is actually proper for QBASIC/QB45), and in the end REM became a command, while ‘ was a shortcut for a comment.
-
(I have no clue as to what is actually proper for QBASIC/QB45)
What we have is the same as QBasic/QuickBASIC 4.5, which is why it never occurred to me this could have once even been discussed. Thanks for clarifying the process.
-
moreover I can say that the real difference is in this
IF a
= 0 THEN b
= 3:
'this is a newer select comment : a =a * 10
if you load this code in QB64 you get a different aspect for comment by apostrophe ( one color for all the comment), while with REM you get different colors,( that for variable used for text of comment except for that words that are Keywords for QB64)....
the results of execution of the code is the same for the two statements....
In Qbasic all the text has one color :-)
In QB45 I don't know because I haven't found this at this moment.
Say again
-
QB45 was all white letters, too. I guess that made it a non-diversified language. Build that firewall!
Pete :D
-
moved to own thread (https://www.qb64.org/forum/index.php?topic=985.0)
-
I have always been somewhat bemused by statements such as:
You would have thought that the compiler would read the line as "I have come across a ' and will therefore ignore anything to the right of it", but it knows '$INCLUDE: is a command.
When '$INCLUDE: was created, was there an actual reason for putting the initial ' (and the subsequent ' characters referencing the included code)?
-
When Rob created QB64 he had a hard time adjusting to the light he created the day before, so due to glare he just missed the typo. Actually, if I recall correctly, QBasic and QuickBasic used '$INCLUDE so one reason to keep it that way was to preserve compatibility. So why did the original developer of QB decide to write it that way? I couldn't tell you, but maybe someone else here who studies language structure would know the answer to that. I just hope my memory of QB is still valid. I never needed to use '$INCLUDE files, so those memories just aren't bolstered up by experience.
Pete
-
I suspect that '$INCLUDE was chosen because most other compilers (also) placed their metacommands in language comments. Often this was because the initial implementation was with a preprocessor followed by a "core language" compiler/parser; if the preprocessor left an uncommented metacommand in the source stream, it would often trigger an error in the parse/compile pass. Masking the metacommand with a language comment indicator prevents this sort of error.