There are three functions that are used to read from, or write to ASCII files:
• READPRN("file")—Returns an array containing the contents of the ASCII file.
Files should be ASCII text only, with data arranged in rows and columns separated by spaces or tabs. A text header is allowed; however, once READPRN encounters a number, it assumes data has begun, so headers should contain no numbers. If complex, string, or nested matrix values are written to a PRN file, a header is created allowing READPRN to reconstruct the array. To read a wider variety of file types with more control, use READFILE.
Data files can contain numbers in engineering, complex, or string format, or nested arrays. Data may not be hexadecimal, octal or binary.
To read binary files, use READBIN. To read file formats from other applications, or with more import options, use data components.
• WRITEPRN("file", M, [rows, [cols, ["decsymb"]]]) —Writes the contents of array M to a delimited ASCII 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 delimited ASCII 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.
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.
• decsymb (optional) is the decimal symbol to use. You can only specify "." (dot).
Additional Information
• 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 ASCII 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 and decsymb. If rows is omitted, the value of cols will be used as rows.