Post Reply 
Use the appropriate "Ans" in a program in HOME or CAS
11-14-2015, 05:08 PM
Post: #1
Use the appropriate "Ans" in a program in HOME or CAS
Hello friends!

My question will look simple but after reading the user's manual and browse this site, I haven't found an answer in the last days I searched. So I am asking help here, even if I will probably look no good.

I've made a few functions (programs) in my HP Prime in the last years and many are based on the last answer computed. In the program if I use the variable "Ans", it will always take the last value from the HOME, even if I am in CAS. And if I use the variable "CAS.Ans", it will use the last result in CAS but it will also use it even if I am in HOME.

Is there a way I can simply adapt my program so it will use the appropriate last answer according to the view I am in so I could still use the same program? How could I programmatically determine in which mode or which view I am so I'll use the correct answer?

I am 90% of the time in HOME but sometimes I forgot I am in CAS, call my program and then did not realize but make bad calculation because it did not use the last answer I see in CAS but the one from HOME... If I could adapt the program, it would avoid these stupid mistake.

I've seen many variables to determine few other things mode and setup, but I am sorry, I did not figure that one for HOME or CAS.

Please, be kind and I don't laugh too much at me. :-)

Denis Bisson
Little electronic technician loving calculators
Visit this user's website Find all posts by this user
Quote this message in a reply
11-16-2015, 06:33 AM
Post: #2
RE: Use the appropriate "Ans" in a program in HOME or CAS
Hello,

Sorry, but at this point in time, there is no way to detect if you are in home or CAS and therefore no way to choose the right Ans..

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
11-16-2015, 03:17 PM
Post: #3
RE: Use the appropriate "Ans" in a program in HOME or CAS
(11-16-2015 06:33 AM)cyrille de brébisson Wrote:  ...
Sorry, but at this point in time, there is no way to detect if you are in home or CAS and therefore no way to choose the right Ans..
...

Well... I might have found a way to doit. You might not like it but me, I will use it. It seems to basically works from the last thirty minutes tests I've done.

Here is the trick: when we're in CAS, in the top left of the screen it shows in WHITE the word "CAS".

So I though about reading back the pixel at coordinates (15,13) which is in the "C" of CAS. If this pixel is WHITE, then we're in CAS. If this pixel is not WHITE then we're not in CAS.

So by having a routine checking the color of that pixel I can determine if I am in CAS or not, and so, take from the start the appropriate answer (CAS.Ans or Ans).

I tested it with various settings like both color theme "dark" and "light", different color for highlight menu, the three font size small, medium and large, etc. It seems to work in every situations. Ha! Ha!

At least, it's better than having nothing.

Sounds good? :-)

Dennis.

Code:

EXPORT MyCalc_isCAS
BEGIN 
 LOCAL MyTestPixels; //Looks like we need to go through a variable though.
 MyTestPixels:=GETPIX_P(15,13);
 if MyTestPixels=RGB(255,255,255) THEN
  RETURN 1;
 ELSE
  RETURN 0;
 END;
END;

Denis Bisson
Little electronic technician loving calculators
Visit this user's website Find all posts by this user
Quote this message in a reply
11-16-2015, 06:07 PM
Post: #4
RE: Use the appropriate "Ans" in a program in HOME or CAS
(11-16-2015 03:17 PM)explorerchess Wrote:  
(11-16-2015 06:33 AM)cyrille de brébisson Wrote:  ...
Sorry, but at this point in time, there is no way to detect if you are in home or CAS and therefore no way to choose the right Ans..
...
Well... I might have found a way to doit.

There is always a way...

I love your idea, especially because even the designers of the Prime didn't think of it. Smile

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
11-16-2015, 06:24 PM
Post: #5
RE: Use the appropriate "Ans" in a program in HOME or CAS
(11-16-2015 06:07 PM)Marcus von Cube Wrote:  There is always a way...
I love your idea, especially because even the designers of the Prime didn't think of it. Smile

Hi!

I don't know if there is always a way, but I am glad it seems to work!

I've simplified it a few minutes ago (see the following) and now I am using it that way.

Thanks.

Dennis.

Code:

EXPORT MyCalc_isCAS
BEGIN 
 RETURN (GETPIX_P(15,13)=#FFFFFFh);
END;

Denis Bisson
Little electronic technician loving calculators
Visit this user's website Find all posts by this user
Quote this message in a reply
11-16-2015, 08:17 PM
Post: #6
RE: Use the appropriate "Ans" in a program in HOME or CAS
Bonjour
Super, une nouvelle fonction qui améliore la Hp Prime.
Merci.

Hello
Super , a new function that improves Hp Prime.
Thank you.

Sorry for my english
Find all posts by this user
Quote this message in a reply
11-17-2015, 03:05 AM
Post: #7
RE: Use the appropriate "Ans" in a program in HOME or CAS
I were going to propose to use some CAS only behaviour of command or CAS only command to do the same.

That pixel color lookup method is really nice!
Find all posts by this user
Quote this message in a reply
11-17-2015, 03:21 AM
Post: #8
RE: Use the appropriate "Ans" in a program in HOME or CAS
Hi!

(11-17-2015 03:05 AM)Vtile Wrote:  I were going to propose to use some CAS only behaviour of command or CAS only command to do the same.
Oh! If you find one. Let it me know. Even if it takes more lines, it might be more reliable than this. That's what I was trying to do during free time last week. I was trying things like:
(2^40+1)-2^40. When we do it in the command line in HOME this gives 0 and when we do it in CAS it gives 1. So I though by programming it would work but no... When invoking the program even from CAS it would give 0. So I was about to give up, looking at this "CAS" sign in top left telling to myself it was laughing at me and suddenly I said "Wait a minute... I see you...". Ha! Ha!

(11-17-2015 03:05 AM)Vtile Wrote:  That pixel color lookup method is really nice!
Yeah... Not really elegant, we would not go to the moon with that, but for me, it will do it until something better. Ha! Ha!

Dennis.

Denis Bisson
Little electronic technician loving calculators
Visit this user's website Find all posts by this user
Quote this message in a reply
11-17-2015, 06:27 AM
Post: #9
RE: Use the appropriate "Ans" in a program in HOME or CAS
Hello,

I love your solution, great thinking!

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




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