Post Reply 
Create a list of undefined user vars?
01-26-2016, 12:08 PM (This post was last modified: 01-26-2016 12:12 PM by DrD.)
Post: #10
RE: Create a list of undefined user vars?
(01-26-2016 06:01 AM)cyrille de brébisson Wrote:  Hello,

1) At the time of the INPUT, the inputed variables MUST exist as INPUT uses the current value of the variable as the default value.
Well, this brings us full circle: Creating a list of undefined variables IS the whole purpose of the effort.

2) do not use CAS.INPUT, INPUT is NOT a CAS command...
The "CAS." prefix was used in order to create a list containing symbolic content (only available from the CAS side), and necessary for naming undefined variables. This is from your earlier suggestion to use CAS to initially create the symbolic name list. (It doesn't work without it). Based on the information you provided yesterday, this sort of worked, to the extent that the INPUT function was able to (sort of) work with it.

EXAMPLE: Make sure User Variables, dogs and cats, don't exist in User Variable memory, then, (in CAS!), create this list: L1:={'dogs', 'cats'}, and run this program:

Code:

EXPORT test()
BEGIN
  // !!CREATE IN CAS FIRST!! ==> L1:={'dogs', 'cats'};
  CAS.expr("INPUT("+string(L1)+")");   // Input type requires '5' and '4' (quoted numbers)   
  return eval(L1);  //  How to access contents of {dogs,cats} ==> {5,4}??
END;


3) What is the value of L1? can you show it?
The Example given above for list L1 was: L1:={'dogs', 'cats'}; however, ANY list containing undefined variable names (that are not reserved variable names) is the ultimate goal. Then, (from your suggestion): CAS.expr("INPUT("+string(L1)+")"); use real number values for the dogs and cats, (previously undefined), as inputs. In the example given, I used a value (for dogs) of 5, and (for cats) of 4. However, this construct only allows quoted numbers as inputs ('5' and '4'), which seem to be unavailable after the INPUT function has completed. I don't understand this, which is why I said the construct "sort of" works.

4) to help you debug, you can save the string in a temporary variable and show it on the screen (PRINT(string_variable); WAITWink or just (save the string in a user accessible variable and kill the program). This will probably let you see what is happening.
My objective, to provide a list of undefined variables, subsequently defined via the INPUT(list) function, may not be possible.

It's useful, in my case, because I want to pre-condition L1 with stock symbol data, to be used, later on, in a generic program that provides statistics of interest using that changeable list; such as, "unrealized gain", "portfolio net worth," etc. Your suggestion comes VERY close to what is needed; but, after spending, (probably too much), time, I haven't quite gotten over this hump yet!

Thanks for your ideas, Cyrille!! Hopefully, others can also gain benefit from information you've provided, even if this notion bumps up against a dead end! -Dale-


Good luck.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Create a list of undefined user vars? - DrD - 01-26-2016 12:08 PM



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