Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiler and Running Disagree
#1
Hi all! New here, and mostly new to programming. Regarding the following code, the compiler thinks it's fine, but when I run the program it says there's a syntax error on the line that begins with "Read" (line 30). I can't seem to get it to go away. What makes it stranger is that I can use it in an entirely different program and there's no such error.

Claude.AI and ChatGPT have been useless trying to figure out how to fix this. And yes, there's a fair amount more code above and below in the BAS file, but it doesn't seem to affect this. And no, this code isn't part of a for, loop, sub, or function.

Any help would be greatly appreciated.

Using the latest version of QB64P as of a few days ago. Windows.

Code: (Select All)
mapWidth = 26
mapHeight = 15

Dim Shared mapC(0 To mapWidth - 1, 0 To mapHeight - 1) As Integer

' First row, first column counts as "0" in coordinates
' Data map must match width and height above

'                              M
'                        1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2
'    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 '0
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '1
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '2
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '3
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '4
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '5
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '6
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '7 M
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '8
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '9
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '10
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '11
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '12
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 '13
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 '14

For y = 0 To mapHeight - 1
    For x = 0 To mapWidth - 1
        Read mapC(x, y)
    Next
Next

EDIT: As is typical, it seems that I figured it out after asking for help. It seems the number-comments after each DATA line are what did it.
Reply
#2
You can add comments, just add the colon...

Code: (Select All)
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1: '0

Pete
Reply
#3
@Pete good point, I might use line labels above some lines for Restore or Documentation.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#4
https://qb64phoenix.com/forum/showthread...4#pid28734  <-- This explains the issue.  It's actually 100% working as intended.
Reply
#5
I would write the comments, in this case just numbers, before the DATA lines: One to fifteen.

For me, zero would not be a DATA line, because zero is zero, there is nothing, that's why it's called zero.  Tongue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Running QB64 v2 InForm Programs on PE Magdha 2 354 11-19-2025, 11:10 AM
Last Post: Magdha
  GNU C++ Compiler error eoredson 55 7,919 12-26-2024, 05:27 AM
Last Post: eoredson
  Run code without compiler phil 9.0 7 1,281 12-05-2024, 08:52 AM
Last Post: phil 9.0
  Detect running from IDE mdijkens 1 578 02-12-2024, 02:59 AM
Last Post: FellippeHeitor
  Importing and Running Libraries in C krovit 7 2,373 12-11-2023, 11:46 AM
Last Post: krovit

Forum Jump:


Users browsing this thread: 1 Guest(s)