The Museum of HP Calculators

HP Forum Archive 17

[ Return to Index | Top of Index ]

I need help: string as variable name on 48G? How?
Message #1 Posted by Reuben on 23 Feb 2007, 12:57 p.m.

I'm working on calorie-counting and meal time tracking capabilities on my 48G, and I've hit a wall:

I need to store a string containing the nutritional data in a variable named by the time of day. I've figured out how to extract the time out of the TSTR cmnd, but it returns a string, which I cannot use as a variable name. Is there any way I can turn this string into a valid variable name? Any Ideas?

I can post code if anyone is interested, but it's pretty laughable, I'd bet.

      
Re: I need help: string as variable name on 48G? How?
Message #2 Posted by Ivan Nejgebauer on 23 Feb 2007, 3:13 p.m.,
in response to message #1 by Reuben

Quote:
I've figured out how to extract the time out of the TSTR cmnd, but it returns a string, which I cannot use as a variable name. Is there any way I can turn this string into a valid variable name?

With the string in level 1, the following snippet

  "'" DUP ROT + SWAP + OBJ\->

will produce the appropriately named variable (algebraic object.)

  OBJ\->
alone would also work, but only if you don't already have such variable in the current directory -- in that case you'd get its contents.

i.

            
Re: I need help: string as variable name on 48G? How?
Message #3 Posted by Reuben on 23 Feb 2007, 8:52 p.m.,
in response to message #2 by Ivan Nejgebauer

Well, that is very clever. Thanks very much!

Now I have another question though... Is there a single command that can add up all the values in a matrix and return 1 result?

Thanks, --Reuben

            
Re: I need help: string as variable name on 48G? How?
Message #4 Posted by James M. Prange (Michigan) on 23 Feb 2007, 10:16 p.m.,
in response to message #2 by Ivan Nejgebauer

Actually, with the string in level 1, the code can be reduced to:

"'" SWAP + OBJ\->
This works because the compiler treats 'string the same as 'string'.

STR\-> could be substituted for OBJ\-> in this case, and should be very slightly faster.

There's also a SysRPL command $>ID that converts a string object to a global name object, and this command could be invoked with a SYSEVAL command, but I don't, offhand, know the entry point address.

Regards,
James


[ Return to Index | Top of Index ]

Go back to the main exhibit hall