LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repetitive format string

Does anybody know how to do repetitive formatting?

I have 40 or so numbers that i want to format into a string. My format is "%#g\t". Instead of typing the format 40 times, is there a format specifier so that a could write something like "38x%#g\t" ?

Thanks
0 Kudos
Message 1 of 9
(3,688 Views)
If your numbers are in an array, you can put your format into string in a for loop and run index in the array of numbers. Your output is indexed to output an array of the strings. Doing this it does not matter how many numbers you need to format. The array size will determine how many times your loop will run.

Hope this is what you were looking for.

AJL
0 Kudos
Message 2 of 9
(3,678 Views)
Hi

If you have the numbers in an array, you could convert them using a loop (see attachement).

Otherwise I think there's no possibility to specify one format for >1 numbers.

Hope this helps.

Thomas
Using LV8.0
--------------------------------------------------------------------
Don't be afraid to rate a good answer... 😉
--------------------------------------------------------------------
0 Kudos
Message 3 of 9
(3,672 Views)
Thanks, but that was not what i was looking for. I can also use the format into spreadsheet string, but then everything will be of the same format.
0 Kudos
Message 4 of 9
(3,672 Views)
Well, without wanting to be smart, instead of typing it 40 times, you could always copy and paste.

Seriously.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 5 of 9
(3,661 Views)
He he, that's what i was doing. The difficult part is to count them, especially when some of them is other format, the format string gets looong. I gave up, and ended up with format to spread sheet string. Good olf FORTRAN has this option, so it is strange that LV does not.
0 Kudos
Message 6 of 9
(3,659 Views)
You could build the format string programmatically. I have attached an example of a subvi to which you could pass the existing format string, the format string to be added, and the number of times to add the format string. This may not be quite as slick as typing 38 x format, but it beats having to keep count of your long string.
Message 7 of 9
(3,651 Views)
Thanks, that looks like it will work. I will try it.
0 Kudos
Message 8 of 9
(3,643 Views)
Hi

you can use a list of format specifiers in an array, one entry for each value you want to format (see attachment). format the data in a for-loop and pass the previous data string as the initial string to the next formatting.

best regards
chris
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 9 of 9
(3,642 Views)