Variable output file name
Variable output file name
(OP)
I have developed a mathcad (V.11) sheet which writes output to an Excel file (Insert > Data > File output). I want to use the sheet to run a number of different cases and write to different Excel files. However, the Excel file name is set once the File output was created. One option is to disable output (by Disable Evaluation), and only activate once the file name is changed manually.
Is there another way to define the ouput file name at the begining of the sheet?
Thanks, bkal
Is there another way to define the ouput file name at the begining of the sheet?
Thanks, bkal
RE: Variable output file name
You can use the strcat() function along with the num2str() function to stitch together a filename. For example, assuming that the variable v is changing every run and A is your data matrix,
WRITEPRN(strcat(strcat('datafile_',num2str(v)),'.dat') : A
Open up the file in Wordpad to see the format -- you should be able to import this into Excel easily.
In my opinion, Mathcad is severely lacking when it comes to the flexibility of it's string processing and file I/O functions. Maybe this has been improved in v13? Anyone know?
I wonder if it's possible to change the filename of the Excel output object using a VBscript-able object. But that's an entirely different animal altogether.
Another idea would be to embed the Mathcad object into the Excel sheet and use the much more robust Visual Basic for Applications to do all the automation. I think this is possible? Not sure.
HTH,
-Matt