Post Reply 
how to programatically define
11-26-2016, 04:15 PM
Post: #1
how to programatically define
Hello,
As you know define (shift-template key) allow you to define a function with parameters.
how can we define such a function from HPPL program ?

Is there something like : Define("abc","A*2+B") ?

Regards.

primer
Find all posts by this user
Quote this message in a reply
11-28-2016, 07:13 AM
Post: #2
RE: how to programatically define
Hello,

Yes, you can actually do it, but it is a little bit cumbersome, sorry about that...

Defined functions are actually user system global variables that contains a user function (a user function is different from an expression. A user function is an instruction sequence (ie, an executable list of objects) that has named parameters).

However, contrary to the CAS system, which is formal, there is no syntax for a user to enter/create such an object in the command line (although there is one in program mode).

As a result, you need to jump through hoops to do "make it happen".
So, without further due, here is how to do it!

First, define a user system global variable using the HVars instruction:
HVars("abc"):='A+2*B'
Then, and this is where the trick is, you need to tell the system to convert that expression into a user function with given parameters.
Do this using the 2nd meta data of the abc variable.
HVars("abc",2):={"B"}
This tells the system that the variable abc is now a user function and that it takes 1 parameter (ie local variable) called B.

You can provide as many parameters as you want of course, and the order in which you give them is the order in which they appear in the parameter list.

Note, this works both ways, you can get the parameter list of an existing user defines function by doing HVars("name", 2)

By the way, this is explained in the help (not as extensively as here)

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
11-28-2016, 11:35 PM
Post: #3
RE: how to programatically define
Thank you Cyrille,
that's impressive !
and it works really good.

(11-28-2016 07:13 AM)cyrille de brébisson Wrote:  By the way, this is explained in the help (not as extensively as here)
yes, but I didn't make the link with HVars. (I pressed help on Define screen)

thanks.

primer
Find all posts by this user
Quote this message in a reply
12-06-2016, 04:41 AM
Post: #4
RE: how to programatically define
Since HVars appears in the Help menus, but I don't seem to be able to access from the catalog, it seems like a semi-documented function. Looks like a really nice way to define functions programatically if you want to create an environment for dealing with specific classes of equations.

Is there any documentation outside of the Help menus that shows these types of commands and how they're used?
Find all posts by this user
Quote this message in a reply
12-06-2016, 06:23 AM
Post: #5
RE: how to programatically define
Hello,

HVars is located in the Vars/Home/System menu.

I am sorry, but I do not have an extensive list...

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
12-07-2016, 05:48 PM
Post: #6
RE: how to programatically define
Thanks for the pointer Cyrille!
Brad
Find all posts by this user
Quote this message in a reply
Post Reply 




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