The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP Prime variables
Message #1 Posted by Davi Ribeiro de Oliveira on 30 Oct 2013, 8:43 p.m.


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


Re: HP Prime variables
Message #2 Posted by Geoff Quickfall on 30 Oct 2013, 9:09 p.m.,
in response to message #1 by Davi Ribeiro de Oliveira

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.


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


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
Message #3 Posted by Davi Ribeiro de Oliveira on 31 Oct 2013, 9:06 p.m.,
in response to message #2 by Geoff Quickfall

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.


Re: HP Prime variables
Message #4 Posted by cyrille de Brébisson on 31 Oct 2013, 2:24 a.m.,
in response to message #1 by Davi Ribeiro de Oliveira


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.


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;


[ Return to Index | Top of Index ]

Go back to the main exhibit hall