|
-
Mar 21st, 2000, 02:10 AM
#1
Thread Starter
Lively Member
What would be the best way to open a text file, find a string, delete it, perform an action then add the string back to the text file? !!!
ie
open text file
find "wibble"
if it exists - delete it
close text file
perform some action
open text file
add "wibble"
close text file
Any ideas people?
Simon
-
Mar 21st, 2000, 05:58 AM
#2
transcendental analytic
I didn't test it but try this out:
'This will open a file:
Open filename For Binary As #1
File = Space(LOF(#1))
Get #fnum, , filevar
Close #1
'And this will search it for the string and remove it:
a=instr(filevar,string)
filevar=left(filevar,a-1) & mid(filevar,a+len(string))
'This will put it back in the file
Open filename For Binary As #1
Put #1, , filevar
Close #1
'This will add string
Open filename for append as #1
Print#1, string;
close #1
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
|