Post Reply 
how to know if prog was started from home or cas ?
03-04-2018, 10:11 AM (This post was last modified: 03-04-2018 11:22 AM by primer.)
Post: #1
how to know if prog was started from home or cas ?
Hello,
I would like to know if the current program have been started from Home or from Cas ?
I need that in order to use the right "Ans" or "CAS.Ans" function in a user key prog.
Thank you.

primer
Find all posts by this user
Quote this message in a reply
03-04-2018, 10:49 AM
Post: #2
RE: how to know if prog was started from home or cas ?
I think that it is not possible to do that, I also look for something similar when programming Applications and want to go to Start or CAS with STARTVIEW, but it is not possible to select between those views.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-05-2018, 12:22 AM
Post: #3
RE: how to know if prog was started from home or cas ?
One possible idea is to capture the top left corner of the screen at the start of the program and see if the "CAS" pixels are showing.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-05-2018, 12:58 AM (This post was last modified: 03-05-2018 01:05 AM by Carlos295pz.)
Post: #4
RE: how to know if prog was started from home or cas ?
(03-05-2018 12:22 AM)Han Wrote:  One possible idea is to capture the top left corner of the screen at the start of the program and see if the "CAS" pixels are showing.

Indisputably xD
Code:
KEY K_9()
BEGIN
  IF GETPIX_P(17,10)=GETPIX_P(17,16) THEN
    ""+CAS.Ans
  ELSE
    ""+Ans
  END
END;

I still wait for my STARTVIEW with address to Home and CAS separately.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-05-2018, 05:47 AM
Post: #5
RE: how to know if prog was started from home or cas ?
Hello,

I have not tried it, but it MIGHT be possible to create 2 "commands", in the same program, with the same name, one in CAS mode, one in Home mode (it might be nessecary to play with the order of declaration to make it work, doing the CAS one first might work).
Thus, when calling from Home, the home one would be called, and when calling from CAS the cas one could be called (because each environement gives preference to his version).
Then, they could both call the common funciton (which would have a slightly different name).

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
03-05-2018, 05:54 AM (This post was last modified: 03-05-2018 07:18 AM by toshk.)
Post: #6
RE: how to know if prog was started from home or cas ?
i think the easy way is to pick the different behaviors in results of a common function under CAS and Home;
eg;
Home;
TYPE(coeff("y","y"))==4;
CAS
TYPE(coeff("y","y"))==6;
and set Flag accordingly;

#cas
ccc():=
BEGIN
BB:=coeff(x/7); // under HOME [0.142857142857,0] and CAS [1/7,0] and denominator of the first element will determine where you are
BC:=CAS.coeff("x/7","'x'"); //exploit a bug of the function when numerator is available in the function "x/7" it does not executes at all. But it should evaluate under Home and fails under CAS
BD:=TYPE(BB);
BE:=denom(BB(1));
END;
#end
Find all posts by this user
Quote this message in a reply
03-05-2018, 04:56 PM (This post was last modified: 03-05-2018 04:58 PM by primer.)
Post: #7
RE: how to know if prog was started from home or cas ?
(03-05-2018 05:54 AM)toshk Wrote:  i think the easy way is to pick the different behaviors in results of a common function under CAS and Home;
eg;
Home;
TYPE(coeff("y","y"))==4;
CAS
TYPE(coeff("y","y"))==6;
and set Flag accordingly;

sorry it does not work in a program context.
for example :

Code:

KEY KS_Abc()
BEGIN
local a:=TYPE(coeff("y","y"));
IF a==4 THEN 
 MSGBOX("from Home");
ELSE
 MSGBOX("from CAS");
END;
END;
Will always popup "from Home" (press [shift]+[a b/c])
because the program itself run from the Home language...

I think we really need to have few flags to know the context of program run.
I even don't ask to interact with that context (...it could be next step) but at least to know :
  • Do I run from Home or CAS context ? (important to know if I must use Ans or CAS.Ans)
  • Does the user was in entry mode or Not ? entry mode = edit line were open (important in the scope of user Key too)
These two are important to deal with user keys properly.
Thanks.
Fabien.

primer
Find all posts by this user
Quote this message in a reply
03-05-2018, 05:12 PM (This post was last modified: 03-06-2018 09:02 AM by StephenG1CMZ.)
Post: #8
RE: how to know if prog was started from home or cas ?
An obvious idea, given that description, which no one has mentioned - so I guess it won't work -
Can you do something, and then check whether it is Ans or CAS.Ans that has changed?

That way, "do something" can return the same value in CAS and Home - you do not depend on the two answers being different - all you are checking is where the answer is placed.

Stephen Lewkowicz (G1CMZ)
https://my.numworks.com/python/steveg1cmz
Visit this user's website Find all posts by this user
Quote this message in a reply
03-05-2018, 07:37 PM
Post: #9
RE: how to know if prog was started from home or cas ?
The game here is exploiting the Oddball; Choose your poison and antidote
Code:

#CAS
Abc()
BEGIN
local a:=coeff(y/7,y);
IF denom(a[1])==1 THEN 
 MSGBOX("from Home");
ELSE
 MSGBOX("from CAS");
END;
END;
#end
Find all posts by this user
Quote this message in a reply
03-06-2018, 02:55 AM
Post: #10
RE: how to know if prog was started from home or cas ?
(03-05-2018 05:54 AM)toshk Wrote:  #cas
ccc():=
BEGIN
BB:=coeff(x/7); // under HOME [0.142857142857,0] and CAS [1/7,0] and denominator of the first element will determine where you are
BC:=CAS.coeff("x/7","'x'"); //exploit a bug of the function when numerator is available in the function "x/7" it does not executes at all. But it should evaluate under Home and fails under CAS
BD:=TYPE(BB);
BE:=denom(BB(1));
END;
#end

Oooh! That's dangerous with a system that is still evolving. When the bug is fixed, your program won't work anymore. Now in the case of the 50g or 35s, it would be safe to use a known bug since they're frozen in time and existing bugs will never be fixed.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 




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