Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
I'm trying to pass on a variable as a string to another mathcad Prime sheet. VAY is a number defined above in calculations within the sheet. I don't want the evaluated value but the variable itself. There should be a function to do just that. See screen shot.
Solved! Go to Solution.
Yes, there should be a way to pass variables by name, or at the very least convert between strings and variables.. A possible conceptual problem in Mathcad with such a proposal is that a variable would appear in a workspace without having been explicitly created (going the other way wouldn't be an issue). However, this might not be an actual problem once people had got used to the idea. And, certainly, going from variable name to string should not be a problem.
Like many other capabilities, this feature has been the subject of a long-standing request. It should be possible to programmatically create variables with, for example, sequential suffix numbers.
However, depending on your use case, it may be possible to achieve what you want through Automation. This would mean using, say, an advanced control to write or rewrite a region in a worksheet.
See, for example, https://support.ptc.com/help/mathcad/r11.0/en/?utm_source=mathcad/index.html#page/PTC_Mathcad_Help/API/example-7_send_sexpressions.html#
Stuart
There is no supported way in Prime to handle/process/manipulate the name of a variable other than through the user interface. You cannot create variable names using any of the worksheet functions, you can only manipulate their values.
You can do what you want only IF.... you can make the evaluation in the present sheet show:
SYNCP = "VAY" (that is, having a string value) while it is at the same time defined with that numeric value of 1.328*105 V.
But, if you can show how you can do that, and then it - may - be possible to transfer that string value to another sheet...
In other words: it is not possible, or I don't understand what you are trying to achieve.
Note that it is possible to show the origin of a variable's value using symbolic evaluation:
This example is from Mathcad, but you can accomplish the same in Prime if you use the function
clear.sym(VAY)
instead of the Mathcad assignment
VAY := VAY
They both have the effect that the numeric value of VAY is set to unknown for symbolic evaluations. Thus subsequent (symbolic ! ) evaluation of SYNC will show that it was defined as equal to VAY (instead of it having the numerical value of VAY).
But note that the symbolic evaluation of SYNC does NOT show the string "VAY".
Success!
L:uc
Its not perfectly clear to me what you would like to accomplish and for what reason. But as Luc already noted there is not way in Prime or Mathcad to turn a variable name into a string or the other way round.
Maybe it helps if you keep two variables, one containing the value, the other the name, showing where it stems from. Something like
BTW, I would suggest that you turn on "Units/Constants in Symbolics" (recalculation of worksheet is necessary afterwards) so that the labeling of units and constants survive a symbolic evaluation.
As can be seen in your screenshot, the kV is no longer labeled as a unit, but as an (unknown) variable. If you were to follow the symbolic evaluation with a numerical one, this would produce an error.
Enabling the Option does NOT tell the symbolics how to deal with units - it only assures that the labeling stays intact.
Thank as always. I will correct Units/Constants for the issue.
It is a strange request that I make above. SYNCP is used further down in the parent worksheet for other calculations. In the sheet as the target of the INCLUDE statement, a variable SYNCP needs to be "VAY" string so it can be shipped into a text file. A third program expects SYNCP as "VAY" as part of a multi-row, two column text file of a certain format.
Yes, there should be a way to pass variables by name, or at the very least convert between strings and variables.. A possible conceptual problem in Mathcad with such a proposal is that a variable would appear in a workspace without having been explicitly created (going the other way wouldn't be an issue). However, this might not be an actual problem once people had got used to the idea. And, certainly, going from variable name to string should not be a problem.
Like many other capabilities, this feature has been the subject of a long-standing request. It should be possible to programmatically create variables with, for example, sequential suffix numbers.
However, depending on your use case, it may be possible to achieve what you want through Automation. This would mean using, say, an advanced control to write or rewrite a region in a worksheet.
See, for example, https://support.ptc.com/help/mathcad/r11.0/en/?utm_source=mathcad/index.html#page/PTC_Mathcad_Help/API/example-7_send_sexpressions.html#
Stuart
Thank You!