HP Forums
Program without using 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: Program without using variables? (/thread-20587.html)



Program without using variables? - DM48 - 10-03-2023 09:04 PM

I am going down a few rabbit holes at the moment and I am exploring the idea of how to take numbers from the stack and use them in a program without storing them to a variable.

Yes, I know about local variables -> a b /<< a b + />> and I use them a lot.

The program I am writing now has six soft menu keys. 1 - 4 store a number from the stack into a variable. 5 executes the program. 6 cleans the variables from memory when I am done evaluating different numbers.

My first thought was to use a list. I place a list on the stack and when I press soft menu keys 1-4 it would store that number in the list on the stack in the appropriate order. This worked well, minus having to have the list on the stack.

Is there a different way to store variables without committing them to memory?


RE: Program without using variables? - mfleming - 10-04-2023 02:39 AM

argc, argv[ ] ?


RE: Program without using variables? - MNH - 10-04-2023 12:29 PM

Try storing numbers in a matrix.


RE: Program without using variables? - MNH - 10-04-2023 05:53 PM

Find CMAT on hpcalc.org.

"CMAT is an HP48 program for performing operations on columns of a
matrix. CMAT iterates over each row of the matrix, treating the n
columns of the matrix as if they were variables named C1, C2, ...
Cn, or, optionally, as if they were named with user-specified
names."


RE: Program without using variables? - DM48 - 10-04-2023 09:12 PM

(10-04-2023 05:53 PM)MNH Wrote:  Find CMAT on hpcalc.org.

"CMAT is an HP48 program for performing operations on columns of a
matrix. CMAT iterates over each row of the matrix, treating the n
columns of the matrix as if they were variables named C1, C2, ...
Cn, or, optionally, as if they were named with user-specified
names."

Does a matrix allow (x,y) points to be stored in one position?

What do you use as a data collector these days? I used an HP48GX like most everyone in the early 2000s. I still have my gun and 48 with cards.


RE: Program without using variables? - John Keith - 10-04-2023 10:26 PM

(10-04-2023 09:12 PM)DM48 Wrote:  Does a matrix allow (x,y) points to be stored in one position?

Yes, if you use a complex matrix. The commands R\->C and C\->R can be used to combine two real matrices into a complex matrix and vice versa.


RE: Program without using variables? - DM48 - 10-05-2023 12:38 AM

(10-04-2023 10:26 PM)John Keith Wrote:  
(10-04-2023 09:12 PM)DM48 Wrote:  Does a matrix allow (x,y) points to be stored in one position?

Yes, if you use a complex matrix. The commands R\->C and C\->R can be used to combine two real matrices into a complex matrix and vice versa.

Fascinating!


RE: Program without using variables? - MNH - 10-05-2023 11:38 AM

(10-04-2023 09:12 PM)DM48 Wrote:  What do you use as a data collector these days?

Topcon FC-5000 with MAGNET Field software.


RE: Program without using variables? - MNH - 10-05-2023 11:47 AM

(10-04-2023 10:26 PM)John Keith Wrote:  Yes, if you use a complex matrix.

Could DM48 use a 3-D vector to store (x,y,z) points?


RE: Program without using variables? - John Keith - 10-05-2023 02:51 PM

(10-05-2023 11:47 AM)MNH Wrote:  Could DM48 use a 3-D vector to store (x,y,z) points?

Sure, or an n X 3 matrix to store a collection of points. The 48G has commands for extracting, inserting and replacing rows so that should be fairly easy and efficient.


RE: Program without using variables? - MNH - 10-07-2023 02:26 AM

This post sparked a memory of a program that I used to use.

[attachment=12622]

Please go to page forty-one of the manual. You will see that the author of the program uses a matrix to store points.

[attachment=12623]


RE: Program without using variables? - David Hayden - 10-20-2023 01:04 PM

Quote:Is there a different way to store variables without committing them to memory?
Keep in mind that the numbers are in memory whether they're on the stack or in a variable. The variable takes a little more space for the name and some overhead.

What you're doing sounds to me like a classic example of what directories for are. Create a directory for the program to run in. Store the variables in that directory. I don't recommend putting them on the stack because the user might modify the stack between pressing the soft keys.