HP Prime: What's wrong with this program? « Next Oldest | Next Newest »

 ▼ BruceTTT Junior Member Posts: 18 Threads: 6 Joined: Aug 2013 10-15-2013, 01:05 AM 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 ▼ cyrille de Brébisson Member Posts: 193 Threads: 10 Joined: Mar 2008 10-15-2013, 02:07 AM 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 ▼ Mike (Stgt) Posting Freak Posts: 858 Threads: 80 Joined: Feb 2009 10-15-2013, 05:09 AM 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 ▼ BruceTTT Junior Member Posts: 18 Threads: 6 Joined: Aug 2013 10-15-2013, 04:14 PM 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. ▼ Marcus von Cube, Germany Posting Freak Posts: 3,283 Threads: 104 Joined: Jul 2005 10-15-2013, 04:46 PM 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. cyrille de Brébisson Member Posts: 193 Threads: 10 Joined: Mar 2008 10-16-2013, 02:00 AM 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 Eddie W. Shore Posting Freak Posts: 764 Threads: 118 Joined: Aug 2007 10-16-2013, 11:14 AM 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.

 Possibly Related Threads... Thread Author Replies Views Last Post Sending little images to the Prime (...and Program name bug?) Erwin Ried 19 3,556 12-10-2013, 05:35 PM Last Post: Erwin Ried Problem with debug HP prime program, somebody help me? Carlos CM (Mexico) 6 1,735 12-05-2013, 03:07 PM Last Post: Carlos CM (Mexico) HP PRIME: APP program code DISAPPEARS !! Joseph Ec 0 521 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 1,128 11-19-2013, 08:59 AM Last Post: Miguel Toro Prime: Program size limited to 64K? Erwin Ried 4 1,029 11-17-2013, 11:42 PM Last Post: Joseph Ec [HP-Prime] Picking elements from a List in a program Jean-Michel 3 963 11-15-2013, 04:16 AM Last Post: dg1969 HP Prime: Recommendation for future RPN Program Mode BruceTTT 3 967 11-13-2013, 10:03 PM Last Post: BruceTTT HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 1,346 11-11-2013, 08:28 PM Last Post: Davi Ribeiro de Oliveira [prime] Insert a breakpoint in a program for debugging ? Olivier Lecluse 3 903 11-09-2013, 09:41 PM Last Post: Joseph Ec HP PRIME: Hide return value from program and swap Edit with Run vrrr 2 835 11-09-2013, 04:04 PM Last Post: vrrr

Forum Jump: