Problem with this is that it requires the user to set up the WRITEFILE construct beforehand so it is not a fully live and dynmaic solution which is the reason why I wanted to use the API in the first place!!!
But surely the user would have had to modify the worksheet for you to use SetValue? At least to the extent that if they have an assignment for the matrix, M, they must disable execution of that assignment. Although that is much less work than setting up the WRITEFILE!
Is there any way I can dynamically create the READFILE(Mfilename,"delimited) construct and assing it to a variable?
Maybe. You cannot create (or destroy) regions via the automation interface. You can change the XML of a math region though (but not any other type of region). So if the worksheet has an assignment for M you could locate that region and replace the XML with the READFILE statement.
Of course, this opens up another possibility. You could perhaps create the matrix directly by modifying the XML. This must be possible in principle, but I'm nor sure how easy it would be in practice.
I have attached a worksheet that might give you some useful code as a starting point for this approach. It has scripted components that read or modifiy the XML of a region. The worksheet was written by Tom Gutman, not me.
I would be amazed if they had fixed this. They are putting minimal effort into Mathcad 15 now, and a bug that affects so few people will never make iti high enough up the list. All their effort is going into Prime. At the current rate of progress maybe in another three years you will be able to do what you want in Prime. I wouldn't bet any money on that though
I have made a program that will import a matrix of data from a text file, and then send that file to MathCad via VBA, as I have alot of different files and want to be able to compare items dynamically and quickly.
So far, my program seems to do just fine when I have a matrix size of 111 x 105, but fails at 111x110. I have NO idea why this is, and can't seem to figure it out. It is very frustrating that this issue is occuring. I supposed I'll have to manually put that data in.
The thing is, I have a 'check' file in which i can put in the matrix as normal from data import wizard and it works JUST FINE! There is something wrong with the import API using the set value for very large matrixes. The solution may be to augment the matrixs if they are over a certain size?
That might be the work around. Currently the text file is filled with other information that isn't specifically the data I need to pass to mathcad. I could export the data to a text file if the matrix is large, and then pass in that file.
Is there a specific API command to make that happen? I'm unsure if saying MC_Sheet.SetValue "Input_Data", 'FileName' would work. Input_Data is the matrix data I have, and MC_Sheet is an object, specifically the Mathcad.Worksheet object. I am only setting two values. One is the Diameter midpoint of the channels (just a singular vector) and have had no problems with it, while the other is the large matrix that has an entry for each diameter for each sample taken.
There's nothing specific. Just pass the path and filename to a variable as a string, and then use READPRN to read the data.
Thank you very much. I altered the code to dump the matrix and vector to a text file (with overwrite true), and then passed those namepaths to my MC functions as strings for my input table. Everything seems to work just fine now, even for the larger matrixes. I do appreciate your insight into helping me solve this issue.
I was slightly worried about calculation time with the file writing, but the largest time part seems to be just the output variables I have from mathcad and setting those as output objects into my excel output table of the document.