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!

Capture File aspect script only grabs the first 10 lines of data!

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
US
Here is a sample of the aspect script that I am using to Capture a file at the specific time.

proc main
integer iYear, iMonth, iDay, iHour, iMin, iSec

while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iHour >= 16
if iMin >= 30
capture on
exitwhile
endif
endif
endwhile

while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iHour >= 06
if iMin >= 00
capture off
endif
endif
endwhile
endproc


As you can see this script starts at 4:30 p.m and is suppose to grab everything till 6:00 a.m . But for some weird reason the file that it makes grabs only the first 10 or 12 lines of data and then closes. Any clue why? I am using the defualt file names assigned by Prcomm Plus 4.8
Thanks a Lot.
 
What is the time and date stamp on the file? It looks to me like the second while loop will run and exit almost immediately (closing the capture file) since iHour would be <= 6 just after the first while loop exited (iHour >= 16). If so, you can change the first if statement in the second while loop to be:

if (iHour >= 06) && (iHour < 16)

This will keep the first if statement from being true until 6 AM the next morning.


aspect@aspectscripting.com
 
Well it worked knob!! But only for one day. And that is weird. I ran it and it worked great for one day.But When I checked it the next day, not even a file was created. Any clue why? I am using the default Procomm file name. So its creates files with names pw01, pw02, etc.

Thank you very much.

 
By looking at your original post, the program will only run once, after 06:00 your second endwhile will kick you out of the loop, and endproc.

Try putting both while loops inside a loop... Of course, put in some code to control the exiting of the program, and close any open files....

proc main
integer iYear, iMonth, iDay, iHour, iMin, iSec

while1

while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iHour >= 16
if iMin >= 30
capture on
exitwhile
endif
endif
endwhile

while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iHour >= 06
if iMin >= 00
capture off
endif
endif
endwhile
;code here to look for some type of exit command and include exitwhile
endwhile
endproc


You may want to look at the yield command also, if your cpu lags.
 
pragmatic, thanks for the reply. One last question ...why would I need any code to exit the big while loop?? Because I dont want the script to ever stop capturing files for me!
Can't I just make the big while true, so that it keeps running.

Also I was thinking of putting the year as a condition, how do I do that. Suppose I want the big loop to run till next year and capture files everday at the same time.How can I do that?

Thanks a Lot.
 
Since you are already using the ltimeints command to get the month, day, etc. (including the year), you could save the value of iYear to a different variable that you never overwrite (say iYearStart). Then, each time your script runs the ltimeints command, insert an if statement checking for iYear == iYearStart. If this is false, meaning that the year has changed on your script, the else clause can then issue an exit command to shut down the script.


aspect@aspectscripting.com
 
Does this work??

proc main
integer iYear, iMonth, iDay, iHour, iMin, iSec

while 1
if iYear = 2003
while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iHour >= 16
if iMin >= 30
capture on
exitwhile
endif
endif
endwhile

while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if (iHour >= 06) && (iHour < 16)
if iMin >= 00
capture off
endif
endif
endwhile
endif
endwhile
endproc

I am not very sure of the aspect syntax either...so couldnt implement knob's idea. Thanks a lot guys.
 
Here's a version of your script that should exit if the year returned by the first ltimeints command returns a year that does not match the year value received when the script was started.

proc main
integer iYear, iMonth, iDay, iHour, iMin, iSec
integer iCurYear

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
iCurYear = iYear

while 1
while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iYear != iCurYear
exit
endif
if iHour >= 16
if iMin >= 30
capture on
exitwhile
endif
endif
endwhile

while 1
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if (iHour >= 06) && (iHour < 16)
if iMin >= 00
capture off
endif
endif
endwhile
endwhile
endproc

aspect@aspectscripting.com
 
Well my boss doesnt seem to stop *frustrated*
He thinks this script will eat up 100% of the CPU resources. Do you think it will guys? He wants me to add some sort of 'sleep' function in the script so that it doesnt keep running the while loop. any ideas?

Thanks a lot guy for all the help. really appreciate it.
 
What does the yield command do? Should I add it after each while 1?
Can u direct me to a link which has aspect script syntax, like a reference book.? I couldnt find any reference pdf files.
Thanks a Lot.
 
Hereis what the ASPECT help file (Help | Script Reference menu item in Procomm) says about the yield command:

Suspends script execution, allowing other tasks within Procomm Plus to continue execution until ASPECT is permitted to resume script execution by the system.

Example

See the example for getfile.

Comments

Under Windows NT 4.0, the following loop can monopolize CPU utilization when, in fact, the script needs to peform very little processing:

while 1 ; while TRUE would also work
.
.
.
endwhile

To prevent this wasteful CPU utilization, place a yield command at the end of the while loop.

aspect@aspectscripting.com
 
Ok now I am getting desperate. Now that I cut down on the CPU resources using yield, my script only runs for one day. So I am back on square one! :( I need this to work everday and capture the file between 4:30 p.m and 6 a.m.

Please I need help. Here is the script.

proc main
integer iYear, iMonth, iDay, iHour, iMin, iSec
integer iCurYear

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
iCurYear = iYear

while 1
yield
while 1
yield
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if iYear != iCurYear
exit
endif
if iHour >= 16
if iMin >= 30
capture on
exitwhile
endif
endif
endwhile

while 1
yield
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
if (iHour >= 06) && (iHour < 16)
if iMin >= 00
capture off
endif
endif
endwhile
endwhile
endproc
 
Try adding exitwhile after the capture off command. What I think is happening is that your script is stuck in the second while 1 loop (or third actually) and is never able to get out to the main while loop. Does your script actual stop running or just doesn't create a second capture file?


aspect@aspectscripting.com
 
It just doesnt create a second capture file. So I only have one file which is created on the day I start the script.I will try the exitwhile solution.
Thanks knob, appreciate all the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top