Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add READ / DATA instructions #296

Closed
spotlessmind1975 opened this issue Dec 11, 2021 · 1 comment
Closed

Add READ / DATA instructions #296

spotlessmind1975 opened this issue Dec 11, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@spotlessmind1975
Copy link
Owner

The BASIC command READ is used for reading constant values from DATA lines into the indicated variables. This command is able to read more constants at once with a variable list separated by commas.

If using the wrong type of variable (for example read a character string into a numerical variable like float or integer) the BASIC error ?SYNTAX ERROR IN line occurs with a reference of the corresponding DATA line. Starting with BASIC 3.5 the error message changes to ?TYPE MISMATCH ERROR and the line number points directly to the READ statement that triggered the condition. Such behavior can be prevented by generally using string variables.
With a value that falls outside the expected range of a READ variable, e.g. the value is outside the range of an integer, BASIC breaks with error ?ILLEGAL QUANTITY ERROR.
If more constants are read than values exist in DATA lines the BASIC error ?OUT OF DATA appears.

The BASIC command RESTORE resets the current DATA read pointer to beginning of the program. A succeeding READ searches for the first DATA statement where the DATA read pointer is adjusted to. How long a READ takes depends on how many program lines are to be processed to advance the DATA read pointer to the next DATA line. See DATA for an advice where to place DATA lines.

The BASIC-Command DATA is used to store constant information in the program code, and is used with the BASIC-command READ. Each DATA-line can contain one or more constants separated by commas. Expressions containing variables etc. will not be evaluated here.

The DATA values will be read from left to right, beginning with the first line containing a DATA statement. Each time a READ instruction is executed the saved DATA position of the last READ is advanced to the next value. Strings can be written normally or in quotes, but characters like comma, space, colon, graphical ones or control characters has to be written inside double quotes like string constants. The BASIC command RESTORE resets the pointer of the current DATA position the program start so that next READ will read from the first DATA found from the beginning of the program (starting with BASIC 3.5 the DATA line can be selected, too).

In case READ uses the wrong variable type the error message ?SYNTAX ERROR appears while referring the DATA line currently read. There is no easy way to get the position of the READ statement which is the real origin of the error. With BASIC 3.5 the error message changes to ?TYPE MISMATCH ERROR and the line number points directly to the READ statement that triggered the condition.

DATA lines may scattered over the whole program code, but it from the sake of execution efficiency it would be better to move them to the end. Otherwise all statements like GOTO or GOSUB jumping to lower line numbers has to walk through all DATA lines every time which leads to be an unnecessary time-penalty.

@spotlessmind1975 spotlessmind1975 added the enhancement New feature or request label Dec 11, 2021
@spotlessmind1975 spotlessmind1975 added this to the 1.8 milestone Dec 11, 2021
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.8, 1.10 Jan 5, 2022
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.10, 1.11 Jan 16, 2022
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.10.2, 1.11 Mar 17, 2022
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.11, 1.12 Apr 29, 2022
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.12, 1.14 Nov 10, 2022
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.13, 1.14 Feb 7, 2023
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.13.3, 1.14 Apr 27, 2023
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.14, 1.15 Jun 17, 2023
@spotlessmind1975 spotlessmind1975 modified the milestones: 1.15, 1.16 Oct 14, 2023
@spotlessmind1975 spotlessmind1975 added the beta Candidate for BETA label Oct 17, 2023
@spotlessmind1975 spotlessmind1975 removed beta Candidate for BETA -done- Done labels Nov 22, 2023
@spotlessmind1975 spotlessmind1975 moved this from In progress to Done in To do list / cose da fare Nov 22, 2023
@spotlessmind1975
Copy link
Owner Author

Published with COLDFIX v1.15 [rev. 20231122.2000].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant