I need to loop this script thru a list of about 100 files and perform the exact same operation on each file, then save the new as 100 new files. I have not been able to get that to work form me.. Any ideas? The files in question in this example are 701.cap and $aaa.txt...
Proc Parse
Count=0
num=0
num2=0
if fopen 0 "C:\Program Files\symantec\Procomm Plus\Aspect\traffic_fields.txt" READ ; open the Fields textfile
while not feof 0 ; Exit Loop at the end of the file
fgets 0 szline ; Retrieve the next line
strtok srchField[Count] szline "," 1 ; Enter the field header into an array
strtok holdthis szline "," 1 ; Retrieve the position for each field
atoi holdthis chrlen[Count] ; Convert the position to an integer and store in an array
Count += 1 ; Increment the counter
endwhile
fclose 0 ; Close the Fields textfile
endif
fopen 1 "C:\Program Files\symantec\Procomm Plus\Aspect\$aaa.txt" CREATE TEXT ; Create a new textfile
if fopen 0 "C:\Program Files\symantec\Procomm Plus\Capture\701.cap" READ TEXT ; Open the capture file (unless already open)
while not feof 0 ; Exit at the end of the file
fgets 0 szline ; Retrieve the next line
for Count2 = 0 upto Count-1 ; Loop to check each field
if strsearch szline srchField[Count2] ; Look for the field header in each line
strtok holdthis szline " " chrlen[Count2] ; Retrieve ASCII string according to field position (i.e. 9 = 9th field on the line)
strlen holdthis num ; Assign num the value of the length of the character string
if count2 == Count-1 ; places every entry on seperate line (csv)
fputs 1 holdthis
else
fwrite 1 holdthis num ; write the string to the output textfile
fwrite 1 "," 1 ; delimit the fields with a comma
endif
endif
endfor
If strsearch szline "Thu " ; Find the start line stats (day of week??)
strtok holdthis szline " " 4
atoi holdthis num2 ; Convert above number to an integer
fputs 1 holdthis
if num2 > 0 ; If the integer isn't null
fgets 0 szline ; then go to the 4th line down which is the
fgets 0 szline
fgets 0 szline
fgets 0 szline ; start of the line stat data.
while not strsearch szline "# exit"
strlen szline num2 ; Determine the character length of the line
if num2 > 45 ; If character length is >45 it is a line stats info line
fputs 1 szline ; Write the data to a new line in the output text file
endif
fgets 0 szline ; get the next line
endwhile
endif
endif
endwhile
endif
fclose 0
fclose 1
endproc