09-29-2025, 02:49 PM
(09-29-2025, 01:42 PM)dakra137 Wrote: No, it is not necessary to add a superfluous value to the DATA statement.
It is sufficient to add a not-really-superfluous comma after the last item to be read.
'instead of
'mydata: Data 8,1,2,3,4,5,6,7,8,9999
'use:
mydata: Data 8,1,2,3,4,5,6,7,8,9999,
The QB64PE documentation page syntax diagram for the DATA statement clearly shows that every value is followed by a comma:
DATA [value1, value2, …]
Kindly look at the samples for the wiki page.
And then remember to look at this highlight from the description:
Comments after a data line require a colon before the comment.
Also notice the example on the wiki page:
Code: (Select All)
Restore Database2
Read A$, B$, C$, D$ 'read 4 string values from second DATA field
Print A$ + B$ + C$ + D$ 'note that quoted strings values are spaced
Restore Database1
For i = 1 To 18
Read number% 'read first DATA field 18 times only
Print number%;
Next
End
Database1:
Data 1,0,0,1,1,0,1,1,1
Data 2,0,0,2,2,0,2,2,2: ' DATA line comments require a colon
Database2:
Data "Hello, ","world! ",Goodbye,work!
The issue isn't any need to end DATA with a comma. That's not required at all.
The issue is reading a STRING as a NUMBER and blipping an error attempting it.


