Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Must an extra value be provided on DATA statement?
#5
(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, …]

Blush

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.
Reply


Messages In This Thread
RE: Must an extra value be provided on DATA statement? - by SMcNeill - 09-29-2025, 02:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Seeking Matches in a Data Base Dimster 10 1,045 07-13-2025, 12:26 AM
Last Post: Dimster
  _Glue statement coming anytime soon? Pete 7 1,303 04-13-2025, 10:56 PM
Last Post: eoredson
  Change file data krovit 5 1,201 07-11-2024, 07:45 AM
Last Post: krovit
  The Width statement eoredson 15 2,308 04-06-2024, 03:57 AM
Last Post: Pete
  Arrays In User Data Types Consolemu 2 868 01-18-2024, 09:49 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)