[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: re-DIM a variable "on the fly" ??
"Rich J." writes ...
>
> Hi,
>
> I got the gate editor to work on my logic gate simulator.
>
> If you choose to add a gate I need to make a variable array
> larger
>
> example
> s=8
> DIM X(s)
>
> NEW GATE:
> s=s+1:REM s=9
> X(s)=5
>
> !!ILLEGAL QUANTITY ERROR!!
> X is only dimmed for 8, and I want to add a 9th variable.
>
> My work around:
>
> Always DIM X to s+1
> DIM X(s+1)
>
> when you add a variable, make X(s+1)equal to that value,
> SAVE the DATA, and LOAD it again. The DATA is dimmed
> to s+1 each time it is LOADed, so I can add one more
> varaiable AGAIN before I have to SAVE/LOAD again.
>
> This takes alot of time! Add 1 gate and the disk spins
> for a while. SAVE/LOAD.
>
> Ideas for a fix?
>
....
There are several ways to avoid having to mess with a disk SAVE/LOAD. The
simplest approach may be to DIM your array to some value large enough to hold
as many X() vars as you may ever want.
Then you can just keep track of how many valid X() vars there and make all
array scans, checks, etc. dependent upon that number.
Rubywand