The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

HP-48 indirect addressing of variables
Message #1 Posted by Geir Isene on 8 Aug 2005, 4:41 a.m.

Situation: I have a set of variables (arrays) in a directory and a program that access the variables. The program asks for user input - the name of one of those variables for which part of the content is to be altered.

Problem: How to change the content of a variable whose name is entered by the user?

Additional info: This problem is of course easily handled on an older HP calculator that has indirect addressing (STO IND 01). Little info exists on the net regarding indirect addressing on the 48. None of the links I found where applicable to this specific problem.

Help or pointers is appreciated.

      
Re: HP-48 indirect addressing of variables
Message #2 Posted by Vieira, Luiz C. (Brazil) on 8 Aug 2005, 6:24 a.m.,
in response to message #1 by Geir Isene

Hi, Geir;

all of my answer is based on User RPL instructions, O.K.? I mean, the one you use regularly.

If you are indexing the contents of an array, you could use either PUT or PUTI provided that:

the name of the array in stack level 3 surrounded by ' (ex: 'MTX1'); this is the name you (user) enter
the location where the data will be placed in the array in stack level 2; if it is a one-row or one-column array, than one number is needed; if it is a bidimensional array, than a list like {row,column} is needed;
the data to be entered in stack level 1.

As an example: suppose you need to enter the number 10 in row 2, column 3 of MTX1 by using PUT. The followin is the stack contents representation:

4:
3:       'MTX1'
2:        {2,3}
1:           10
Than you just need to execute PUT.

Remember that all of the three objects above are removed from the stack after PUT is executed. PUTI automatically increments the index in level 2 and keeps both the name of the array (level 2) and the updated index (level 1) in the stack. This has to purpose to be an aid for successive input.

Hope this helps.

Luiz (Brazil)

Edited: 8 Aug 2005, 6:26 a.m.

            
Re: HP-48 indirect addressing of variables
Message #3 Posted by Geir Isene on 8 Aug 2005, 7:11 a.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Yes, this helped.

Now I'd like to store the name 'MTX1' in a variable for later retrieval. How do I do that? As I store 'MTX1' in , let's say a variable named 'VAR1', any time I want to retrieve the variable name, it is automatically evaluated - I just want the name of tha variable back to further play with it.

Any way to convert "MTX1" to 'MTX1'?

                  
Re: HP-48 indirect addressing of variables
Message #4 Posted by Vieira, Luiz C. (Brazil) on 8 Aug 2005, 12:30 p.m.,
in response to message #3 by Geir Isene

Hi, Geir;

I'm not sure about what input command (there are many) you are actually using to capture the variable name (in this case, MTX1). BTW, which HP48 are you using? The S-series, the earlier G-series or the new GII?

If you have one of the earlier G-series model, the complement to the User's Manual (AUG, or Advanced User's Guide) has references to all available UserRPL commands/functions plus a friendly explanation on how to use the various input resources. I'm not sure about the best one in your case, but the INFORM is the most resourcefull of them. Anyway, you can check for input 'sintax' and data format by specifying some additional parameters, and then your name will be placed in the stack as 'MTX1' instead of "MTX1".

There is another handy command in the HP48, the OBJ->, that returns an object within another object. It is meant to 'disassemble' complex objects into elementary objetcs (a list into its individual objects, an array into its numbers, a program into its comands, etc.). I'm not sure if the OBJ-> actually evaluates the returned object(s); if so, any exisitng object named MTX1 in the current directory or in any subdirectory associated with the current directory will be returned and evaluated (I'm not so sure about this, should test or read about).

Anyway, you should try using the 'poor man' converter: add one "'" to both the head and tail of the name. Than you have "'MTX1'" instead of "MTX1". Now you use OBJ-> (or STR->) and the name 'MTX1' is returned, even if there is a variable named MTX1 in the same conditions explained below.

I'd try to go ahead with some experiences. Please, let us know what HP48 you have, so we can give you better guidance (by 'we' I mean anyone in this forum, OK?).

Best regards.

Luiz (Brazil)

Edited: 8 Aug 2005, 12:33 p.m.

                        
Re: HP-48 indirect addressing of variables
Message #5 Posted by Geir Isene on 9 Aug 2005, 2:52 a.m.,
in response to message #4 by Vieira, Luiz C. (Brazil)

Thank you.

Quote:
Anyway, you should try using the 'poor man' converter: add one "'" to both the head and tail of the name. Than you have "'MTX1'" instead of "MTX1". Now you use OBJ-> (or STR->) and the name 'MTX1' is returned, even if there is a variable named MTX1 in the same conditions explained below.

This did the trick in my program. Great.

Info: I have a G+ and a GX.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall