Post Reply 
Can app equations be indexed?
01-13-2017, 04:45 PM
Post: #1
Can app equations be indexed?
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!

-Dale-
Find all posts by this user
Quote this message in a reply
01-13-2017, 05:04 PM
Post: #2
RE: Can app equations be indexed?
EXPR("V"+1+":="+QUOTE(L1(1)) ) ???

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
01-13-2017, 05:20 PM
Post: #3
RE: Can app equations be indexed?
On my side I've come up with:
Code:
EXPORT AGV(list)
BEGIN
LOCAL j;
  FOR j FROM 1 to SIZE(list) DO
     EXPR("Advanced_Graphing.V"+(j-1)+":=UPPER(STRING(list("+j+")))");
  END;
END;
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.
Find all posts by this user
Quote this message in a reply
01-13-2017, 05:46 PM (This post was last modified: 01-13-2017 05:51 PM by DrD.)
Post: #4
RE: Can app equations be indexed?
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!

-Dale-

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!
Find all posts by this user
Quote this message in a reply
01-13-2017, 08:35 PM (This post was last modified: 01-13-2017 08:43 PM by Han.)
Post: #5
RE: Can app equations be indexed?
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).

Code:
ex:="2*x-3*y+myvar";
varnames:=lname(CAS(eval(ex)));
k:=size(varnames);
for n from 1 to k do
  varnames(n):=string(varnames(n));
  AVars(varnames(n)):=0;
end;

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.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-14-2017, 09:13 PM
Post: #6
RE: Can app equations be indexed?
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:

Code:

EXPORT testapp()  
BEGIN 

  LOCAL a, list:=UPPER({"x+3y<=10","x+5y<=8","z=8x+10y"});
 
  a:="Advanced_Graphing";
  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
    ELSE
      BREAK;
    END;
  END;    
   
END;
Find all posts by this user
Quote this message in a reply
01-14-2017, 09:50 PM
Post: #7
RE: Can app equations be indexed?
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.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
01-14-2017, 10:18 PM
Post: #8
RE: Can app equations be indexed?
Good point. I hadn't thought of that...
Find all posts by this user
Quote this message in a reply
Post Reply 




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