|
-
Feb 2nd, 2000, 12:52 PM
#1
Thread Starter
New Member
What is the comand to replace text in an open ascii file? Please help.
-
Feb 2nd, 2000, 04:41 PM
#2
New Member
Originally posted by JohnL55:
What is the comand to replace text in an open ascii file? Please help.
Read your text into a string variable or array whichever best suits your needs and then use instr to find each instance of the text you want to replace. Then use mid$ to replace the text and write it back out to the file.
[This message has been edited by Lemp (edited 02-03-2000).]
-
Feb 2nd, 2000, 09:12 PM
#3
Fanatic Member
The mid() function can be a little combersome for lots of replacements especially if you're replacing the same text (like in a multi find replace program )
read to a string then use the replace function.
FileString = Replace(FileString, OldText, NewText)
For some reason this function is not that well known
-
Feb 2nd, 2000, 10:48 PM
#4
Thread Starter
New Member
Originally posted by Paul282:
The mid() function can be a little combersome for lots of replacements especially if you're replacing the same text (like in a multi find replace program )
read to a string then use the replace function.
FileString = Replace(FileString, OldText, NewText)
For some reason this function is not that well known
When writing FileString back to the document, double quotes are added to the start and end of the string. The double quotes are not in the string to start with.
Take the words NEW DATA. When I write it back, it comes out "NEW DATA". If I replace in the string the Quotes with nothing it does not get rid of the quotes because they are not really in the string.
-
Feb 2nd, 2000, 10:58 PM
#5
Hyperactive Member
It depends on what you use to write the string back to the doc. If you use print it just plain dumps it, if you use write it puts quotes around things. If you look up the Write function it mentions that. That's how I get around it. Write is convienant when writing to a CSV but I use the Print one more often.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|