This configuration file contains a library of scripting functions used to read/write data between a CSV file and a list. These utilities now include functionality to copy a file off of a USB memory device into internal memory. This is the only way to access an external file. The CopyFileTo/From USB function reads and writes files from the Scripting folder location. Scripting can only access files located in the Scripting folder, file system management functions are not available which means you cannot access files located in other folders. Files loaded under Customer Extensions are located in a different folder and are therefore not accessible from scripting with the exception of those Powervision Library Functions that specifically expect access to that folder.
CSV files must be formatted with the RFC 4180 specification.
This configuration was created in Powervision 4.797 but the scripts can be copy/pasted to any other version, Download Version 2.1 of the Example Here.
At the top of the script file are variables named “FileNameIn” and "FileNameOut" , this is where you will name your CSV files to operate on, for example: “MyFile.txt”
Copy the file you wish to read onto a USB Memory device then load it using the on-screen buttons. Each button executes a specific function so you can see how each one operates. Status indicators will display the state of each function.
void WriteListFromFile(int type) –
This function is used to write a list from a CSV file specified by the FileNameIn variable listed at the top of the script library. To call this function, enter an array of the type of primitive each column is starting after the first column: 1 for int/bool, 2 for strings. All columns of the list must be named CSVList_Column_ColumnNumber such as "CSVList_Column_1". There are 2 switch statements in the function that must have cases equal to the number columns you want written too, simply add or remove cases to reach the desired number.
void WriteFileFromList(int type, int offsets) –
This function writes to a CSV file specified by the FileNameOut variable at the top of script.
To use this function, the first input parameter is a array of ints, with each int representing a column in the list and the type of variable in the column that you wish to export.
1 = int, 2 = string, 0 = ignore column.
Secondly you need to pass the column byte offsets which is a byte count starting from 0 for each column you want to export. You can find the number of bytes assigned to each column in the CSVList then add them up to find byte offsets for each column to be exported. This will write from the list named "CSVList"
Please sign in to leave a comment.