DAY 011: REM
#11
For DATA...

EDITED
Code: (Select All)
DATA 1,2,3 ' This doesn't run for a numeric read, because 3 ' This.. is viewed as a STRING in the DATA statement. The IDE won't flag it, because it cannot tell if the data is meant to be numeric.
DATA 1,2,3: ' But with a colon added, it will work.
DATA "1,2,3" ' This doesn't works. IDE flags it.
DATA "1,2,3": ' But with a colon added, it does.

DATA 1,2,3 REM This doesn't run for a numeric read, because 3 REM This.. is viewed as a STRING in the DATA statement. The IDE won't flag it, because it cannot tell if the data is meant to be numeric.
DATA 1,2,3: REM But with a colon added, it does.
DATA "1,2,3" REM That doesn't works and the IDE flags it.
DATA "1,2,3": REM But with a colon added, it does.

Thanks Steve for the heads up on mixed variable types caused by remark statements.

Pete
Reply
#12
TerryRitchie, in QB64-3.4.0 under Windows it works for me
Code: (Select All)
Read a, b, c, d, e
Print "a = "; a
Print "b = "; b
Print "c = "; c
Print "d = "; d
Print "e = "; e

Data 1,2,3,4: ' comment
Data 5
Reply
#13
(11-16-2022, 07:47 PM)TerryRitchie Wrote: READ a, b, c, d, e
DATA 1, 2, 3, 4: ' comment
DATA 5

When trying to read the value for e a syntax error is thrown. Oh well, thought I was on to something there.

Now these are the type of issues that really make me scratch my head...

Code: (Select All)
READ a, b, c, d, e
PRINT a, b, c, d, e

DATA 1,2,3,4: ' comment
DATA 5

This has no issues with reading our 5 data statements -- even with one of them having a comment attached to it in this manner.  At least, for me, there's no issues.

[Image: image.png]

free pic upload site


So why the heck is there issues for you?  Is this an OS glitch?  A 32-bit vs 64-bit glitch?  Why does it work sometimes and not all the time?  

Enquiring minds want to know!
Reply
#14
If anything, someone might want to improve the IDE so it throws an error for the two examples I gave in post #11.

As is, folks have two ways of coding data with remarks wrong, but they won't be stung until runtime. Since runtime yields a syntax error, the user is going to be scratching his head wondering why the IDE let the syntax error compile.

Pete
Reply
#15
Just like the rule that everything after REM is considered remarks/comments, probably a good idea to have a rule that states everything after DATA is considered data.

Simple no fuss no muss.

Always safe.

But I tend to not like comments at the end of a line, so totally biased over here.
Reply
#16
I always use a ' instead of REM, but a funny thing I noticed playing with REM is that if you add a colon after a REM, followed by code on the same line, the IDE thinks it's code and syntax colors it accordingly, but the code on the line is ignored and not run.

REM: SLEEP  'it's really in rem sleep, lol

or REM: PRINT "FFF"  'the print syntax code is colored, but not run.

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#17
(11-16-2022, 10:03 PM)Dav Wrote: I always use a ' instead of REM, but a funny thing I noticed playing with REM is that if you add a colon after a REM, followed by code on the same line, the IDE thinks it's code and syntax colors it accordingly, but the code on the line is ignored and not run.

REM: SLEEP  'it's really in rem sleep, lol

or REM: PRINT "FFF"  'the print syntax code is colored, but not run.

- Dav

Ooooh, that's a good catch.  Good sleuthing.

The little I've looked at (in general), syntax highlighting is not a trivial affair.
Reply
#18
I've noticed what Dav mentioned, too. Especially since I make a lot of colorful REMarks.

Pete
Reply
#19
(11-16-2022, 09:20 PM)Pete Wrote: As is, folks have two ways of coding data with remarks wrong, but they won't be stung until runtime. Since runtime yields a syntax error, the user is going to be scratching his head wondering why the IDE let the syntax error compile.

Pete
It's like the glitch you discovered the other day! The user has to have some common sense while using the product. No developers want to slave over minute details of getting this little bit just right, even if they're being paid for it. Just put the comment in a separate line from any valid code line. Relying on the colon only to place a comment on the same line as code is the sign of sloppy programming. I would reject that if it's not for a "this number of lines" programming contest and even if there are more valid English clauses in it than stuff to be parsed. Tell the kids not to be lazy like C++ programmers that screamed out for that double-slash and made sure many other languages had it also.

Remarks being colored because the IDE thinks they are valid statements: don't sweat any of that stuff. If this is too confusing then use another text editor to create source code.

Be glad QB64PE is not like Lua. How to deal with this many equals signs when plain double-bracket isn't good enough to start a comment or delimit a string full of single- and double-quotation marks...

I was going to request code-folding in the IDE, and '{ and '} supported for the user to enforce it on a block. Imagine that.
Reply
#20
This oversight upsets the Continuity Principle.

Code: (Select All)
DATA "1,2,3" ' This doesn't works. IDE flags it.
DATA 1,2,3 ' This doesn't run, but the IDE doesn't flag it.

So when Rob put this together, he simply missed a condition. Since the IDE is set up to catch syntax errors before compilation, yes, this should at some point in time be corrected. In therms of priorities, things like this and the IF THEN ELSE anomaly are certainly backseat compared to a memory leak in SCREEN Zero. Oh the horror!!!!

Pete
Reply




Users browsing this thread: 2 Guest(s)