Post Reply 
Learning to program on the HP Prime (intermediate to advanced)
10-09-2020, 03:42 AM
Post: #1
Learning to program on the HP Prime (intermediate to advanced)
I have learned to program quite a bit while taking my ChemE courses but it has been quite difficult finding good help on things that aren't clear or are not even in the user manual for the HP Prime (this forum is very helpful). What I would like to know is if there are any materials or courses that teach you how to program better for the HP Prime or is it just trial and error? I see some people make amazing programs and apps for the Prime but I have no idea how they learned to do all of that stuff. If someone could point me to some learning materials that would be much appreciated.
Find all posts by this user
Quote this message in a reply
10-09-2020, 09:38 AM
Post: #2
RE: Learning to program on the HP Prime (intermediate to advanced)
Perhaps the following link might be helpful:
http://www.hp-prime.de/files/composite_f...hp-ppl.pdf

Best
Raimund
Find all posts by this user
Quote this message in a reply
10-09-2020, 11:23 AM
Post: #3
RE: Learning to program on the HP Prime (intermediate to advanced)
(10-09-2020 09:38 AM)rawi Wrote:  Perhaps the following link might be helpful:
http://www.hp-prime.de/files/composite_f...hp-ppl.pdf

Best
Raimund

I have looked at that before and it does have some useful information. I am looking for something with more information. That pdf has showed me a few things but I still had to look at someone elses code to figure out how to format the input screen or use the CHOOSE function. If I could find something that will teach how to format the screen/code and also how to use calculator functions better or in new ways, that would be amazing.
Find all posts by this user
Quote this message in a reply
10-09-2020, 09:50 PM
Post: #4
RE: Learning to program on the HP Prime (intermediate to advanced)
I don’t know if this will be of great help: I found this good tutorial, but it is in French.
http://mic.nic.free.fr/hp/Livret%20HP%20Prime.pdf

Maybe, if you don’t speak French, with screen captures and the use of Google translate you could find some help.

I think you should also feel free to post your tries here, and let the people suggest their improvements or their tricks.
You can even post lots of questions at a time, there are people here who are not afraid of long posts.

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-09-2020, 10:16 PM (This post was last modified: 10-10-2020 02:40 AM by pinkman.)
Post: #5
RE: Learning to program on the HP Prime (intermediate to advanced)
... And of course the built in Help is very important for your learning curve.

Here is a simple “INPUT” example with radio button behavior:

Code:


EXPORT CHECKTEST()
BEGIN
 LOCAL I, R, I1, I2, I3, I4, I5;
 R := INPUT({{I1,4,{25,10,1}}, {I2,0,{25,10,2}}, {I3,0,{25,10,3}}, {I4,0,{25,10,4}}, {I5,0,{25,10,5}}},
      "Make your choice",
      {"Choice 1","Choice 2","Choice 3","Choice 4", "Choice 5"},
      {"Help text #1", "Help text #2", "Help text #3", "Help text #4", "Help text #5"});
 IF R THEN
  I := I1 + I2 * 2 + I3 * 3 + I4 * 4 + I5 *5;
  IF I THEN
   MSGBOX("You chose " + STRING(I));
  ELSE
   MSGBOX("You chose nothing");
  END; 
 ELSE
  MSGBOX("You canceled your choice");
 END;
END;

Edit: corrected after bug detection on I assignation

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-10-2020, 12:04 AM
Post: #6
RE: Learning to program on the HP Prime (intermediate to advanced)
With that sample program, I always get the message that I chose nothing. I think the value of I is being checked before it gets assigned.
Find all posts by this user
Quote this message in a reply
10-10-2020, 02:41 AM (This post was last modified: 10-10-2020 06:00 PM by pinkman.)
Post: #7
RE: Learning to program on the HP Prime (intermediate to advanced)
(10-10-2020 12:04 AM)tcab Wrote:  With that sample program, I always get the message that I chose nothing. I think the value of I is being checked before it gets assigned.

Shame on me!
Var “I” was assigned two lines too late. Corrected in the original post.

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
10-10-2020, 04:03 AM
Post: #8
RE: Learning to program on the HP Prime (intermediate to advanced)
Thanks, works fine now.

Playing around a bit, it looks like MSGBOX works OK if you pass it the integer I without converting it to a string. Also, returning I might be a nice enhancement if the user wants the value on the main calculator history/stack. E.g.

PHP Code:
MSGBOX("You chose " I);
return 
I

I know it's a toy program, but this information might help the original poster.
Find all posts by this user
Quote this message in a reply
10-12-2020, 10:34 PM
Post: #9
RE: Learning to program on the HP Prime (intermediate to advanced)
Yes good idea of course.

To the OP: if your function doesn’t explicitly returns a value, then it returns the last calculated value of the function.

You also asked to learn how to use CHOOSE, well there is less mystery.

Code:

EXPORT CHOOSETEST()
BEGIN
 LOCAL CHOICE, LST := {"Apple","Pear","Cherry","Orange"};
 CHOOSE(CHOICE,"Make your choice", LST);
 IF CHOICE THEN
  MSGBOX("You chose " + LST[CHOICE]);
 ELSE
  MSGBOX("You chose nothing");
 END; 
 RETURN CHOICE; 
END;

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)