HP Forums
Help with a program - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Help with a program (/thread-17164.html)

Help with a program - matalog - 06-24-2021 10:56 PM

I have been trying to make a program to leave the leading zeroes on a number, just to get a quick look at them, and experiment with the calculator.

I have got this far, and it seems that at the first reference to Ans() is being taken from Home mode, not CAS, and the second use of Ans() is being taken from CAS. So, if the number in history in home screen, and CAS are of the same order, then it actually works fine.

Can anyone offer any guidance as to how I can get it to correctly use the number in the CAS history, to set the length

LOCAL f:=STRING(Ans(1));
LOCAL g:="";
LOCAL h:="";
LOCAL i:=0;

RE: Help with a program - cext104 - 09-26-2021 09:25 PM

Maybe you should END your program

RE: Help with a program - pinkman - 09-27-2021 03:53 PM

Your program is a Home program, not a CAS program.
I guess that when it calls Ans (1st time) it gets the Home Ans, but the second time it calls Ans from the format() function, which is a CAS function, thus leading to get Ans from CAS.

If this is true it means you'll have erratic behaviors because of confusing Home and CAS.
You should declare your program as a CAS program and run it from the CAS View.

RE: Help with a program - Albert Chan - 09-27-2021 05:24 PM

Hi, pinkman

Your guess confirmed. With CAS Ans = 0

HOME> id(Ans)       → 0

But, we should seriously considered this behavior a bug.
Ans is really a shorthand for "previous answer".
It should be related to where the environment was called from.

For above example, HOME> id(Ans) should return 1