ArrayToFile
- Updated2023-02-21
- 4 minute(s) read
ArrayToFile
int ArrayToFile (char fileName[], void *array, int dataType, size_t numberOfElements, size_t numberOfGroups, int arrayDataOrder, int fileLayout, int columnSeparationStyle, int fieldWidth, int fileType, int fileAction);
Purpose
Saves an array to a file using various formatting options. ArrayToFile creates, opens, writes, and closes the file. You can use FileToArray to read back the file into an array.
Parameters
Input | ||||||||||||||||||||||||||||||||
Name | Type | Description | ||||||||||||||||||||||||||||||
fileName | char [] | Name of the file to generate. fileName can be an absolute pathname or a relative filename. If you use a relative filename, ArrayToFile creates the file relative to the current working directory. |
||||||||||||||||||||||||||||||
array | void * | Numeric array to be saved to the file. | ||||||||||||||||||||||||||||||
dataType | int | Array element data type. dataType must be one of the following data types:
|
||||||||||||||||||||||||||||||
numberOfElements | size_t | Number of array elements to save. | ||||||||||||||||||||||||||||||
numberOfGroups | size_t | If you save the array data in ASCII format, you can divide the array data into groups. ArrayToFile can write groups as columns or rows. numberOfGroups specifies the number of groups into which to divide the array data. If you do not want to divide your data into groups, use 1. | ||||||||||||||||||||||||||||||
arrayDataOrder | int | If you divide your array data into groups, arrayDataOrder specifies how the data of different groups is ordered in the array. The choices are as follows:
|
||||||||||||||||||||||||||||||
fileLayout | int | If you save the array data in ASCII format, fileLayout specifies how ArrayToFile arranges the data in the file. The choices are as follows:
|
||||||||||||||||||||||||||||||
columnSeparationStyle | int | If you tell ArrayToFile to write multiple values on each line, colSepStyle specifies how to separate the values. The choices are as follows:
|
||||||||||||||||||||||||||||||
fieldWidth | int | If you specify a colSepStyle of VAL_CONST_WIDTH, fieldWidth specifies the width of the columns. If you do not specify a colSepStyle of VAL_CONST_WIDTH, this parameter is ignored. | ||||||||||||||||||||||||||||||
fileType | int | Specifies whether to create the file in ASCII or binary format. The choices are as follows:
|
||||||||||||||||||||||||||||||
fileAction | int | Specifies the location in the file to begin writing data if the named file already exists. The choices are as follows:
|
Return Value
Name | Type | Description | ||||||||||||||||||||||||||||
status | int | Indicates whether the function succeeded or failed. If the value is –1, –2, or –3, you can use GetFmtIOError to get more information about the type of error that occurred.
|
Additional Information
Library: Formatting and I/O Library
Include file: formatio.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later
Example
Refer to fileio\arrayfile.cws for an example of using the ArrayToFile function.