HP Forums
The why is there a syntax error thread - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: The why is there a syntax error thread (/thread-712.html)



The why is there a syntax error thread - DeucesAx - 02-19-2014 05:13 AM

This thread is supposed to helpful for everyone who needs a quick help for a syntax error he can not resolve by himself. If you do come up with an answer for your own problem, it would be nice to post it here as well.


Ill start: Wink

unfortunately I am having trouble with a simple addition. I try to calculate "xmax=xmin+ymax" (non-sensical, just to get me started).

I tried:

EXPORT int2(xmin,xmax,ymin,yreal,ymax)
BEGIN
local xmin,xmax,ymin,ymax,xreal;
PRINT("oashio")
xmax:=xmin+ymax;
END;


and:

EXPORT int2(xmin,xmax,ymin,yreal,ymax)
BEGIN
local xmin,xmax,ymin,ymax,xreal;
PRINT("oashio")
xmin+ymax▶xmax;
END;


Similar to what's shown here
What's wrong?


RE: The why is there a syntax error thread - DeucesAx - 02-19-2014 05:23 AM

the ";" after my print was missing. Geez.


RE: The why is there a syntax error thread - DeucesAx - 02-19-2014 06:12 AM

what's wrong with this?


export int2(xmin,xmax,ymin,ymax,yreal)
BEGIN
local xmin,xmax,ymin,ymax,xreal,yreal;
xreal:=xmin+((yreal-ymin)/(ymax-ymin));
print(xreal);
END;


RE: The why is there a syntax error thread - patrice - 02-19-2014 06:44 AM

You don't need to declare LOCAL variables that are already declared as function parameters.
Code:
export int2(xmin,xmax,ymin,ymax,yreal)
BEGIN
local xreal;
xreal:=xmin+((yreal-ymin)/(ymax-ymin));
print(xreal);
END;
and use
RETURN(xreal);
for the answer


RE: The why is there a syntax error thread - DeucesAx - 02-19-2014 07:19 AM

(02-19-2014 06:44 AM)patrice Wrote:  You don't need to declare LOCAL variables that are already declared as function parameters.
Code:
export int2(xmin,xmax,ymin,ymax,yreal)
BEGIN
local xreal;
xreal:=xmin+((yreal-ymin)/(ymax-ymin));
print(xreal);
END;
and use
RETURN(xreal);
for the answer
Awesome, thank you. Is there a way I can have the result copied to the cas screen? I know I can get that with typing int2(...) in cas, but I love the easy input box so I don't need to remember the order of the input parameters.
Also, can I copy program names to the cas screen from the catalog?


RE: The why is there a syntax error thread - Han - 02-19-2014 02:58 PM

If I understand your question correctly, you should be able to access the programs (while in CAS view) via the Toolbox. Just select the User menu and you'll see a list of programs from which to choose int2().