|
Post by bitvast on Aug 18, 2014 8:32:23 GMT 1
If I have some data which is segregated by labels, it doesn't seem to be possible to jump directly to the data under a particular label and READ it. Example:
FOR i = 1 TO 8 READ x PRINT x IF i = 4 THEN RESTORE odd NEXT i
LABEL odd DATA 1,3,5,9 LABEL even DATA 2,4,6,8
1 3 5 9 1 3 5 9
That works ok, but what if want to READ the even data first? So I want to print this:
2 4 6 8 1 3 5 9
This doesn't work:
RESTORE even
FOR i = 1 TO 8 READ x PRINT x IF i = 4 THEN RESTORE odd NEXT i
LABEL odd DATA 1,3,5,9 LABEL even DATA 2,4,6,8
|
|
|
Post by bitvast on Aug 18, 2014 11:32:59 GMT 1
The example given in the manual works just the same without putting "txt" after RESTORE
DATA 1, 2, 3, 4, 5 LABEL txt DATA "Hello", "world", "this", "is", "BaCon" RESTORE READ dat$ PRINT dat$
Is this because dat$ is a string variable? It seems that any data which isn't of the correct type won't be read into the variable. But changing the first data set to strings doesn't work as expected:
DATA "1", "2", "3", "4", "5" LABEL txt DATA "Hello", "world", "this", "is", "BaCon" RESTORE txt READ dat$ PRINT dat$ 1
|
|
|
Post by Pjot on Aug 18, 2014 21:17:05 GMT 1
Thanks bitvast, The RESTORE <label> statement contains a lot of legacy code, but it should work nevertheless (which it doesn't . I have partly fixed it, but for now the DATA has to appear before a RESTORE statement. So this works now: LABEL odd DATA 1,3,5,9 LABEL even DATA 2,4,6,8
RESTORE even
FOR i = 1 TO 8 READ x PRINT x IF i = 4 THEN RESTORE odd NEXT i
A permanent solution, where the DATA can occur anywhere in the program, will take more work; this will appear during this week. For your second question, indeed it is true that a READ checks the variable type and reads the first suitable value into it. BR Peter
|
|
|
Post by bitvast on Aug 19, 2014 7:29:48 GMT 1
Thanks Peter. Another bug squashed.
|
|
|
Post by Pjot on Aug 20, 2014 20:58:49 GMT 1
Hi Bitvast, So it is done, the latest beta is here as usual. BR Peter
|
|