HP Prime: What's wrong with this program? - 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: HP Prime: What's wrong with this program? (/thread-252953.html) HP Prime: What's wrong with this program? - BruceTTT - 10-15-2013 Anyone have an idea why I keep getting a syntax error with: EXPORT Solver(a,b,c) BEGIN RETURN solve(a*x*x+b+x+c=0,x); END; 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 Re: HP Prime: What's wrong with this program? - cyrille de BrĂ©bisson - 10-15-2013 Hello, 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)... Cyrille Re: HP Prime: What's wrong with this program? - Mike (Stgt) - 10-15-2013 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) Ciao.....Mike Re: HP Prime: What's wrong with this program? - BruceTTT - 10-15-2013 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? Thanks! Bruce Edited: 15 Oct 2013, 4:22 p.m. Re: HP Prime: What's wrong with this program? - Marcus von Cube, Germany - 10-15-2013 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. Re: HP Prime: What's wrong with this program? - cyrille de BrĂ©bisson - 10-16-2013 Hello >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. Cyrille Re: HP Prime: What's wrong with this program? - Eddie W. Shore - 10-16-2013 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: EXPORT SOLVER(A,B,C) BEGIN RETURN CAS.cZeros(A*X*X+B*X+C,X); END; Edited: 16 Oct 2013, 11:15 a.m.