CSVFIELD_TO_ARG

CSVFIELD_TO_ARG 1:

The function converts the value from a data field in CSV format which is present as byte buffer into a PLC variable. Double quotation marks in the data field are replaced with simple quotation marks. If the bQM parameter is set (QM = quotation marks) the outer quotation marks (around the data field) are removed from the input data. If successful the function returns the length of the converted data. In the event of an error or if the length of the input data is zero the function returns the value zero. The application must ensure the PLC target variable is large enough to accommodate the value.

The function is usually used together with the function block FB_CSVMemBufferReader in order to read (parse) data sets that are stored in the PLC memory in CSV format. Before this operation the CSV data sets are usually read from a file into the PLC memory. In contrast to the CSVFIELD_TO_STRING function this function can also be used to convert CSV data fields with binary data into PLC variables. 

FUNCTION CSVFIELD_TO_ARG: UDINT

VAR_INPUT

VAR_INPUT
    pInput   : POINTER TO BYTE;
    cbInput  : UDINT;
    bQM      : BOOL;
    out      : T_Arg;
END_VAR

pInput: Start address (pointer) to a byte buffer containing the data field to be converted in CSV format. The address can be determined with the ADR operator.

cbInput: Length of the data field to be converted in bytes. The length can be determined with the SIZEOF operator.

bQM: If this input is TRUE the enclosing quotation marks are removed from the field data.

out : PLC target variable into which the value of the data field is to be written (type: T_Arg).

Example:

See example in the documentation for the ARG_TO_CSVFIELD function block.

Further information can be found here: Example: Writing/reading of a CSV file.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)