cancelar
Mostrando los resultados de 
Buscar en lugar de 
Quiere decir: 

Number format string

Hi to all. I have a question about formatString property when it form a number on indicator or "FormatToString" function.

How can I known the number lenght in simbols by it format string? In some cases it's easy: "%10d" - 10 symbols, but how it works in more complex cases, like "%010_7f" or "%f" or "%g"?

And how calculate symbols after point by formatString?

0 kudos
Mensaje 1 de 8
4.178 Vistas

Hi Forest,

 

use StringLength after the FormatString function!

(Most often FormatIntoString results in a variable amount of chars…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 kudos
Mensaje 2 de 8
4.176 Vistas

@GerdWuse StringLength after...

I want to know it before the function is done.

0 kudos
Mensaje 3 de 8
4.154 Vistas

Hi Forest,

 

then you need to analyze your data - it is much easier to check after the conversion to string…

 

Example:

- value of 1 with a format of %g gets converted to "1.000000" (8 chars)

- value of 1 with a format of %#g gets converted to "1" (1 char)

- value of 1 with a format of %#3g gets converted to "  1" (3 chars)

- value of 1.001 with a format of %#3g gets converted to "1.001" (5 chars)

 

It is much easier to check string length after conversion than to analyze all possible input data with all possible format strings…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 kudos
Mensaje 4 de 8
4.145 Vistas

@GerdW wrote:

then you need to analyze your data - it is much easier to check after the conversion to string…


Not is it just easier, but a lot of the analysis would require at least most, if not all, of the conversion already.  So you might as well check it after the conversion and make your like A LOT simpler.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 kudos
Mensaje 5 de 8
4.126 Vistas

Number of desimal points I calculate like this:
Безымянный.png
And its work in many cases.

0 kudos
Mensaje 6 de 8
4.117 Vistas

@0Forest0 wrote:

Number of decimal points I calculate like this:
Безымянный.png
And its work in many cases.


So you convert two strings into numbers to figure out the decimal length.  Again, that seems wasteful.  Just convert the original number and use Search/Split String and String Length to get your decimal length.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 kudos
Mensaje 7 de 8
4.102 Vistas

When I prepare long string of values I don't know what values (big or not) will convert to string. But I shall put numbers on exactly positions in result string. Then I should know lenght of result string basing on formats of containing values.

0 kudos
Mensaje 8 de 8
4.091 Vistas