Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
I use references to text files to import data into my MathCAD worksheets.
On occasion, I have multiple versions of the data to analyze.
In order to change to another data file, I currently need to right-click the reference, select Properties, select the Reference tab, and then modify the name of the referenced file.
What I would like to do is have a string variable on the worksheet (this would be the name of the referenced file). Changing this variable would change the referenced file.
Is this possible at all with a script or control of some kind?
Thanks,
You can create a variable with a string, and reference that variable.
With a mistbox and a script you can go further. (But not with me, you need an expert.)
Three seperate text files for data, one file to read in any or all. You'll need to edit the path in the "File" matrix.
Fred,
This is helpful, but doesn't quite work for me because the second column of data in my txt file is not numerical. Using your method forces everything to numbers.
I would attach a file to better explain, but am not sure how to do so.
Steven Fatzinger wrote:
I would attach a file to better explain, but am not sure how to do so.
Select 'Use advanced editor' (top right of reply editor). Then go to bottom left of the advanced editor to select and post your file.
Alan
Alan,
Thanks. I think Firefox was not happy last time since I did try clicking 'Use advanced editor' but nothing appeared to happen. Today when I tried, I got a new screen and see where I can attach a file.
Thanks for your reponse.
Steve
Steven Fatzinger wrote:
... the second column of data in my txt file is not numerical. Using your method forces everything to numbers.
Use Insert component. Select Data Import Wizard. File format: Fixed width text. Browse to one of the files.Select Next (rather than Finish). In the Enter Column Widths box, ensure you set a value large enough to capture the whole of each number and string. Click Finish. Enter an output variable name. Then right-click and choose Add Input Variable. Enter the name of the file that contains the string that points to the text file of interest (include its subscript if it's in the form Fred has it).
Alan
Alan,
Alan Stevens wrote:
Use Insert component...
This doesn't exactly work for me as you described because the data is not fixed width. However, I noticed that I can select an option for delimited data; and that seems to work as I would expect. Now I can supply the data file name via the input variable name and the output variable updates accordingly.
Thanks so much for pointing me in the proper direction.
Steve
If you mean a referenced Mathcad worksheet, then no. There is no way to change the reference programmatically. It's been requested many times. But if it's just data can you not put it in a text file?