Author Topic: An interesting difference between REM and '  (Read 4795 times)

0 Members and 1 Guest are viewing this topic.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
An interesting difference between REM and '
« 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
Re: An interesting difference between REM and '
« Reply #1 on: January 15, 2019, 11:23:02 am »
I haven't tried it, but is ' really equivalent to REM at the end of a line, or is it equivalent to : REM?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: An interesting difference between REM and '
« Reply #2 on: January 15, 2019, 11:58:27 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

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.

« Last Edit: January 15, 2019, 12:03:31 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: An interesting difference between REM and '
« Reply #3 on: January 15, 2019, 12:51:38 pm »
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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: An interesting difference between REM and '
« Reply #4 on: January 15, 2019, 01:02:34 pm »
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?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: An interesting difference between REM and '
« Reply #5 on: January 15, 2019, 02:08:41 pm »
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.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: An interesting difference between REM and '
« Reply #6 on: January 15, 2019, 03:32:30 pm »
(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.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: An interesting difference between REM and '
« Reply #7 on: January 15, 2019, 06:01:06 pm »
moreover I can say that the real difference is in this
Code: QB64: [Select]
  1. IF a = 0 THEN b = 3: REM  this is a select old command comment : a =a * 10
  2. PRINT a, b
  3. IF a = 0 THEN b = 3: 'this is  a newer select comment  : a =a * 10
  4. PRINT a, b
  5.  

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
Programming isn't difficult, only it's  consuming time and coffee

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: An interesting difference between REM and '
« Reply #8 on: January 15, 2019, 06:26:55 pm »
QB45 was all white letters, too. I guess that made it a non-diversified language. Build that firewall!

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Re: An interesting difference between REM and '
« Reply #9 on: January 18, 2019, 10:56:21 am »
moved to own thread
« Last Edit: January 19, 2019, 09:43:02 am by xra7en »
I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: An interesting difference between REM and '
« Reply #10 on: January 24, 2019, 05:08:19 am »
I have always been somewhat bemused by statements such as:

Code: QB64: [Select]
  1. '$INCLUDE:'InForm.ui'

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)?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: An interesting difference between REM and '
« Reply #11 on: January 24, 2019, 10:15:53 am »
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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
Re: An interesting difference between REM and '
« Reply #12 on: January 24, 2019, 10:54:44 am »
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.