andysuth
08-15-2007, 05:36 AM
I'm looking for a bit of code to open text files and delete about four or five different types of lines.
These are trail files for ProE and I want to get rid of mouse movements automatically and comments that aren't needed:
e.g. Comments:
!%CIDatum planes will be displayed.
(always start with a '!')
e.g. Zooms:
~ Wheel `main_dlg_cur` `proe_win` \
9 809 831 458752 0 1529 947 1920 1200 107781
('~ Wheel' starts two lines)
I've tried similar to the replace command:
Sub filemoder()
Dim VFF As Long, trailwpath As String, trailoutput As String, trailbody As String, trailbodyO As String, vIStep As String
trailwpath = "C:\Path\trailfile.txt"
trailoutput = "C:\Path\trailfile2.txt"
VFF = FreeFile
Open trailwpath For Binary As #VFF
trailbody = Space$(LOF(VFF))
Get #VFF, , trailbody
Close #VFF
trailbodyO = Replace(trailbody, "!", "")
Open trailoutput For Output As #VFF
Print #VFF, trailbodyO
Close #VFF
End Sub
But with poor results. Mainly because it just takes out the "!" comment denoter. So the file then falls over
I was thinking maybe read the file line by line and then only write to next file string if it didn't read the "!" or the "~ wheel", but I don't know how to do that.
Any ideas?
-AS
These are trail files for ProE and I want to get rid of mouse movements automatically and comments that aren't needed:
e.g. Comments:
!%CIDatum planes will be displayed.
(always start with a '!')
e.g. Zooms:
~ Wheel `main_dlg_cur` `proe_win` \
9 809 831 458752 0 1529 947 1920 1200 107781
('~ Wheel' starts two lines)
I've tried similar to the replace command:
Sub filemoder()
Dim VFF As Long, trailwpath As String, trailoutput As String, trailbody As String, trailbodyO As String, vIStep As String
trailwpath = "C:\Path\trailfile.txt"
trailoutput = "C:\Path\trailfile2.txt"
VFF = FreeFile
Open trailwpath For Binary As #VFF
trailbody = Space$(LOF(VFF))
Get #VFF, , trailbody
Close #VFF
trailbodyO = Replace(trailbody, "!", "")
Open trailoutput For Output As #VFF
Print #VFF, trailbodyO
Close #VFF
End Sub
But with poor results. Mainly because it just takes out the "!" comment denoter. So the file then falls over
I was thinking maybe read the file line by line and then only write to next file string if it didn't read the "!" or the "~ wheel", but I don't know how to do that.
Any ideas?
-AS