Post Reply 
[HP 35s] Clearing variables
03-01-2015, 06:00 PM
Post: #1
[HP 35s] Clearing variables
I came across a glitch on allocated variables management.
After a CLEAR All, MEM shows VAR:0
Now if I do CLEAR CLVAR% and enter 000 MEM shows VAR:1 and as a matter of fact VAR 0 is still allocated.
Does anybody know a way to clear all variables without clearing the whole calculator?
Find all posts by this user
Quote this message in a reply
03-01-2015, 09:09 PM
Post: #2
RE: [HP 35s] Clearing variables
(03-01-2015 06:00 PM)Tugdual Wrote:  Now if I do CLEAR CLVAR% and enter 000 MEM shows VAR:1 and as a matter of fact VAR 0 is still allocated.

Sure. CLVARX clears all indirect variables beyond (!) the entered index. As stated in the manual: "...all the indirect variables whose addresses are greater than the address entered are erased. For example: CLVAR056 erases all indirect variables whose address is greater than 56." So CLVARX 000 clears variable 001 and up.

(03-01-2015 06:00 PM)Tugdual Wrote:  Does anybody know a way to clear all variables without clearing the whole calculator?

CLVARX 000 followed by 0 STO I STO(I).
The direct (lettered) variables can be cleared by CLVARS.

Dieter
Find all posts by this user
Quote this message in a reply
03-01-2015, 09:47 PM
Post: #3
RE: [HP 35s] Clearing variables
(03-01-2015 09:09 PM)Dieter Wrote:  CLVARX 000 followed by 0 STO I STO(I).
The direct (lettered) variables can be cleared by CLVARS.
Thank you Dieter, I guess I didn't word my question correctly.
I wanted to know if it was possible to de-allocate VAR0 rather than just clear it?
Find all posts by this user
Quote this message in a reply
03-01-2015, 09:58 PM
Post: #4
RE: [HP 35s] Clearing variables
(03-01-2015 09:47 PM)Tugdual Wrote:  Thank you Dieter, I guess I didn't word my question correctly.
I wanted to know if it was possible to de-allocate VAR0 rather than just clear it?

That's the same procedure: clearing the highest-numbered variable deallocates it. So if var(1) to var(nnn) have been cleared by CLVARX 000, storing zero into var(0) also clears and thus deallocates var(0). Try it! Checking MEM will display VAR 0 afterwards.

Dieter
Find all posts by this user
Quote this message in a reply
03-01-2015, 10:58 PM (This post was last modified: 03-01-2015 10:58 PM by Tugdual.)
Post: #5
RE: [HP 35s] Clearing variables
(03-01-2015 09:58 PM)Dieter Wrote:  
(03-01-2015 09:47 PM)Tugdual Wrote:  Thank you Dieter, I guess I didn't word my question correctly.
I wanted to know if it was possible to de-allocate VAR0 rather than just clear it?

That's the same procedure: clearing the highest-numbered variable deallocates it. So if var(1) to var(nnn) have been cleared by CLVARX 000, storing zero into var(0) also clears and thus deallocates var(0). Try it! Checking MEM will display VAR 0 afterwards.

Dieter
Oh my Gosh, indeed!
And putting zero is the last variable systematically de-allocates it.
So you never can store zero in the last element of an array because when you recall it you have the message "INVALID (I)". What the heck is this logic!?
Find all posts by this user
Quote this message in a reply
03-01-2015, 11:08 PM (This post was last modified: 03-01-2015 11:09 PM by Dieter.)
Post: #6
RE: [HP 35s] Clearing variables
(03-01-2015 10:58 PM)Tugdual Wrote:  Oh my Gosh, indeed!

Bingo!

(03-01-2015 10:58 PM)Tugdual Wrote:  And putting zero is the last variable systematically de-allocate it.
So you never can store zero in the last element of an array because when you recall it you have the message "INVALID (I)". What the heck is this logic!?

It's called dynamic memory allocation, and this feature has been discussed in this very thread, including a solution like storing a non-zero value in the first variable beyond the last one required. Take a look at the suggested code.

The 35s offers a vast amout of memory. It can store more or less equations as well as more or less programs, and so a varying amout of memory that is not used for these is still available. This memory is used for the indirect variables. With an otherwise "empty" calculator there may be 800+ variables. If there was a fixed amount of, say, 500 variables, memory for equations and programs was limited. So it's quite clever to use (and allocate) only the amount of memory that is actually used. This is done by storing a non-zero value in the last variable.

Type CLVARX 000 to clear all indirect variables (except var(0)). You get the maximum amount of memory for programs and equations. Now store 1 into var(20) and var(100). This allocates memory for variables 1 to 100. Store a zero in var(100) and this leaves var(0) to var(20) allocated. The memory previously used for var(21) to var(100) is freed and can be used for other purposes.

Dieter
Find all posts by this user
Quote this message in a reply
03-01-2015, 11:13 PM (This post was last modified: 03-02-2015 08:22 AM by Tugdual.)
Post: #7
RE: [HP 35s] Clearing variables
Thank you for the detailed explanation Dieter. Sorry if this topic has already been discussed.
Find all posts by this user
Quote this message in a reply
Post Reply 




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