Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Much of my past experience has been in C, C++, etc where I can write my output directly to a text file. Is there a way I can send strings to a text file along with variables? I would like to be able print out my results from my program in order to debug my results.
For example, I have a matrix M that I would like to send to a text file along with sentences. Throughout the program I would like to append to the same text file.
In MC15, use the trace() function and open the debugging window.
Prime does not yet have the trace() function.
Rehan Momin wrote:
Much of my past experience has been in C, C++, etc where I can write my output directly to a text file. Is there a way I can send strings to a text file along with variables? I would like to be able print out my results from my program in order to debug my results.
For example, I have a matrix M that I would like to send to a text file along with sentences. Throughout the program I would like to append to the same text file.
There are several file output functions and components ... look them up in Help. Here's an example (most of the output functions work on arrays rather than scalars or strings) in which I create an array that contains a list of the variables that I wish to output.
One thing to note is that with Mathcad, provided you aren't dealing with arrays or other values that stretch over more than one page width (only a limitation in Mathcad Prime), then you could just evaluate the variables when you want (using 😃 and print the Mathcad worksheet (if on-screen inspection isn't feasible).
Play around with some of the functions ... the PRN format is readable but not as "obvious" as the Mathcad evaluation shown above:
// Datafile written by Mathcad
// 10/07/12 09:41:44
.MATRIX 0 0 3 2
"M" {1,0,2,2} "x" 9 "A" {2,0,2,2}
.MATRIX 1 0 2 2
1 2 3 4
.MATRIX 2 0 2 2
9 18 27 36
Stuart
When using the trace function to output to the trace window, my 11x11 matrix is not displayed with all values shown. Is there a way to have the trace window output the matrix with all values shown?