Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
I want to create a global result table with fixed columns. From anywhere behind the definition of that table I will insert new result lines or modify existing rows. For modification, the first column is a key column, so that the match-Function could give back the row number:
My problem is, that the ResultTable will not be changed. Also not if I write
ResultTable:=AddResult("key123","Cap1","that's a nice result",4.5)
Yes, I know that inside a program the assignments are local. How to make global?
Thank for help!
Solved! Go to Solution.
You have to pass ResultTable as an argument to AdddResult.
Stuart
Thank you, Stuart
yes that works in that way:
ResultTable:=AddResult(ResultTable,other arguments)
but is there no possibility to change global variables directly?
> but is there no possibility to change global variables directly?
No. The first time you use ResultTable on the LHS of an assignment in your program you automatically create a local variable with that very name and all subsequent calculations are done using this local variable. So you can't change a worksheet variable from within a program the way you tried to do.
In Mathcad 15 there may be a way of doing it using scripted component - not sure about that and not available in Prime anyway.
R
In Mathcad 15 there may be a way of doing it using scripted component - not sure about that and not available in Prime anyway.
That can indeed be done in MC15. However, as you say, it's not a solution for Prime.
Peter Klemm wrote:
Thank you, Stuart
yes that works in that way:
ResultTable:=AddResult(ResultTable,other arguments)
but is there no possibility to change global variables directly?
Well, possibly there is a way ... it works in Mathcad 15 but it's an undocumented feature. I think it still works in Prime 3.1, but I'm not sure and don't have Prime available to check. It makes use of a "feature" (aka "bug" ... but maybe not) that allows a function to create a closure around an array, which provides a means for updating the array. It needs careful handling and the worksheet should be written and then calculated as a whole to make sure that all evaluations are carried out in the intended order.
Here's an example based around a Fibonacci function ...
Stuart
Thanks again.
I will try it.