Re: ^M characters in the files
From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 03/17/04
- Next message: Steve Fulton: "Re: ^M characters in the files"
- Previous message: Torgeir Bakken (MVP): "Re: Problem with VBScript and ActiveX"
- In reply to: madan: "^M characters in the files"
- Next in thread: Steve Fulton: "Re: ^M characters in the files"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 17 Mar 2004 23:17:15 +1100
That's what windows text files look like in binary editors
such as 'vi' and 'gvim'.
Why did you begin a new thread ?
>From what O/S are these files you're parsing ?
What editor are you using ?
Cheers.
Chris Val
"madan" <anonymous@discussions.microsoft.com> wrote in message
news:368C3F44-558C-40FF-B0B8-35B600F4EB02@microsoft.com...
| Hello All:
|
| I would like to do token replacements in FileB using FileA. I was able to do this
(thanks to Steve). The script works fine. But the problem is once it writes to the file,
it is appending ^M character for every token that has been replaced. How do I fix the
problem? Any help is appreciated. I have enclosed the script at the end of the file.
|
| FileA:
| ====
| HOST_NAME = aaa.bbb.com
| PORT_NUMBER = 80
| INSTALL_LOCATION = c:\temp
|
| FileB:
| ===
| machine_name = HOST_NAME
| machine_ port = PORT_NUMBER
| install_location = INSTALL_LOCATION
|
| FileB looks like below after the script is executed:
|
| machine_name = aaa.bbb.com^M
| machine_ port = 80^M
| install_location = c:\temp ^M
|
| How do I get rid of the extra character in the script?
|
| Script:
| ==========================================================
| Const ForReading = 1, ForWriting = 2
| Set FSO = CreateObject("Scripting.FileSystemObject")
|
| With New RegExp
| .Pattern = "^(.*?) = (.*)$"
| .Multiline = True
| .Global = True
| Set Tokens = .Execute(FSO.OpenTextFile(FILE_A, ForReading, False).ReadAll)
| End With
|
| B = FSO.OpenTextFile(FILE_B, ForReading, False).ReadAll
|
| For Each Token In Tokens
| B = Replace(B, Token.Submatches(0), Token.Submatches(1))
| Next
|
| FSO.OpenTextFile(FILE_B, ForWriting, False).Write B
| ===========================================================
|
| Thanks in advance,
| Madan
- Next message: Steve Fulton: "Re: ^M characters in the files"
- Previous message: Torgeir Bakken (MVP): "Re: Problem with VBScript and ActiveX"
- In reply to: madan: "^M characters in the files"
- Next in thread: Steve Fulton: "Re: ^M characters in the files"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|