HP Forums
Use the appropriate "Ans" in a program in HOME or CAS - 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: Use the appropriate "Ans" in a program in HOME or CAS (/thread-5126.html)



Use the appropriate "Ans" in a program in HOME or CAS - explorerchess - 11-14-2015 05:08 PM

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. :-)


RE: Use the appropriate "Ans" in a program in HOME or CAS - cyrille de brébisson - 11-16-2015 06:33 AM

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


RE: Use the appropriate "Ans" in a program in HOME or CAS - explorerchess - 11-16-2015 03:17 PM

(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;



RE: Use the appropriate "Ans" in a program in HOME or CAS - Marcus von Cube - 11-16-2015 06:07 PM

(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


RE: Use the appropriate "Ans" in a program in HOME or CAS - explorerchess - 11-16-2015 06:24 PM

(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;



RE: Use the appropriate "Ans" in a program in HOME or CAS - Tyann - 11-16-2015 08:17 PM

Bonjour
Super, une nouvelle fonction qui améliore la Hp Prime.
Merci.

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


RE: Use the appropriate "Ans" in a program in HOME or CAS - Vtile - 11-17-2015 03:05 AM

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!


RE: Use the appropriate "Ans" in a program in HOME or CAS - explorerchess - 11-17-2015 03:21 AM

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.


RE: Use the appropriate "Ans" in a program in HOME or CAS - cyrille de brébisson - 11-17-2015 06:27 AM

Hello,

I love your solution, great thinking!

Cyrille