![]() |
Need CAS help - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Need CAS help (/thread-255667.html) |
Need CAS help - Michael de Estrada - 11-12-2013 Using CAS in programs is tricky. I need to store a value inside a CAS variable inside a program using variables local to the program or passed as parameters to the program, I've tried using the CAS command to no avail, since it evaluates to zero.
Assuming aaaa is a CAS variable and A,B,C are variables than have been assigned non-zero numeric values CAS("aaaa:=A*B*C") stores zero in aaaa, but CAS("aaaa:=2") stores the number 2. Also, if I store 2 in aaaa directly in CAS, it successfully retains this value in the program. So, basically, there seems to be no way to store computed values in a program in a CAS variable.
Re: Need CAS help - Han - 11-12-2013 Quote: You keep forgetting that the CAS currently does not recognize local variables. So CAS("aaaa:=A*B*C") actually creates a GLOBAL variable called aaaa and this GLOBAL variable will have the correct value. However, since local variables have higher priority, the LOCAL variable aaaa still has a value of 0 and that is what is visible to the program. So to do what you want, use: aaaa:=CAS("A*B*C"); which takes the result of the CAS calculation A*B*C and saves it into the LOCAL variable aaaa.
Here's that old thread again :-) Edited: 12 Nov 2013, 8:42 p.m.
Re: Need CAS help - Michael de Estrada - 11-12-2013 Thanks, but that doesn't solve my problem. It just creates a nul value in aaaa. I need this to be a CAS value not a local value. Oh dear, now my calculator has crashed again, and I've lost my CAS history, variables, settings... What a pain this thing is to do anything.
Edited: 12 Nov 2013, 9:26 p.m.
Re: Need CAS help - Han - 11-12-2013 Quote: Are the variables aaaa, A, B,and C all global variables? or are they all local variables? or a mix? This makes a big difference. If you are using A, B, and C as local variables, then that would not work in CAS. In general, I try to avoid using the built-in variables as local variables. Are you using EXPORT on aaaa or did you leave that out? I am able to create a CAS variable just fine with
EXPORT TEST()
When I go into the memory browser, I see aaaa listed as a real value under the CAS variables. Its value is non-zero, provided that my A, B, and C built-in variables are non-zero. Perhaps there are details I am not understanding about your code. Edited: 12 Nov 2013, 10:02 p.m.
Re: Need CAS help - Michael de Estrada - 11-12-2013 I'm afraid my calculator is broken again and may need another re-format, so I may just throw it out with tomorrow's trash pickup and cut my losses.
Re: Need CAS help - cyrille de Brébisson - 11-13-2013 Hello,
export test(A,B,C) seems to work. But I am not sure if it will work on your earlier revision. Can you please try it? Else, you might want to try
export test(A,B,C)
Cyrille
Re: Need CAS help - Michael de Estrada - 11-13-2013 Well, I've finally gotten everything to work, but it hasn't been easy. As you can see, my dilemma was getting CAS and non-CAS stuff to work together harmoniously inside a program. I'm creating and solving a symbolic expression, which contains coefficients that are evaluated at runtime to be used in the construction of the expression. All of this would be so much easier if there were some sort of CAS switch that could be enabled inside a program at runtime, i.e. CASmode(On || Off). Anyways, here's the code I've written; note the complete absence of LOCAL variables: Program Beam
//Eigenvalue solver for root based on guess "G"
Edited: 13 Nov 2013, 3:51 p.m.
|