LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display Text file content in string control without changing the format

Solved!
Go to solution

Hi All,

 

I need your help! 

 

Im planning to display text report file content in labview string control.

 

when I read the text file and update the string control, text format alignment was not proper.

 

but when I open the same text file in notepad, alignment looks good.

 

how to resolve this text alignment issue ?

 

AlignmentIssue

 

 

Gramy

0 Kudos
Message 1 of 9
(6,182 Views)

String indicators treat tab constants as whitespace. You could use Search and Replace String to replace all tab constants with a finite number of spaces:

 

stringws.png

 

However, this doesn't help if the initial string in the line is a variable character length as your columns will still not line up. You'd need to scan each line of the string (search for line return characters, for instance, to split the lines up) and measure the length of the string before the first tab character (\t), adjusting your number of spaces accordingly.

 

Or, even better, treat your incoming string as a spreadsheet array (tab delimited), convert accordingly and display in a table. Definitely the right way forward!

 

stringws2.png

---
CLA
Message 2 of 9
(6,170 Views)

Another issue is the font you're using in LabVIEW.  Notepad is using a fixed-width font and your LabVIEW string indicator is not.

 

Example_VI_FP.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 9
(6,151 Views)

While your answer is very well, thoult, there is one possible issue with your suggestion with a string array:

The "separator lines"

-----------------------------------------------------------------

It does not display decently in a table view of a 2D array.

 

Nevertheless, there are possible ways to address this, but as the OP can see: They have to be implemented specifically.

And Jim is correct that this specific handling could be related to e.g. the used font.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 9
(6,145 Views)

Pfft, separator line schmeparator line... 😛

 

Just spitballing:

 

stringws3.png

 

As Norbert says, you have to implement that specifically. For something that's only decoration, I wouldn't bother myself.

---
CLA
Message 5 of 9
(6,138 Views)

Edit - removed double post

---
CLA
0 Kudos
Message 6 of 9
(6,137 Views)
Solution
Accepted by topic author GRamy

Run into the same problem before.

 

Simply use a .net textbox to display the text, instead of LabVIEW string.

There is NO need to re-format the string.

 

 

George Zou
Message 7 of 9
(6,115 Views)

Thank you so much for all your replies.

 

I just want to share, I used the same font which is used to print the report in text file, now the text alignment issue is solved...

 

It looks exactly how it is in notepad editor.

 

Ram

0 Kudos
Message 8 of 9
(6,068 Views)

You know why?

Because they use the same window class.

 

 

George Zou
0 Kudos
Message 9 of 9
(6,042 Views)