07-25-2019, 06:24 PM
At the start of a program, some variables are declared and their values assigned accordingly, e.g.:
While the program is running, some of these values are changed:
etc.
At the end, when the program should go back to the start
variables retain the values they held at that time instead of being reinitialized. To do that, I must explicitly insert a series of LET instructions after the DIMs, e.g.
which is pretty annoying as well as making the program use more memory.
Is there any way to make DIM reinitialize variables?
Code:
start:
DIM year AS UBYTE = 56
DIM pre AS BYTE = 100
DIM stru(3,9) AS UBYTE => {{1,0,0,1,0,1,0,1,0}, {0,3,3,0,4,0,4,0,5}, {0,30,30,0,60,0,50,0,70}}
While the program is running, some of these values are changed:
Code:
year = year + 10
stru(2,9) = 1
etc.
At the end, when the program should go back to the start
Code:
end:
GOTO start
variables retain the values they held at that time instead of being reinitialized. To do that, I must explicitly insert a series of LET instructions after the DIMs, e.g.
Code:
DIM year AS UBYTE
DIM pre AS BYTE
DIM stru(3,9) AS UBYTE
...
year = 56
pre = 100
RESTORE strudata
FOR n = 1 TO 3
FOR m = 1 TO 9
READ stru(n,m)
NEXT m
NEXT n
which is pretty annoying as well as making the program use more memory.
Is there any way to make DIM reinitialize variables?