vbscript - Exception to overwrite -
i have vbscript - if run not want repeating words replacing. there if
statement can add stop doing this?
option explicit const forreading = 1 const forwriting = 2 dim objfso,objfile,strtext,strnewtext set objfso = createobject("scripting.filesystemobject") set objfile = objfso.opentextfile("c:\users\newtons\desktop\text.txt",forreading) strtext = objfile.readall objfile.close strnewtext = replace(strtext, "<jim","<!--<jim") '<pseudocode> if "<!--<jim" = exist nothing end if '</pseudocode> set objfile = objfso.opentextfile("c:\users\newtons\desktop\text.txt",forwriting) objfile.writeline strnewtext objfile.close set objfso = nothing set objfile =
replace <jim
<!--jim
instead of <!--<jim
avoid repeated replacements (i.e. make sure search string isn't substring of replacement string).
Comments
Post a Comment