Functions > Reading and Writing Files > Fixed Width (PRN) Files
Fixed Width (PRN) Files
Three functions are used to read from, and write to, PRN files:
READPRN("file")—Returns an array containing the contents of the PRN file.
Files can contain numbers in engineering, complex, or string format, or nested arrays. Data may not be hexadecimal, octal or binary.
WRITEPRN("file", M, [rows, [cols]])—Writes the contents of array M to a PRN file.
Remember that in order to execute, an expression in a PTC Mathcad worksheet must be an assignment or a request for evaluation, as in:
APPENDPRN("file", M)—Writes the contents of array M to the end of a PRN file. The number of columns in the array must match the number of columns in the existing file. If the file does not exist, then APPENDPRN creates it. To write the file, you must evaluate the function as shown in the WRITEPRN example.
* 
To read binary files, use READBIN.
To read a wider variety of file types with more control, use READFILE.
Arguments
"file" is a string containing the file name or the full pathname and the filename. Non-absolute pathnames are relative to the current working directory.
M is an array, or, for WRITEPRN, it may be a scalar.
rows (optional) is either a scalar specifying the first row of matrix M to write to a file, or a 2-element vector specifying the range of rows (inclusive) of matrix M to write. If this argument is omitted, WRITEPRN writes out every row of the matrix to the file.
cols (optional) is either a scalar specifying the first column of matrix M to write to a file, or a 2-element vector specifying the range of columns (inclusive) of matrix M to write. If this argument is omitted, WRITEPRN writes out every column of the matrix to the file.
Additional Information
If complex, string, or nested matrix values are written to a PRN file, a header is created allowing the function to reconstruct the array.
Both rows and cols are indices that start with 1.
ORIGIN does not affect the behavior of READPRN or APPENDPRN.
The PRNPRECISION worksheet variable defines the number of significant digits to be used by WRITEPRN or APPENDPRN.
The PRNCOLWIDTH worksheet variable controls the width of columns in PRN files created by WRITEPRN or APPENDPRN.
You can only omit optional arguments from the last argument and back. For example, in WRITEPRN you cannot omit rows and specify cols. If rows is omitted, the value of cols will be used as rows.
Was this helpful?