Showing results for 
Search instead for 
Did you mean: 
Level 1
10 3 0 0
Message 1 of 2
Flag Post

Programming unts and returing 2 values

HP Recommended
HP Prime
Microsoft Windows 10 (64-bit)



I am trying to return the value of x and y in my program


The calculator returns this...



another thing I would like to do is add some note about what each input is in the same window as the program perameters and add a choice for units. for example you have a drop down for the input unit and a drop down for output, say input p in bar but output in psi.  not sure if this is possible or easier a different way.


0 Kudos
Level 6
Level 6
252 251 42 77
Message 2 of 2
Flag Post
HP Recommended



2 questions here.

The first one, about return values.

"Program" are mathematical functions. They take 0 to 15 arguements and return one single output.

So, if you indeed do need to return 2 "values", then it does not work because it would not be a "function" (ie: one single output)...

Luckily, there is a workaround. Functions return "outputs", wich can be of any valid object type. Including "composit objects". Objects which are composed of 0 to n other objects.

Depending on your needs, you can return the result as one complex number (which is 2 normal numbers) (return (x,y);), one vector or matrix (from 1 to n numbers), or one list (0 to n objects) (return {x,y};)...


About the 2nd issue in your post. Unfortunately, the build in "enter the parameter" system does not have that type of functionality.

BUT, you can create your own program (that takes no arguements) and that can display such an input box with all the bells and wistle that your heart desire.

look at the (rather complex and powerfll) INPUT function.

If you look in the forum, someone has made an INPUT form creator program. A program to help to the design of INPUT form. This could help you a little bit.



I am an HP Employee
0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation