Hello everyone, i have attached the following block that features a cluster consisting of different data types, numeric, string boolen and 1D array. Then i convert the data to a variant data and i create variant array. However when i try to save the data to a text file i get a result that isnt fully readable. I expect a result such as
Solved! Go to Solution.
why do you expect such a result?
When you convert your cluster into a variant it not just takes the included data, but also all "additional" information (like cluster element labels and datatypes) - and it will also write all this information into the file!
When you don't want all that additional information you need to convert your cluster content into text "manually" - using UnbundleByName followed by FormatIntoString might lead to one solution…
The closest thing will probably be Flatten to JSON or Flatten to XML to get something readable. As GerdW said, there is other meta data that is contained within a cluster that needs to be considered as well. JSON or XML will handle that for you. You can also read that text file back in.
I attached a sample code that produce a similiar result you expect. If you want to use it with variants, you simply have to call the Variant to Data function on the corresponding variant and use the reference of the result cluster. In this case you must wire a cluster type constant which has the same controls as the variant has inside, to the Variant to Data function.
However, as the others pointed out before me. It is easier if you use flatten to string or flatten to xml functions.
Thank you for the time and effort and put in to help me.I tried different functions and i found out flatten to JSON worked the best out for me.