Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can values assigned with DIM be reinitialized?
#1
At the start of a program, some variables are declared and their values assigned accordingly, e.g.:

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?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)