RESTORE I -> undefined line number

By The Apeman

Master (252)

The Apeman さんの画像

05-01-2023, 19:50

In MSX BASIC, I'm trying to assign a number to a variable which will be the line number from which the DATA values should be read:

10 LET I = 60
20 RESTORE I
30 READ J:IF J=0 THEN END
40 PRINT J
50 GOTO 30
60 DATA 1,2,3,4,5,0

I expect this to output 1,2,3,4 and 5, each on a line, but instead, I get Undefined line number in 20.

Does RESTORE only accept values, not variables? Question

ログイン/登録して投稿

By ARTRAG

Enlighted (6977)

ARTRAG さんの画像

06-01-2023, 00:33

Only values, no variables

By gdx

Enlighted (6438)

gdx さんの画像

06-01-2023, 01:07

You can use DIM and a variable table to do it.

By The Apeman

Master (252)

The Apeman さんの画像

06-01-2023, 09:14

Thanks

By NYYRIKKI

Enlighted (6093)

NYYRIKKI さんの画像

07-01-2023, 02:38

This slightly modified code should work with tables:

10 DEFINT A-Z
20 DIM D(5,10)
30 COPY "MY_DATAS.DIM" TO D
40 IF D(C,0)=0 THEN END
50 PRINT D(C,0)
60 C=C+1: GOTO 40