Split a CSV Reply
hard
Splits a comma-separated reply from a weld controller into five REAL values.
What it teaches
Each field is taken out of the text and converted, as the second number was in Two Numbers From a Reply, and the same step repeats for every field, starting where the last one ended: '182.5,24.1,7.6,14.0,3.25' has five. The last field, 3.25, has no comma after it, so it runs to the end of the text. A shorter reply leaves old values behind: '1.5,2' after that reply leaves 7.6, 14.0 and 3.25 in the last three elements unless they are cleared first.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| Out_Count | Output | DINT | 0 | How many fields the reply has |
| Ref_Reply | InOut | STRING | — | A weld controller reply such as '182.5,24.1,7.6,14.0,3.25' |
| Ref_Values | InOut | REAL[5] | — | Current, voltage, wire speed, gas flow and arc time |
Required behavior
- A weld controller reports its current, voltage, wire speed, gas flow and arc time as numbers separated by commas: '182.5,24.1,7.6,14.0,3.25'. A reply never has more than five fields.
- Every scan, Ref_Values[0] to Ref_Values[4] hold the fields in order, and Out_Count is how many fields the reply has. The last field has no comma after it.
- A reply with fewer than five fields fills the elements it has and sets the rest to 0.0. An empty reply has no fields.
- Never change Ref_Reply.