Active Forums => QB64 Discussion => Topic started by: Qwerkey on June 19, 2019, 01:28:06 pm
Title: How to Avoid Conditional DATA line READ Errors?
Post by: Qwerkey on June 19, 2019, 01:28:06 pm
In the code given here, the first line containing a DATA statement is inside a condition which only happens the first time the code is run. At any subsequent program run, it is required to ignore that DATA line.
However, when READing for the Parameters!() array input (the subsequent DATA lines), the first elements of Parameters!() are taken from that first DATA line, even though that is not executed. Is there a way to skillfully avoid that? In my case, it was easy enough to move the DATA lines for Parameters!() before the original DATA line.
and one warning for you. If you use DATA, then character ' must be separated by a colon. Otherwise, READ takes it as part of a DATA block.
Title: Re: How to Avoid Conditional DATA line READ Errors?
Post by: bplus on June 19, 2019, 03:13:25 pm
Data statements are best placed after main code block - from Wiki
As I remember READ looks for first DATA line regardless of where it sits in program, unless RESTORE is used to set the next DATA READ line.
You can isolate DATA statements in a SUB or FUNCTION only to be READ inside that procedure.
Title: Re: How to Avoid Conditional DATA line READ Errors?
Post by: Cobalt on June 19, 2019, 07:32:27 pm
Yeah, there is no such thing as 'Conditional Data' as far as I'm aware. the best way to accomplish what it looks like your trying to is use a RESTORE command within the condition to read specific data area. unless its called from within a SUB or FUNCTION as BPlus has said, data is read from top down within the main code. Perhaps a better way is to preload all the data into an array and just call upon the required array area when needed.
Title: Re: How to Avoid Conditional DATA line READ Errors?
Post by: Qwerkey on June 20, 2019, 04:00:17 am
Thanks guys. Look like I should have read the wiki.