How to convert a Numeric table to string table

Hi All,

I have a float table(numData) of length 55, I want to convert it to a string table (sData) so that I can write to a file in a SD card.
How can I loop through the number table and convert each element of the table to string element of the string table.
Is there a way to convert numeric table to string table?
an example to do this conversion might be helpful.

Thanks,

If you’re okay with Optoscript, here is a quick way:

for i=0 to 54 step 1
  FloatToString(numData[i], Width, Decimals, sTemp);
  sData[i] = sTemp;
next

code gives me syntax error that "unable to find variable or command i. even when i put i=0; at the beginning.

You need to set up “i” as an integer variable in your strategy.

FWIW, it doesn’t have to be called “i”, you can name it whatever you want - it’s just a normal variable.

thanks …I did add this to the strategy this works now…(too bad we cant initialize variable in script).
I am getting error -23 that destination string too short? what can be this.

-23, Error, Destination string too short., DataReading, 34, N/A, sData String,

NO KIDDING!!! This is on my wishlist!

What did you set width too in the FloatToString command?
What is the string length of your string table?

FloatToString(tableNum[n1], 8, 4, sTemp);

I assume width will be total characters including decimal? my number varies i.e 2.11, 3445.22, 33.4567 etc.

will varying numbers can be a problem.

Yes, width is the total width including decimal. You can always click on the command help when your cursor is on the command and it will explain the parameters.

The FloatToString will pad the left side with spaces, so sTemp will have a string length of 8 all the time, and if the number will be longer than that, I believe it fills sTemp with *****.

Is sTemp or the string length of your string table you are assigning sTemp to shorter than 8? That is the only thing I can see that will cause your error -23.

Thanks …indeed sTemp was shorter. it fixed the problem, I might change this code to while loop or better use table length , it will easier if I want to add some more variables