HP Forums
Can app equations be indexed? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Can app equations be indexed? (/thread-7567.html)

Can app equations be indexed? - DrD - 01-13-2017 04:45 PM

Provided with a suitable {list} of equations, does anyone know of a way to programmatically enter each of the equations into the Advanced Graphing App variables V0-V9? Some indexed way, via a loop construct, is the general idea.

Thanks, if you can help!


RE: Can app equations be indexed? - Tim Wessman - 01-13-2017 05:04 PM

EXPR("V"+1+":="+QUOTE(L1(1)) ) ???

RE: Can app equations be indexed? - Didier Lachieze - 01-13-2017 05:20 PM

On my side I've come up with:
  FOR j FROM 1 to SIZE(list) DO
which takes care of the conversion of the lower case variables you may use in CAS to upper case variables required by the Advanced Graphic app.

You may need to check additionally that the input list doesn't have more than 10 elements.

RE: Can app equations be indexed? - DrD - 01-13-2017 05:46 PM

I'll wrestle with that awhile. I had tried that with a list of string objects, which didn't work. Also, I just noticed that my string object list has lower case variables, and that's not going to work, either! Your idea seems work fine with a list of single quoted function objects, using upper case variables.

Thanks, Tim. I hope you had a nice Christmas and things go superbly in the new year!


Didier posted another idea, as I was preparing this response to Tim. I'll give that a try, as well. Thanks Didier! I always appreciate your clever ways and means!

RE: Can app equations be indexed? - Han - 01-13-2017 08:35 PM

I've done this in Graph3D, but only using a single V0 to do temporary calculations and restoring the original content of V0. The format is just V0:=<string> where <string> is an actual string or a variable containing a string. It's also a way to quickly create a function.

The string itself needs to be a valid expression. Tim's suggestion works fine for a list strings.

If you are running into issues with variables, you can create app variables using AVars("varname"):=0 and delete when with DelAVars (can be a list of strings corresponding to app variables, too).

for n from 1 to k do

Then to delete, since varnames have been converted to strings, just use DelAVars(varnames);

I have been using this scheme to program my own Equations Library and solver application that allows for any sort of variable.

EDIT: In case it was not clear, once the app variables are created, you can use your string equations as already described by Tim and Didier without needing to convert to upper case or limiting yourself to single-letter variables.

RE: Can app equations be indexed? - DrD - 01-14-2017 09:13 PM

Thanks for all of your suggestions! I have a much better understanding of the details now. I combined several of the suggestions in this snippet program, which others might find useful down the line:


EXPORT testapp()  

  LOCAL a, list:=UPPER({"x+3y<=10","x+5y<=8","z=8x+10y"});
  FOR I FROM 1 to SIZE(list) DO
    IF I<=10 THEN
      EXPR(a + ".V" + (I-1) + ":=" + 'list(I)'); // This populates app variables V0-V9
      EXPR(a+".CHECK(I-1)");                     // This CHECKS the corresponding Checkbox

RE: Can app equations be indexed? - Han - 01-14-2017 09:50 PM

Your code could fail should a user set their number format to FIX or anything similar. You may want to use LEFT(STRING(I),1) or some variation of STRING with optional arguments.

RE: Can app equations be indexed? - DrD - 01-14-2017 10:18 PM

Good point. I hadn't thought of that...