HP Prime: What's wrong with this program?


Anyone have an idea why I keep getting a syntax error with:

EXPORT Solver(a,b,c)

RETURN solve(a*x*x+b+x+c=0,x);


Other things I've tried:

RETURN "solve(a*x*x+b+x+c=0,x)";
RETURN CAS.solve(a*x*x+b+x+c=0,x);
RETURN "CAS.solve(a*x*x+b+x+c=0,x)";
RETURN solve(a*x*x+b+x+c=0);

and many variations of uppercase and lowercase variables, etc.

TIA, Bruce



At the root cause of the problem is the fact that the CAS does not have access to your local variables. Basicaly, we did everything we could to have the CAS and the numeric world as integrated as possible, however, local variable is something that we did not manage to do 100%

Yours is a case where that fact pops up to the surface...

Here is how you could do what you want:

in CAS, do:
Solver(a,b,c):=BEGIN solve(a*x*x+b+x+c=0,x); END;
This will create a CAS progam (which can be called from numerical)...



In addition, you probably wanted to solve a*x*x+b*x+c, not a*x*x+b+x+c = x*(a*x+1)+(b+c)



Correct, that was a typo on my part, supposed to be a version of the quadratic formula. Because the "syntax error" is kind of vague, I was trying anything (including modifying the formula) to get it to work.

So if understand correctly, I cannot use CAS.built-in-function from within a program that uses local variables?

And will the Solver(a,b,c):=... example you listed work from within RPN/Home?



Edited: 15 Oct 2013, 4:22 p.m.


From my understanding, there a two distinct types of programs, CAS and standard, which behave differently. The CAS programs need to be created form the command line but can be edited in the program editor later without loosing their capabilities.

Tim, Cyrille, Bernard, why isn't CAS the default mode for programs? If this has disadvantages it should be possible to create a CAS program within the editor or change its status (CAS/non CAS) later.



>So if understand correctly, I cannot use CAS.built-in-function from within a program that uses local variables?

Yes and no.

The Numerical system will try to make it work. and replace local variables with their values before CAS calls. This works in simple cases, however it does not work in all cases.



The zeros and cZeros commands work in regular programming and in the Home Modes. In Home and the regular programming editor, the "CAS." prefix must accompany zeros and cZeros. (CAS.zeros, CAS.cZeros)

cZeros allow for complex roots. The following program can be used universally:





Edited: 16 Oct 2013, 11:15 a.m.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Sending little images to the Prime (...and Program name bug?) Erwin Ried 19 1,831 12-10-2013, 05:35 PM
Last Post: Erwin Ried
  Problem with debug HP prime program, somebody help me? Carlos CM (Mexico) 6 876 12-05-2013, 03:07 PM
Last Post: Carlos CM (Mexico)
  HP PRIME: APP program code DISAPPEARS !! Joseph Ec 0 268 11-25-2013, 11:35 AM
Last Post: Joseph Ec
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 580 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  Prime: Program size limited to 64K? Erwin Ried 4 542 11-17-2013, 11:42 PM
Last Post: Joseph Ec
  [HP-Prime] Picking elements from a List in a program Jean-Michel 3 501 11-15-2013, 04:16 AM
Last Post: dg1969
  HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 483 11-13-2013, 10:03 PM
Last Post: BruceTTT
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 673 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  [prime] Insert a breakpoint in a program for debugging ? Olivier Lecluse 3 433 11-09-2013, 09:41 PM
Last Post: Joseph Ec
  HP PRIME: Hide return value from program and swap Edit with Run vrrr 2 475 11-09-2013, 04:04 PM
Last Post: vrrr

Forum Jump: