LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add end of line constant (CR & LF) to large text entry

I wrote a LabVIEW program to read a large array of U32 numbers from a text file. However when I want to save the data for use in an Arduino project (ASCII text file) I wanted to limit the width to 80 characters. I thought it would be trivial to do, but ended up spending more time than I expected. It's been a long week so I might just be brain dead at the moment, but here was my solution. Anyone have thoughts on a better way to do it?

 

(I am searching for the commas that separate values and if it's more that 80 characters into the string, add an EOL to the PREVIOUS comma)

 

format_array_string.png

Download All
0 Kudos
Message 1 of 4
(742 Views)

How about this?

80colums.png

 

80colums2.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 4
(729 Views)

Sorry I forgot to say, I want the EOL after commas. My raw data looks something like this:

 

static const PROGMEM uint32_t LUT[232] = {520, 18350600, 33554432, 50331648, 67108864, 83886080, 100663296, 117440512,134217728, 150994944, 167772160, 184549376, 201326592, 218103808, 234881024, 251658240, 268435456, 285212672, 301989888,318767104, 337642504, 354681864, 371721224, 388760584, 405799944, 422839304, 439878664, 456918024, 473957384, 490996744,508036104, 525075463, 542115848, 558957064, 575799816, 592708616, 603979776, 620756992, 637534208, 654311424, 671088640,687865856, 704643072, 721420288, 738197504, 754974720, 771751936, 788529152, 805306368, 822083584, 838860800, 855638016,872415232, 889192448, 905969664, 922746880, 939524096, 956301312, 973078528, 989855744, 1006632960, 1023410176, 1040187392, 1056964608, 1073741824, 1090519040, 1107296256, 1124073472, 1140850688, 1157627904, 1174405120, 1191182336, 1207959552,1224736768, 1241513984, 1258291200, 1275068416, 1291845632, 1308622848, 1325400064, 1342177280, 1358954496, 1375731712,1392508928, 1409286144, 1426063360, 1442840576, 1459617792, 1476395008, 1493172224, 1509949440, 1526726656, 1543503872,1560281088, 1577058304, 1593835520, 1610612736, 1627389952, 1644167168, 1660944384, 1683489828, 1700529188, 1717568548,1734607908, 1751647268, 1768686628, 1785725988, 1802765348, 1819804708, 1836844068, 1853883428, 1870922788, 1887962148,1905001508, 1922040868, 1939080228, 1956119588, 1973158948, 1990198308, 2007237668, 2024277028, 2041316388, 2058355748,2075395108, 2092434468, 2109473828, 2126514212, 2143552548, 2160592932, 2164260864, 2181038080, 2197815296, 2214592512,2231369728, 2248146944, 2264924160, 2281701376, 2298478592, 2315255808, 2332033024, 2348810240, 2365587456, 2382364672,2399141888, 2415919104, 2432696320, 2449473536, 2466250752, 2483027968, 2499805184, 2516582400, 2533359616, 2550136832,2566914048, 2583691264, 2600468480, 2617245696, 2634022912, 2650800128, 2667577344, 2684354560, 2701131776, 2717908992,2734686208, 2751463424, 2768240640, 2785017856, 2801795072, 2818572288, 2835349504, 2852126720, 2868903936, 2885681152,2902458368, 2919235584, 2936012800, 2952790016, 2969567232, 2986344448, 3003121664, 3019898880, 3036676096, 3053453312,3070230528, 3087007744, 3103784960, 3120562176, 3137339392, 3154116608, 3170893824, 3187671040, 3204448256, 3221225472,3238002688, 3254779904, 3271557120, 3288334336, 3305111552, 3321888768, 3338665984, 3368812817, 3385590033, 3402367249,3419144465, 3435921681, 3452698897, 3469476113, 3486253329, 3503096081, 3519873297, 3536650513, 3553427729, 3570204945,3586982161, 3603759377, 3620536593, 3637379345, 3654156561, 3670933777, 3687710993, 3704488209, 3721265425, 3738042641,3754819857, 3771662608, 3788439824, 3791650816, 3808428032, 3825205248, 3841982464, 3858759680, 3875536896}

 

Screenshot 2022-02-18 154305.png

0 Kudos
Message 3 of 4
(720 Views)

I'd do it thusly. 

 

Add EOL to end of input string. Use Split String.vi from the Hidden Gems pallet to get an array of strings.

 

Initialize a SRs with an empty string array and an empty string scalar into a For loop and auto index the string array.

 

Concat string scalar SR,  comma, space and string element.  Get strlen.  Create case structure selector on strlen length case 0...79 place concatenated string on scaler SR. 

case default concat previous string SR content with EOL add to string array SR and place the New string element on string scalar SR.  

 

You might want to test that the max string length is less than 80 but the above should work .

 

Just, inside out from your approach. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 4
(706 Views)