Interactive ND1 Programs

Discuss your code, get questions answered

Interactive ND1 Programs

Postby JohnShau » Sat Dec 24, 2011 11:35 am

Hi Oliver,

I've been having some fun programming on the ND1 some of the examples in Chapter 28 of the 28S Owners Manual. I thought I'd give Chapter 27 a go, but think I may have run onto a snag. Let me just ask straight away; does the ND1 have the 28S program control commands like: s WAIT, KEY, f s BEEP, CLLCD, CLMF, DISP, etc? If yes where can I read up on these kind of commands for the ND1? If not maybe you would suggest a way for the ND1 to ask the user to do things and provide inputs.

Thanks, and have a great holiday!

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Re: Interactive ND1 Programs

Postby JohnShau » Sun Dec 25, 2011 1:15 pm

Hi Oliver,

I found and read the post, in Reference > ND1 RPL Implementation, about interactive commands. Too bad for now. Looking forward to V 1.4. Couldn't find much about the INPUT command. Where is it discussed?

What are the ND1 program input options? Is there any way to get programs to ask for inputs or have dedicated keys for specified input quantities?

Thanks.

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Re: Interactive ND1 Programs

Postby oliver » Mon Dec 26, 2011 1:51 pm

Hi John,

Happy Holidays to you too!

INPUT is from the 50g and discussed in the "HP 50g User's Guide", or the "HP 49 Advanced User Reference", which is preferable because its PDF file has an index. Both can be easily found with Google and downloaded from HPs website. I strongly recommend you get one of these, because, as mentioned, ND1 is actually way closer to the 50g than the 28S, by now. Most of the really cool things (list processing, etc.) are 50g features. Also, the most powerful programmatic input option from HP, INFORM, is a 50g feature and will eventually be supported.

I've gotten quite far with implementing interactivity, but v1.4, which will post any day (although iTunes is on holiday), will unfortunately, and against the plan, not release input options yet. V1.5 will, which is not far away. The tack I'm taking with input will be very different from HPs. See the Definition page of the calculator? You'll be able to design user input UI with buttons and sliders and other UI elements. The user will be able to select your program as if it were a different calculator. You'll even be able to define dynamic UI. You'll be able to invoke it programmatically with a single simple command ("myForm" @ui). This will go far beyond what HPs could do and be easier for both user and programmer/form designer.

As for INPUT, try this:
Code: Select all
≪ "My Computation" "Value?" INPUT ≫

This prompts a dialog and will return whatever the user types, as a string. Don't forget to convert this with STR→ if you want to have a numerical value. Hope this helps.

Cheers.
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Re: Interactive ND1 Programs

Postby JohnShau » Tue Dec 27, 2011 10:03 am

Hi Oliver,

Thanks for the reply, I took your advice and downloaded the HP 50g graphing calculator advanced user's reference manual. I am now in Chapter 1 RPL Programming. I was making good progress until I coded the Example program on pg 1-4 RPL Programming to calculate the volume of a sphere. When I run my code I get various error messages e.g.

Program execution error
Detail: incorrect syntax

In this case the display showed

'(64)*pi'
4.00

(In this post I typed pi to represent the pi symbol on . Lvl2 that I used in the code.)

If I use 3.14159 instead of the pi symbol and don't use the ->Num then the code works fine. I'm definitely making a mistake coding the space after the 4 and/or getting the ->NUM in correctly.

I have a problem with the symbols in the note "Enter the same keystrokes in a program (... just starts a new line.)

I don't want to tell you how much time I've spent trying to get this simple program working :-)

Please give me code that works with the pi symbol. Also, in the next few Examples that I want to code and understand I see a SPC key and black arrowheads in circles that will probably cause me trouble. Please give me code for these examples too.

Thanks for the help.

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Re: Interactive ND1 Programs

Postby oliver » Tue Dec 27, 2011 12:07 pm

Hi John,

Ok, I assume your talking about this program:
Code: Select all
≪ 3 ^ π * 4 3 / * →NUM≫


This works as is, just note that there's a space between each of the symbols before →NUM, and no space between → and NUM.
If you're in Classic mode, and you type the program on the edit line, you find all the keys you need, incl. ≪, π, and →NUM, on the keypad.

If you're in the multi-line editor, you cannot get to →NUM as I discovered (it's an omission and I took a note). Instead, get any command that has an arrow in it (such as →STR from the String menu) and erase backwards three letters to keep the arrow, and append NUM. Note, with the iPhone font the arrow looks somewhat disconnected from the text that follows it.

You don't actually need the →NUM key in this example. They put this in this example so that it will work with algebraic expressions as input (vs. numerical input). You could it simply leave it out.

As for the π: in ND1, you can actually just type pi, and you'll be fine.

The SPC key is simply the "space" key. In ND1, it's the untitled key in the bottom left. (Or, if you're in the multi-line editor, simply the normal keyboard's space key.)

The black arrowheads in circles refer to the cursor keys on the 50g. (It has a rocker of cursor keys, which can assume a variety of functions.)
Although most functions you'll encounter are there, there's no match between 50g and ND1 menu organizations. Hence, you'll have to completely ignore the exact typing instructions provided in the example and learn where to find the functions on ND1's keypad.
For example, "-> |> <- |> →NUM" (I'm approximating the various 50g symbols here in ASCII) on the 50g are the exact keys you have to press to get →NUM. On ND1 in Classic mode, that corresponds to shift-→NUM (atop the EVAL key).

(The 50g has far more keys (too many to cram onto an iPhone screen), two shift keys, and a two-level menu system that some find hard to navigate.)

For the next program
Code: Select all
≪ → r '4/3*π*r^3'  →NUM≫

you need no menus. All the keys, except the "r", are on the keypad. Make sure there's a space between → and r. If you enter ≪ and → using the keypad (→ is in the shifted position of the +/- key), correct spaces will be provided.

You'll have to tap onto the edit line and use the iOS keyboard to type the r and you'll have to dismiss the keyboard twice with "Done" to type the whole thing. Note, "Done" on the keyboard just dismisses it. It does not mean you're done entered stuff on the edit line. That is, don't worry that tapping Done on the keyboard will enter your line. It won't.

This second program also works as is. (And returns three more digits in the result.)

Finally, when you have v1.4 (which should post sometime this week), this RPL+ program will work
Code: Select all
≪ =r 4/3*π*r^3 ≫

Note how much shorter/clearer this is.

In the version you have, you can write
Code: Select all
≪ =r '4/3*π*r^3' EVAL ≫
or
Code: Select all
≪ =r '4/3*pi*r^3' EVAL ≫


The equals sign (connected/fused to the name following it) does away with the arrow syntax in RPL and a weird thing in RPL about re-assigning a local variable: while you initially create it with the arrow, you have to use 'r' STO if you want to re-assign r later in the program. In RPL+, you simply always use =r and you do *not* have to create a "defining procedure" with ' or , after creating a local variable. =nameOfYourLocal just works. I might confuse you now, but mention it all the same, because this is probably the single most important feature in RPL+ to make your life easier. So you may want to make a mental note and re-read this at some point.

Hope this helps.

Oliver
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Re: Interactive ND1 Programs

Postby JohnShau » Tue Dec 27, 2011 3:01 pm

Hi Oliver,

Your reply helped me very much. I guess my coding problem was the spacing. I typed in what you sent and it ran fine. I also got the examples with "r" and "h" inputs working as well. Yes! Now I know more about the inputs I can code in V 1.3.

Also, with the information you included in these posts I now better understand the keys and how to type what I want.

As always, thanks,

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Re: Interactive ND1 Programs

Postby JohnShau » Wed Dec 28, 2011 11:21 am

Hi Oliver

Is there a stand alone right delimiter (like >>) on the ND1 keyboard or on a menu key? I usually try to make one from the double delimiter <<>> on the Program Menu. The trouble is, on my 3GS it's tough to get the cursor in the middle to delete the left half. An example of the need is on page 1-2 of the 50g advanced manual. There is an example code as follows:

<< << 1 2 + >> EVAL >>

The problem comes trying to get the >> between the + and EVAL. I'm probably missing something, but I can't find a good way to do it.

Thanks.

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Re: Interactive ND1 Programs

Postby oliver » Wed Dec 28, 2011 12:28 pm

John,

If I need a sole ≫, I do as you mention: take the right half of ≪≫.

If positioning the cursor is too fiddly for you, I suggest the following:
- use iOS copy/paste functionality to copy a ≫ character
- go to Definition, find the Program menu, and edit it: create a new key named ≫ with function ≫ (paste the character)

Done. Enjoy your new key. ;-)

The only downside to this is that after the next update you should restore the calculator to pick up 50 new function keys. This will remove your own key definition, and you'll have to add it again. In v1.5, you'll be able to save your own calculator. I hope people will use this and share their calcs.

Note,
Code: Select all
≪ [1 2 +] EVAL≫

works too and avoids the characters in question.

Oliver
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Re: Interactive ND1 Programs

Postby JohnShau » Wed Dec 28, 2011 2:51 pm

Hi Oliver,

Neat! I put the >> symbol on the Classic 1 key (replaced the degree symbol). I scared myself though; I did it so fast I was afraid I might have replaced the 1 by mistake and I didn't know how to get back :-) All was ok. I did worry a bit when I thought; how DO I get the degree symbol back again? I did what you suggested and copied the degree and pasted it where I had put the >>. That worked, fine so I put the >> back on with the 1.

Thanks for the ideas.

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Re: Interactive ND1 Programs

Postby JohnShau » Wed Dec 28, 2011 3:09 pm

Hi Oliver,

Holy Cow, I just re-read your post. You suggested I put the >> in the program menu. I read your post so fast I thought you suggested replacing a symbol (like the degree on the 1 key) on one of the shifted keys on the keyboard :-)

I went to Definitions > Menus and edited Programs and I see all the Program actions available. My question is; if I want to add the >> symbol do I just paste it in both the Soft Keys line and the Functions line at the same place? e.g. Right after <<>> ? I don't think I'll do this till I've heard back from you.

Thanks

John
JohnShau
 
Posts: 29
Joined: Thu Dec 08, 2011 6:30 am

Next

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron