You can take a look at the function PV_ninfo (B&R Online Help)
This function take the name of your variable as STRING pointer and give you back what is the datatype, the lenght in bytes and the dimension if it’s array or structure.
Using this you can identify all variables in your structure and convert them 1 by 1 and depending on the datatype.
By the way if your generated string is format as JSON there is existing library that does it, you can check about :
Essentially My data structure is composed of two data structures, which contain different data types; some bools, some sints, some ints, etc…
I need to be able to map these onto a String of length 472 bytes, so I can then send to my sigmatek controller.
Quickly drawn Diagram of what the AB copy function does.
I don’t know if this is already solved? Are you saying that you want the ASCII value of the variables to be copied as bytes to the string? I am not aware of any function (block) which would solve your use case. You would probaby have to write your own, here is a simple example:
This will make a byte out of your BOOLs, and then copy the numeric value as the corresponding ASCII sign to the string. The SINT is one byte already so you can just copy it directly.
Now, depending on if your structure ever changes, you could either have it hard coded like in my example, or you could make it more dynamic with pv_ninfo, to iterate through the whole structure and read the data types of each structure member.