QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: xra7en on November 30, 2019, 11:12:59 am

Title: Odd Data/Read syntax error
Post by: xra7en on November 30, 2019, 11:12:59 am
The following syntax error is not making sense

Data Snippet (saved as gamedata.bi)

Code: QB64: [Select]
  1. STAR_NAMES:
  2. DATA "Lelande 21185","NI,P"
  3. DATA "Alpha Centauri","NA,I"
  4. DATA "Sirius","A"
  5. DATA "Benards Star","I,P"
  6. DATA "Sol","R"
  7. DATA "Ross 154","NI,NA"
  8. DATA "Episilon Eridani","A,P"
  9. DATA "Luyten 726-8","NA"
  10. DATA "Luyten 789-6","A,NI,P"
  11. DATA "Ross 248","A,I"
  12.  

Main code to read this:
Code: QB64: [Select]
  1.     DIM A, B AS STRING
  2.     DIM I AS INTEGER
  3.  
  4.     FOR I = 1 TO 10
  5.         READ A, B '<--- SYNTAX ERROR
  6.         PRINT A
  7.         PRINT B
  8.         END
  9.  
  10.         PRINT USING "##"; I;
  11.         PRINT TAB(5); A; TAB(21); B;
  12.         PRINT TAB(29);: PRINT USING "##.##"; DD(I);
  13.         PRINT TAB(35);: PRINT USING "####"; T(I)
  14.     NEXT
  15.  
Odd thing, if I press YES to continue through the error it displays correctly??!!?

Thanks!
EDIT: Added how the variables are DIM'd
Title: Re: Odd Data/Read syntax error
Post by: SMcNeill on November 30, 2019, 11:23:00 am
Is A and B both defined as STRINGs?

Code: QB64: [Select]
  1. STAR_NAMES:
  2. DATA "Lelande 21185","NI,P"
  3. DATA "Alpha Centauri","NA,I"
  4. DATA "Sirius","A"
  5. DATA "Benards Star","I,P"
  6. DATA "Sol","R"
  7. DATA "Ross 154","NI,NA"
  8. DATA "Episilon Eridani","A,P"
  9. DATA "Luyten 726-8","NA"
  10. DATA "Luyten 789-6","A,NI,P"
  11. DATA "Ross 248","A,I"
  12.  
  13.  
  14.  
  15. FOR I = 1 TO 10
  16.     READ A, B '<--- SYNTAX ERROR
  17.  
  18.     PRINT USING "##"; I;
  19.     PRINT TAB(5); A; TAB(21); B;
  20.     PRINT TAB(29);: PRINT USING "##.##"; DD(I);
  21.     PRINT TAB(35);: PRINT USING "####"; T(I)
Title: Re: Odd Data/Read syntax error
Post by: xra7en on November 30, 2019, 11:27:01 am
Hi!!
Ya, just added that when you sent yours LOL
Title: Re: Odd Data/Read syntax error
Post by: Pete on November 30, 2019, 11:51:43 am
I wish we could get away with DIM A, B, C, D, ETC, AS STRING but then we would need a new syntax: AS STRINGS

Change it to...

DIM A AS STRING, B AS STRING

Sorry, I copied and pasted your code first, ran it, then hit reply. I should have looked for other replies first, to see the problem was solved. Oh well, blame it on too much Thanksgiving Day lasagna!

Pete
Title: Re: Odd Data/Read syntax error
Post by: xra7en on November 30, 2019, 12:18:08 pm
LOL!! lasagna!!!!!
 You can't stuff lasagna :-)


BTW that was it!! thanks!

Title: Re: Odd Data/Read syntax error
Post by: TempodiBasic on November 30, 2019, 12:57:59 pm
you say lasagna  and I think these
https://i.pinimg.com/474x/4a/f4/a2/4af4a2a50cd93167002d04c701b2a0be.jpg (https://i.pinimg.com/474x/4a/f4/a2/4af4a2a50cd93167002d04c701b2a0be.jpg)
https://scontent.ffco3-1.fna.fbcdn.net/v/t1.0-9/13686737_1065061723585368_6969759272860016585_n.jpg?_nc_cat=107&_nc_ohc=pFhZR8JucbEAQn9fPAlJqSRhE6VatT9cPPfUsgS0O62j1R2o6EPMMEbwg&_nc_ht=scontent.ffco3-1.fna&oh=22fc790d94cbe914c2fb8f6321fe59ea&oe=5E7DD846 (https://scontent.ffco3-1.fna.fbcdn.net/v/t1.0-9/13686737_1065061723585368_6969759272860016585_n.jpg?_nc_cat=107&_nc_ohc=pFhZR8JucbEAQn9fPAlJqSRhE6VatT9cPPfUsgS0O62j1R2o6EPMMEbwg&_nc_ht=scontent.ffco3-1.fna&oh=22fc790d94cbe914c2fb8f6321fe59ea&oe=5E7DD846)
https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSENurOfymM23gVDOch3zKcMZg9KxyHtquEmDFnR9B05tcgrjPd&s (https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSENurOfymM23gVDOch3zKcMZg9KxyHtquEmDFnR9B05tcgrjPd&s)
and them Shrek and Ciuchino (Donkey) https://4.bp.blogspot.com/-EHukDXSbl0Y/Wr1PYh0e_0I/AAAAAAAAELc/iJn_NNPOOkEMpXzLchQwzVzTvxkmWf-JgCLcBGAs/s320/10203_613510198717595_1137046265_n.jpg (https://4.bp.blogspot.com/-EHukDXSbl0Y/Wr1PYh0e_0I/AAAAAAAAELc/iJn_NNPOOkEMpXzLchQwzVzTvxkmWf-JgCLcBGAs/s320/10203_613510198717595_1137046265_n.jpg)
Title: Re: Odd Data/Read syntax error
Post by: SMcNeill on November 30, 2019, 01:24:28 pm
LOL!! lasagna!!!!!
 You can't stuff lasagna :-)


BTW that was it!! thanks!

No, but you can use lasagna to stuff a Garfield.
Title: Re: Odd Data/Read syntax error
Post by: Pete on November 30, 2019, 01:30:08 pm
For what's it's worth, I do have a cat that eats lasagna, however unlike Garfield, she's a little spring. I have yet to beat her in a race down our stairs... well, without cheating by jumping off the balcony. With my luck, my tie would get caught on the railing, and I'd end up like that Epstein character, who supposedly committed suicide in his prison cell. The only difference is his jail cell had non-functioning video cameras, whereas my my home cam system works perfectly; so while his family had to start a go fund me page, mine would just submit our footage to America's Funniest Home Videos, for a sure bet of winning the grand prize!

Now what topic were we on again??? :D

Pete