HP Forums
HP Prime variables - 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 variables (/thread-254389.html)



HP Prime variables - Davi Ribeiro de Oliveira - 10-30-2013

Hello,

I have two programs and need help in programming. The first is the calculation of total hardness in water. The second is the total number of cations present in this water. As I describe below:

1st program:

EXPORT DTotal;
EXPORT Dureza_Total(Ca,Mg)
BEGIN
DTotal:=Ca*2.49+Mg*4;
END;

2st program:

EXPORT Cátions;
EXPORT TCátions(Fe3,Fe2,H,NH,Na,K,Cu,Zn,Al,Cr,Ca,Mg)
BEGIN
RETURN Dureza_Total(Ca,Mg)+Fe2*1.79+Fe3*2.69+H*50+NH*2.78+Na*2.17+K*1.28+Cu*1.57+Zn*1.53+Al*5.56+Cr*2.89▶Cátions;
END;
END;

When I run this program pops up the error: “TCátios Error: Invalid input”.
If you decrease the amount of variables, for example, from 12 to 10, the program works. This same program in 50 g works without problem. There is no solution or other alternatives?

Thank You

David


Re: HP Prime variables - Geoff Quickfall - 10-30-2013

Make more then one EXPORT command,

that is, break up your variables into two back to back EXPORT statements.

it seems there is an upper limit of the number of variables that one is able to place in and EXPORT (variables) statement. so I do this:

//declare variables.

EXPORT IN,OUT,NUM,EQL,TIM;
EXPORT OFA,OFB,ONA,ONB;
EXPORT TOA,TOB,CAA,CAB;
EXPORT SHA,SHB,LGA,LGB;
EXPORT WTA,WTB,WTC;

i went nuts but there was a reason. Firstly all the variables declared in a single EXPORT did not work. Since I have 5 subroutines i broke up the declaration into 5 EXPORT commands for easy editing. Each command set of variables applies to one subroutine.

cheers, geoff


try:

EXPORT TCátions()
EXPORT (Fe3,Fe2,H,NH,Na,K);
EXPORT (Cu,Zn,Al,Cr,Ca,Mg);


Edited: 30 Oct 2013, 9:11 p.m.


Re: HP Prime variables - cyrille de Brébisson - 10-31-2013

Hello,

There is a limit to the number of parameters that a funciton can take. This limit is 16 parameters.

EXPORT and LOCAL are functions, so they have a 16 parameter limit... However, there is a subtelty there. EXPORT/LOCAL is really
EXPORT(var, value, var, value..., var, value)
this means that 1 EXPORT or LOCAL is limited to 8 variables definitions at a time.

however, USER functions can have up to 16 input parameters, so your function should be OK.

example:

EXPORT Dureza_Total(Ca,Mg)
BEGIN
return Ca*2.49+Mg*4;
END;


EXPORT TCátions(Fe3,Fe2,H,NH,Na,K,Cu,Zn,Al,Cr,Ca,Mg)
BEGIN
RETURN Dureza_Total(Ca,Mg)+Fe2*1.79+Fe3*2.69+H*50+NH*2.78+Na*2.17+K*1.28+Cu*1.57+Zn*1.53+Al*5.56+Cr*2.89;
END;

cyrille


Re: HP Prime variables - Davi Ribeiro de Oliveira - 10-31-2013

Hello my friends:

Thanks for the help, but it didn't work. I wonder if you can't demonstrate with a concrete programme that uses and functions that have more than 12 variables? I will test it and check if it works on my machine.

Thank you in advance.

David