HP 50g Programming functions to be used in the EQW
06-09-2016, 06:44 AM
Post: #1
 Jun0303 Junior Member Posts: 2 Joined: Jun 2016
HP 50g Programming functions to be used in the EQW
Good morning,

These days I've been programming some functions with UserRPL in the 50g HP and I was wondering how can I code a function that can be used in EQW. I mean functions like COS(angle) or F0ʎ(ʎ,T), that when I select then through the CATALOG of commands they appear in the Equation Writer with parentesis and the nº of value sthey need to work.

My function is something like:

<< → n p
<<
code of the function
>>
>>

and I included it in a library using HPLibs library to create my library but when I used in the Equation Writer it says "→ Error: Too Few Arguments", so how can I create a function that the Equation Writer asks for the arguments?
06-09-2016, 10:09 AM (This post was last modified: 06-09-2016 11:07 AM by Vtile.)
Post: #2
 Vtile Senior Member Posts: 406 Joined: Oct 2015
RE: HP 50g Programming functions to be used in the EQW
Equation Writer aka EQW is algebraic (which I personally like on that, someone else might not like). So in UserRPL you are using RPL/RPN like name suggest so if you like to take sine from angle of X you then enter ie.

<< 45 SIN >>
Results -> 0.7071...

This same logic implies most (all that I know / remember) of the commands in userRPL..

So first the object(s) to be manipulated and after that the action you want to do.

IE. This program creates complex number polar form a "quick" way.
Quote:
Code:
<< DUP2 COS * UNROT SIN * Re±Im >> 'YɑX' STO

You enter in RPN: ABS [SPC] ARG [YɑX]
.. and it creates a complex number representation from polar entry, but shown in the mode you have chosen. Note that I haven't tested it in the radian mode almost at all, but it seems to work also in radians flawlessly (why not).

You can familiarise yourself these commands and RPL logic more by turning the calculator to RPN mode and using letters ie. Y and Z (also X if it doesn't have value in it)

Now you can build the exact equations ( you normally write in EQW ) in stack view. Like
3: 'W'
2: 'Y'
1: 'Z'
Then command: / (=divide key)
Result:
2: 'W'
1: 'Y/Z'
Result
1: '(Y/Z)+W'
Then command: SIN (=Sine key)
Result :
1:SIN((Y/Z)+W) [or close to this depending of the settings of the CAS and flags]

So the buety of UserPRL comes from exactly from this, you can make programs precisely as you would using the normal RPN-mode calculator. If you are using Algebraic mode (as is by defaul) as your normal mode, you are giving away most of the benefits of the 50g. It takes week or two to get used to the RPN mode, but you will not ever want to go back after that it is that intuitive.

PS. Were this what you were asking?? I'm not sure if you can use UserRPL programs in EQW, but if you can the difference must be the same as giving values to userRPL program in ALG / RPN mode default view.
The above code example have this (underlined) "Re±Im" command.
<< DUP2 COS * UNROT SIN * Re±Im >>
Which is a call for an another UserRPL program/function. Re±Im contains a code:
<< i * SWAP + >>

Code examples are taken from thread:

PPS. In some point of time you will need this Advanced User Manual. http://www.hpcalc.org/details.php?id=7141 (note: there is also searchable version around on the net, I'm not sure if this is it. This one were first google did give.)

PPPS. Also for more complex programs you should download and install HP useredit software (which contains IDE and emulator for atleast userRPL programming) that also can be found on the HPCalc.org
06-09-2016, 01:29 PM
Post: #3
 Vtile Senior Member Posts: 406 Joined: Oct 2015
RE: HP 50g Programming functions to be used in the EQW
I had a bit more time and I tested to call my existing userRPL programs (or functions if you prefer) it indeed works in EQW the calling procedure is a bit glumsy though.

in EQW
[VAR][F1...F6][DownArrow][<- (del/clear)][Left Shift][ - ][0..9][Right Shift][SPC][0..9]

Phew ... ALGebraic mode is definedly later add-on top (which it is) of the stack based RPN system.
06-12-2016, 10:40 AM
Post: #4
 Jun0303 Junior Member Posts: 2 Joined: Jun 2016
RE: HP 50g Programming functions to be used in the EQW
@VTile Don't really understand the point of the first post because I already know how to program in UserRPL. What I was asking though it isn't how to use a UserRPL program in the EQW as you indicated in the second post and thanks for that! It is usefull but also I knew how to do it (and yeah, it's glumsy).

What I would like to know is how to use an UserRPL program in the EQW writer which is inside a library, so I can access to it through the catalogue of commands as the other functions.

For instance, if you go to the EQW and select the F0ʎ command, teh EQW already prepares two spots so you can give it the 2 value sthat the command need. However,when I try my library command programmed in UserRPL I got the error I specified in the first command.

So I was wondering if there is a was that I can program things and the calculator treat them as the F0ʎ example in the EQW. If it is possible with UserRPN or I have to use SystemRPN. So, any ideas in this field?
06-12-2016, 01:55 PM
Post: #5
 Tugdual Senior Member Posts: 764 Joined: Dec 2013
RE: HP 50g Programming functions to be used in the EQW
Did you check MSOLV?
06-14-2016, 04:30 PM (This post was last modified: 06-14-2016 04:45 PM by Vtile.)
Post: #6
 Vtile Senior Member Posts: 406 Joined: Oct 2015
RE: HP 50g Programming functions to be used in the EQW
(06-12-2016 10:40 AM)Jun0303 Wrote:  @VTile Don't really understand the point of the first post because I already know how to program in UserRPL. What I was asking though it isn't how to use a UserRPL program in the EQW as you indicated in the second post and thanks for that! It is usefull but also I knew how to do it (and yeah, it's glumsy).

What I would like to know is how to use an UserRPL program in the EQW writer which is inside a library, so I can access to it through the catalogue of commands as the other functions.

For instance, if you go to the EQW and select the F0ʎ command, teh EQW already prepares two spots so you can give it the 2 value sthat the command need. However,when I try my library command programmed in UserRPL I got the error I specified in the first command.

So I was wondering if there is a was that I can program things and the calculator treat them as the F0ʎ example in the EQW. If it is possible with UserRPN or I have to use SystemRPN. So, any ideas in this field?
I'll understand your problem now. Unortunately the solution is beyond my knowledge.

Could the solution to be as simple as placing your library to CAS-menu? (answer to my self .. propably not) If you find the solution please share it. AUR seems to share a few lines of the poorly documented \$extPRG functionality of CRLIB command, but I don't know if there would be the keys for the solution.

The HPLIBS seems to be mainly a GUI for that command (CRLIB), what I did quickly read the code.

PS. Also does non analytical functions have the pre-placed brackets after them? .. to answer myself yes, atleast fuctions.
06-14-2016, 07:37 PM (This post was last modified: 06-14-2016 09:26 PM by Vtile.)
Post: #7
 Vtile Senior Member Posts: 406 Joined: Oct 2015
RE: HP 50g Programming functions to be used in the EQW
This started to hount me (as this would be somewhat usefull to me also) and I had free evening so I spend it poking around my 50g.. Here is partial solution for the whole problem and full solution?? to first question me thinks. Note. the program do not work in usefull way, but shows how to automaticly insert the brackets in certain conditions. This is tested with HPLIBS and through CAT in EQW ... works.

I think the solution is found in the implementation of apply command and correct structure for error trapping and branching.

edit...
Newermind I found fatal error on my example, hmpf.. Still apply command is the one I would try to hack around. My error were that apparently it seems that apply can not use library command for it's string argument or something odd like that. My example were using different name for apply .. silly me .. when I made another version and tested it through library I did notice this "apply error: bad argument type".
 « Next Oldest | Next Newest »

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