LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete line in string

Hi there:
 
I have a text file like the following, and I wanna delete all the lines with a // in front of them and make the vector numbers to be continuous. Anybody knows how to write a VI to work this out?
 
Thanks in advance
 
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 H ; // vector 1548
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 L ; // vector 1549
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 L ; // vector 1550
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 H ; // vector 1551
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 H ; // vector 1552
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 L ; // vector 1553
// scan vector end
//  End chain test
//  Scan_test
//  Pattern 0 Cycle 334 Loop 1554
            >stuck_at_faults_rev1_1_tp0 1 0 0 0 X ; // vector 1554
// scan vector start
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1555
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1556
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1557
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1558
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1559
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1560
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1561
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1562
 
What I like the format is like this:
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 H ; // vector 1548
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 L ; // vector 1549
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 L ; // vector 1550
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 H ; // vector 1551
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 H ; // vector 1552
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 L ; // vector 1553
            >stuck_at_faults_rev1_1_tp0 1 0 0 0 X ; // vector 1554
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1555
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1556
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1557
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1558
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1559
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1560
            >stuck_at_faults_rev1_1_tp0 1 1 1 0 X ; // vector 1561
            >stuck_at_faults_rev1_1_tp0 1 1 0 0 X ; // vector 1562
 
 
0 Kudos
Message 1 of 6
(7,646 Views)

Hi,

Here's how you can go about doing it ...isn't it better to teach how to fish rather than providing a fish?  Smiley Very Happy

1.  Read the contents fo the file.  You can either read-in the entire file as one big string, or can read one line at a time.  There are VIs in the File I/O palette for doing both.

2.  Check each line for the first two characters.  There are functions in the String palette for doing this.

3.  If they are forward-slashes, ignore the line.  And go to the next one.  (If you read the file contents as a single character, you can use the newline character "\n" to know where the line ends). 

Hope this gest you started.  Maybe you can post your VI if you run into some difficulties. 

-Khalid

 

0 Kudos
Message 2 of 6
(7,640 Views)

thanks but it is not helpful.

I can not find the right functions to do so.

Actually before I posted I have tried to do it using Scan Scan From String . The format string is not working.

and the help of the Labview is too less information .

Anybody can help me ?

Scans the input string and converts the string according to format string. Use this function when you know the exact format of the input text. Alternatively, you can use the Scan From File function to scan text from a file. The connector pane displays the default data types for this polymorphic function. Details  

0 Kudos
Message 3 of 6
(7,609 Views)
Easiest would be to get each line, then keep it if it contains the substring "stuck". You can easily modify it so it deletes lines that start with "//".
 
Both possibilities are demonstrated in the attached example (LabVIEW 7.0).
 
Of cours in your case you would replace the string control with "read characters from file".

Message Edited by altenbach on 12-13-2005 03:31 PM

Message 4 of 6
(7,600 Views)
Hi altenbach:
    It works, thanks a lot.
0 Kudos
Message 5 of 6
(7,593 Views)
I don't know who is giving you single stars in this thread, it is certainly not me...
0 Kudos
Message 6 of 6
(7,565 Views)