HP Forums

Full Version: Help with a program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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;
Maybe you should END your program
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.
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
Reference URL's