vbscript - Specific Lines after first occurrence of keyword -
vbscript - Specific Lines after first occurrence of keyword -
i have file in able find keyword using vbscript farther need maintain copying next 3-4 lines downwards it, until find occurrence of similar pattern of keyword. have written - ( newbee assume dumb )
set fso = createobject("scripting.filesystemobject") set infile = fso.opentextfile("filename", 1) set outfile = fso.opentextfile("filename", 8, true) outfile.writeline("this sample data.") stranswer = inputbox("please come in value:", _ "enter value") until infile.atendofstream line = infile.readline if instr(line, stranswer) outfile.writeline line ' re-create line , write output file sernum = left(line, 7) 'if not ((line = infile.readline()) 'take first 3 char , find next occurance of 'copy lines until line wscript.echo "found" end if loop outfile.close set fso = nil
any suggestion appreciable.
you utilize sub-loop go on writing until serial number found again.
do until infile.atendofstream line = infile.readline if instr(line, stranswer) outfile.writeline line ' re-create line , write output file sernum = left(line, 7) ' go on writing until eof or serial number found... while not infile.atendofstream line = infile.readline if instr(line, sernum) = 0 outfile.writeline line loop end if loop
vbscript
Comments
Post a Comment