Post Reply 
Help with a program, getting Ans to get info from CAS not Home.
06-25-2021, 08:26 AM
Post: #1
Help with a program, getting Ans to get info from CAS not Home.
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 told the Prime I was setting up a NEW program with CAS activated, so I assumed it would read from the CAS Ans() history.

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. It is degigned to read the last 2 digits of a number in memory, like 2.36E-25, it would read only the 25 and then store that as a string in g and a number in i.

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

Code:
EXPORT CDEC()
BEGIN
LOCAL f:=STRING(Ans(1));
LOCAL g:="";
LOCAL h:="";
LOCAL i:=0;
g:=RIGHT(f,2);
i:=EXPR(g);
i:=i+2;
h:="f"+STRING(i);
MSGBOX(format(Ans(1),h));
END;
Find all posts by this user
Quote this message in a reply
06-25-2021, 09:39 AM
Post: #2
RE: Help with a program, getting Ans to get info from CAS not Home.
(06-25-2021 08:26 AM)matalog Wrote:  I told the Prime I was setting up a NEW program with CAS activated, so I assumed it would read from the CAS Ans() history.

Well, your program is a PPL program, not a CAS program which should start with #cas and has a different syntax for the declaration of the program name.

I recommend the reading of the HP-Prime: Documentation & Tutorials on this forum as you'll find a lot of information not available in the Prime manual, including for CAS programs: HP Prime CAS programming

(06-25-2021 08:26 AM)matalog Wrote:  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

You may read this thread about the difference between the Home Ans and the CAS Ans.

To ensure you access the CAS Ans you can use CAS.Ans instead of Ans(1) in your program.

But if you want to access either the Home Ans or the CAS Ans depending from where you are running your program you need a way to know if you launched your program from Home or from CAS. I'm not aware of a clean way to get this information in a PPL program.
Here is how I've implemented this in Base48 and Units48 by checking the CAS indicator on the screen as a workaround:
Code:
CASMode()
BEGIN
 GETPIX_P(16,10)==#FFFFFFh;
END;
[...]
a:= IFTE(CASMode(), CAS.Ans, Ans); // IF CAS, then import CAS.Ans, else Home Ans
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)