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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Items in a Text File 2

Status
Not open for further replies.

MyFlight

Technical User
Feb 4, 2002
193
Help,
I have a script file that accesses a Phonemail system to Purge Mailboxes and then change the Password for these boxes. It accesses a File (Textfile.txt) that contains the list of extensions. i need to be able to count these extensions and provide a total number when the script file finishes.
Any suggestions will be greatly appreciated. If you need the Script file let me know and I will send it.

Thanks in advance.
 
Are you reading each line from the file as your script executes? If so, you could create an integer variable and assign it zero before you read from the file, then increment the variable by one for each line of text it reads from the file. aspect@aspectscripting.com
 
Hello,

Here's an Example that I put together. Maybe it will help you out.

Testfile.txt:

hank.txt
hank.bat
hank.exe
matt.txt
matt.bat
matt.exe
jane.txt

Aspect Script:

Proc Main

Integer T = 0
Integer B = 0
Integer E = 0
String sLine
String Output

fopen 1 "c:/files/testfile.txt" Read
While not feof 1
fgets 01 sLine
If strfind sLine ".txt"
T++
Endif
If strfind sLine ".bat"
B++
Endif
If strfind sLine ".exe"
E++
Endif
Endwhile
fclose 1
strfmt Output "Txt File Found: %d" T
Termwrites Output
Termwrites "`n`r"
strfmt Output "Bat File Found: %d" B
Termwrites Output
Termwrites "`n`r"
strfmt Output "Exe File Found: %d" E
Termwrites Output
Termwrites "`n`r"
Endproc

Hope this helps...

Hank
camphm@bellsouth.net
 
If you need to count only what was modified, you could use the an integer that is updates each time the while procedure is run.


Integer T = 0

While not feof 0
Transmit "^M"
Waitfor "Password :"
transmit YOURSTRINGVARIABLE
transmit "m"
Waitfor (whatever the next prompt is)
Transmit ";^M"
Waitfor "Subscriber Name or Extension :"
T++
(Script back to password field)
Endwhile Robert Harris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top