Skip to content

DATA-blocks with labels #319

Description

@tommy-carlier

Currently, you can READ values from DATA-lines and use RESTORE to start reading from the top again.

A possible enhancement is to allow a label before a DATA-line, and pass that label to the RESTORE-statement to start reading from that line.

Example:

RESTORE @block1
GOSUB @processData
RESTORE @block2
GOSUB @processData
END

@processData
DO
    READ i%
    IF i% < 0 THEN EXIT DO
    PRINT i%
LOOP

@block1
DATA 1, 2, 3, 4, -1

@block2
DATA 5, 6, 7, 8, -1

A further enhancement is to allow an END-value in a DATA-line that marks the end of a block of DATA-lines. Reading the END-value results in an "out of data" error.

Example:

RESTORE @block1
GOSUB @processData
RESTORE @block2
GOSUB @processData
END

@processData
ON ERROR GOTO @endOfData
DO
    READ i%
    PRINT i%
LOOP
@endOfData
ON ERROR GOTO 0

@block1
DATA 1, 2, 3, 4, END

@block2
DATA 5, 6, 7, 8, END

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions