LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change two elements in an array from double to integer.

I have my program working just fine until it comes to saving the file. I have a 2 dimensional array that has data at 0,0 0,1 and 0,2. It is being displayed perfectly the way I have it set up. The problem is where it comes to saving the file. I want elements 0,0 and 0,1 to be an integer and 0,3 to be a fractional number. I can only save it as one or the other. I am sending the data to a write to text file VI which only allows one or the other. Does anyone have any ideas of how to over come this? I know from probing that the data is getting to the write to text file VI in the format that I want it to.

Thanks,
Troy
0 Kudos
Message 1 of 6
(2,996 Views)
You cannot have a mixture of data types in an array. The array elements must be all integer or all double, etc. No way around that. You can have a mixture of data types in a cluster. You can unbundle the cluster elements and write them to a data file so that your file can contain a mixture of data types. Or you can convert the elements into a string and write them to a text file. Why must some elements be integers? Seems like 1.0 and 1 are the same. Can you not make them all doubles? When reading back from the file, you can convert the ones you want to be integers by using the typecast function or the numeric conversion functions.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 6
(2,983 Views)
If I understand you correctly, you want to format your file output with different formats, depending on the column in the array.
You can easily built your ASCII strings using different formats, e.g. put your array into an autoindexing FOR loop where you format each row with e,g, "%.0f %.0f %.5f \n", then append the string to a shift register initialized with an empty array.
Take the final string and write it to your file using e.g. "write charcters to file".
Message 3 of 6
(2,975 Views)
Thank you both for the suggestions. I am sure I can make one of them work.
0 Kudos
Message 4 of 6
(2,961 Views)
altenbach - I am trying to use the method you suggested. I am having trouble getting the rows to format as you have explained. I guess I am not understanding the concept fully. Would you happen to have an example you could attach that I can use as a reference?

Thanks,
Troy
0 Kudos
Message 5 of 6
(2,947 Views)
0 Kudos
Message 6 of 6
(2,943 Views)