[HP 35s] Clearing variables - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: [HP 35s] Clearing variables (/thread-3233.html) |
[HP 35s] Clearing variables - Tugdual - 03-01-2015 06:00 PM 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? RE: [HP 35s] Clearing variables - Dieter - 03-01-2015 09:09 PM (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 RE: [HP 35s] Clearing variables - Tugdual - 03-01-2015 09:47 PM (03-01-2015 09:09 PM)Dieter Wrote: CLVARX 000 followed by 0 STO I STO(I).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? RE: [HP 35s] Clearing variables - Dieter - 03-01-2015 09:58 PM (03-01-2015 09:47 PM)Tugdual Wrote: Thank you Dieter, I guess I didn't word my question correctly. 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 RE: [HP 35s] Clearing variables - Tugdual - 03-01-2015 10:58 PM (03-01-2015 09:58 PM)Dieter Wrote:Oh my Gosh, indeed!(03-01-2015 09:47 PM)Tugdual Wrote: Thank you Dieter, I guess I didn't word my question correctly. 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!? RE: [HP 35s] Clearing variables - Dieter - 03-01-2015 11:08 PM (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. 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 RE: [HP 35s] Clearing variables - Tugdual - 03-01-2015 11:13 PM Thank you for the detailed explanation Dieter. Sorry if this topic has already been discussed. |