Post Reply 
71B: DIM a variable, but keep the old value if it's already the right type?
03-23-2021, 03:05 AM
Post: #2
RE: 71B: DIM a variable, but keep the old value if it's already the right type?
(03-23-2021 01:08 AM)Dave Britten Wrote:  ... If I use DIM or REAL to make sure they are the correct type, this zeroes them out, even if they were already REAL variables to begin with.

How might the 71B experts approach something like this? I know I can write the input values to an SDATA file and retrieve them at the beginning of the program, and I've done this for programs where it makes sense to keep the values indefinitely between runs. But is there a simpler option for when I don't care if one of the variables gets clobbered by another program I've run in the meantime?

The "HP-71 Reference Manual" says the following about the DIM command:

"If DIM specifies a simple numeric variable that already exists, the variable is reinitialized to zero. Other variables are redimensioned, but not reinitialized (unless the data type -- or, if a string variable, the maximum string length -- is changed). If DIM expands an array, it also initializes all newly created elements in the array."

Therefore, just make sure that the desired array already exists and contains the desired data type. Then using DIM to redimension it will not clobber its existing contents (unless redimensioned smaller, obviously).

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 71B: DIM a variable, but keep the old value if it's already the right type? - Joe Horn - 03-23-2021 03:05 AM



User(s) browsing this thread: 1 Guest(s)