Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to move the same line of text from a capture file.

Status
Not open for further replies.

chief39

Technical User
Aug 4, 2002
14
US
I need to take the same line of text from the captured text file and move it to new file. The line is an address that changes each time but it is in the same place in the capture file every time. Capture file looks like this:

Loc: 1305 W Strasburg Rd,

I need 1305 W Strasburg Rd only this address changes all the time but the format is the same. I also need to over write that file each time, The file has to be the same name.

Thanks

 
Here's a script that will read the specified file (test.txt in your ASPECT directory in this case) and output the address to output.txt (also located in the ASPECT directory):

proc main
string sLine
string sOutput

if fopen 0 "test.txt" READ TEXT
while not feof 0
fgets 0 sLine
if strfind sLine "Loc:"
strtok sOutput sLine ":" 2
strdelete sOutput 0 1
if fopen 1 "output.txt" CREATE TEXT
fputs 1 sOutput
endif
fclose 1
endif
endwhile
endif
fclose 0
endproc

The contents of output.txt will be ovewritten each time the script is run (as long as it find a string with Loc: in the file).


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top