By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,030 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,030 IT Pros & Developers. It's quick & easy.

A VBScript for text search in .txt file.

P: n/a
Guys,

I'd love if any of you can help me with this one.
I need a script that will take out the words Error,
Warning, and Aborted from a 12mb text file and into a new
text file after running the script.
Please.

Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
* "Roomy" <ra**@medonline.com.au> scripsit:
I need a script that will take out the words Error,
Warning, and Aborted from a 12mb text file and into a new
text file after running the script.


Notice that this is a VB.NET language group, but your question is
related to VBScript programming:

You may want to ask the question in this group:

<news://news.microsoft.com/microsoft.public.inetsdk.programming.scripting.vbs cript>

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
Cor
Hi Roomy,

This is a VB.net group, that is not VB script.
Therefore I think you can better ask this too in a VB script newsgroup.

Most probably you don't get an answer here because the people who visit this
newsgroup are not very familair with VB script.
Although most of them knows a lot of it.

But your problem can be a hell of a job with VB.script.

When you want to use VB.net tell it than someone will probably help you.

Sorry that I could not help you

Cor
Nov 20 '05 #3

P: n/a
here's some old code from the cellar. it is meant to recurse through a dev
branch, find all the dlls and ocx files, create a dos batch that executes to
un/register them. all you have to do is modify it to your liking. you'll
need to use the file scripting object, open the file and and maybe instr$
for a text match. easy, breezy, beautiful cover girl!

next time, if you're not familiar w/ netiquette (a word overly used in a
very long thread today), please post questions to groups that have some
correlation to the context/language of your quandry.

hth,

steve
' ====== snip =======

Private mfso
Private mfd
Private mRegStream
Private mURegStream
Private mcstrHeader
Private mcstrErrText
Private mcstrFooter
Private mlngPtr
mcstrHeader = "@echo off" & vbCrLf & "cls" & vbCrLf & "echo [REG]..." &
vbCrLf & vbCrLf & "set has_err=0" & vbCrLf & "set errors=0" & vbCrLf & "set
e_text=0" & vbCrLf & vbCrLf
mcstrErrText = "if errorlevel=1 Set has_err=1" & vbCrLf & "if errorlevel=1
set errors=[SEQ]" & vbCrLf & "if errorlevel=0 set e_text=%errors%" & vbCrLf
& vbCrLf
mcstrFooter = "set e_text=Error, Line %e_text%" & vbCrLf & vbCrLf & "if
%has_err%==0 set e_text=No Errors" & vbCrLf & vbCrLf & "cls" & vbCrLf &
"echo [REG]!" & vbCrLf & "echo %e_text%" & vbCrLf & "pause"
mlngPtr = 0
mlnghFileReg = 1
mlnghFileUReg = 2
If MsgBox("Create Un/Register Batch Files?", vbYesNo, "Dll Auto-Register") =
vbYes Then
Set mfso = CreateObject("Scripting.FileSystemObject")
Set mfd = mfso.GetFolder("C:\")
Set mRegStream = mfd.CreateTextFile("Register.bat", True, False)
Set mURegStream = mfd.CreateTextFile("UnRegister.bat", True, False)
mRegStream.Write Replace(mcstrHeader, "[REG]", "Registering")
mURegStream.Write Replace(mcstrHeader, "[REG]", "Un-Registering")
SetDllRegText "C:\Your Project\Dev\"
mRegStream.Write Replace(mcstrFooter, "[REG]", "Registered")
mURegStream.Write Replace(mcstrFooter, "[REG]", "Un-Registered")
mRegStream.Close
mURegStream.Close
MsgBox "Done.", vbOKOnly, "Dll Auto-Register"
End If

Private Sub SetDllRegText(ByVal strSearchPath)
Dim dr
Dim sfld
Dim f
Dim strPrintData
If Right(strSearchPath, 1) <> "\" Then strSearchPath = strSearchPath &
"\"
Set dr = mfso.GetFolder(strSearchPath)
For Each f In dr.Files
If Right(LCase(f.Name), 4) = ".dll" Or Right(LCase(f.Name), 4) =
".ocx" Then
mlngPtr = mlngPtr + 1
strPrintData = Replace(mcstrErrText, "[SEQ]", mlngPtr)
mRegStream.Write "regsvr32.exe " & """" & strSearchPath & f.Name
& """ /s" & vbCrLf & strPrintData
mURegStream.Write "regsvr32.exe /u " & """" & strSearchPath &
f.Name & """ /s" & vbCrLf & strPrintData
End If
Next
If dr.SubFolders.Count Then
For Each sfld In dr.SubFolders
If Err.Number Then Exit For
SetDllRegText sfld.Path
Next
End If
End Sub
Nov 20 '05 #4

P: n/a
z

"Roomy" <ra**@medonline.com.au> wrote in message
news:03****************************@phx.gbl...
Guys,

I'd love if any of you can help me with this one.
I need a script that will take out the words Error,
Warning, and Aborted from a 12mb text file and into a new
text file after running the script.


I had a similar problem the other day, and ended up using a brilliant
freeware utility called AutoIt.

Here is the download page http://www.computerhope.com/dutil.htm
I also made the mistake of asking the question the wrong group, so apologies
everyone for the original error, and persisting in this error with a
solution.

Nov 20 '05 #5

P: n/a
Cor
Hi Roomy,
I also made the mistake of asking the question the wrong group, so apologies everyone for the original error, and persisting in this error with a
solution.


What is wrong with that

VB.net has a

Try
..................The one who has a problem
Catch
.................. Regulars in this group or all others
Finnaly
.................. You
End Try
:-))
Cor
Nov 20 '05 #6

P: n/a
* "z" <no***********@btopenworld.com> scripsit:
I also made the mistake of asking the question the wrong group, so apologies
everyone for the original error, and persisting in this error with a
solution.


You don't need to apologize. Directing you to the right group was only
a hint for you to get a response in shorter time. You are welcome to
post your VB.NET related questions to this group.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

P: n/a
* "Cor" <no*@non.com> scripsit:
What is wrong with that

VB.net has a

Try
.................The one who has a problem
Catch
................. Regulars in this group or all others
Finnaly ^^^^^^^

Nice typo.

;-)
................. You
End Try


--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #8

P: n/a
lol. programmer to the end!

;^)
"Cor" <no*@non.com> wrote in message
news:O5*************@TK2MSFTNGP09.phx.gbl...
| Hi Roomy,
| > I also made the mistake of asking the question the wrong group, so
| apologies
| > everyone for the original error, and persisting in this error with a
| > solution.
|
| What is wrong with that
|
| VB.net has a
|
| Try
| .................The one who has a problem
| Catch
| ................. Regulars in this group or all others
| Finnaly
| ................. You
| End Try
| :-))
| Cor
|
|
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.