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!

How to change Procomm Plus start date automatically in a script??

Status
Not open for further replies.

JBRMN

Technical User
Jul 21, 2009
17
CA
Hello there, first time as a member here, just like to say thanks is greatly appreciated

I have been looking at some of the date changing info on this site and have not been able to implement it into my script that is suppose to get data every week by dialing up to the modem, but I am having difficulties changing the start date to a week before the date at which the gauge info is downloaded, to get the full week of data. My basic is:

proc main

string Name = "scotch.doc" ; Name of capture file to open.

set capture file Name ; Set name of capture file.

waitfor "NORMAL^[[20;25H"
transmit "u"
;area where i think i need to have a change in the start date

waitfor " ^H"
transmit "s"
waitfor "<<< Press ENTER to Start, A for Ascii, X/Ymodem, or ESC to Abort >>>^@^@^@"

transmit "a"

capture on ; Open up the capture file.
while $CARRIER ; Loop while connected to remote.
yield ; Yield processing time

waitfor "<<< Press ENTER to Continue >>>"
transmit "^M"

capture off ; Close the capture file.

endwhile

endproc






the function below is the one that i am trying to include in my script above, need to change the date after i tell procomm to transmit "u" for upload. but have been unable to do this, does anyone know an easy way?
can i get rid of iDaysAgo and just put a 7 in there??

func XDaysAgo : string
param integer iDaysAgo
integer iDay, iMonth, iYear, iHour, iMin, iSec
long lDate
string sDate

lDate = $LTIME - (86400 * iDaysAgo)
;Derive timeval for specified num. of days ago

ltimeints lDate iYear iMonth iDay iHour iMin iSec ;Convert timeval to integer components

strfmt sDate "%02d%02d%d" iMonth iDay iYear ;Create MMDDYYYY string

strdelete sDate 4 2 ;Delete first two numbers from year value
return sDate

sorry for the mess let me know if you have any ideas!
thanks again

 
Yes, if you just need seven days back, then replace iDaysAgo with 7 in the script, as long as the date you are needing to send is 7 days back from today's date. You might also need to modify the strfmt command in case the system is expecting the date in a different format than MMDDYYYY.

 
thanks for the reply!
I tried to put 7 in for idaysAgo put it didn't like that as an integer name, so i took out the whole line of
"param integer iDaysAgo". I tried to put a call function in the program to call the program when it needs to change the date, but haven't been unable to get it to work.
Is the format of the output correct if i want in the end to have
"7/23/2009" end up to be "7/16/2009"
how would i include these dashes in the printout...

here is what i have so far


proc main

string Name = "Omagh.doc" ; Name of capture file to open.

set capture file Name ; Set name of capture file.

waitfor "NORMAL^[[20;25H"
transmit "u"
waitfor " ^H"

transmit "d"
waitfor " ^H"

Call XdaysAgo

transmit "s"
waitfor "<<< Press ENTER to Start, A for Ascii, X/Ymodem, or ESC to Abort >>>^@^@^@"
transmit "a"

capture on ; Open up the capture file.
while $CARRIER ; Loop while connected to remote.
yield ; Yield processing time


waitfor "<<< Press ENTER to Continue >>>"
transmit "^M"

capture off ; Close the capture file.

endwhile

endproc


func XDaysAgo : string

integer iDay, iMonth, iYear, ihour, imin, isec
long lDate
string sDate

lDate = $LTIME - (86400 * 7)
;Derive timeval for specified num. of days ago

ltimeints lDate iYear iMonth iDay ihour imin isec ;Convert timeval to integer components

strfmt sDate "%02d%02d%d" iMonth iDay iYear ;Create MMDDYYYY string


return sDate

endfunc


thanks in advance for any suggestions
 
Since you are not passing any arguments in with the function, the param line can be removed as you have done. What you do need to do though is assign the output of your function to a string variable. I am thinking you probably want something like Name = XDaysAgo() to get a date-specific capture file name.

As for the slashes you want to use, those cannot be in the filename due to Windows restrictions. If you want to use dashes instead, you could change the strfmt command to look
like this:

strfmt sDate "%02d-%02d-%d" iMonth iDay iYear ;Create MMDDYYYY string

 
I see, I don't really need to have a date specific capture file name, I'd rather just have the file omagh.doc updated every week with the new data, and then from there we can edit it if we need to. I'm getting errors for having NAME in the code when i insert the above line??
where would i assign the ouput to a string variable and what would this look like
thanks again

Justin
 
I am wondering if it might be easier for me to just make a script that will waitfor "MM/DD/YYYY" and transmit "start date" that way it can be automated but i would just have to change this script every week. How can i call up a script to execute in another script??

cheers,
Justin
 
Sorry for the confusion, the file is being captured in a continuous file that is edited in excel to remove any problem and then moved to another spreadsheet for archives.
basically what i need is to automate a script to go through the commands to upload a file with a sutron 8210 data logger after it autoconnects, There are 10 different dams that we upload data from the water gauges. It becomes a little tedious, we would like to upload every sunday night so I was trying to find a way to take the date and subtract seven days from it, I am finding this is a little more trickier than i thought and have not been too successful yet.

My last post was in thought of instead of having a code in every ten of my scripts to change the date, I could just use the record a script function and record me changing the date back seven days and make that a script in it's own(which i already know how to do). If I could call this script within each of my ten scripts because they will all have the same time frame for uploading, that would serve the same purpose. How do I do this?? Then it would just be a matter of changing the actual date in the one script every week... let me know where you need more clarification

cheers,

Justin
 
You can use the execute command to launch a second script and have return control to the first script once the second one has completed. Does that do the trick for what you need?

 
Hey Knob, Thanks for the tip! should do the trick. I am just having trouble implementing the excute command into my script. The aspect help window only gives an example of an execute command where it asks the user what script they would like to run, I don't want this, how do I modify this to run "changingdate.was" script automatically at a certain point in my script?
thanks for the help,

cheers,

Justin
 
All you would need is this line:

execute "changingdate.was"

Keep in mind that specifying the .was file instead of the compiled .wax file will cause the script to be compiled before it is launched. That shouldn't be an issue as long as the script compiles OK.

 
Hey knob thanks for the help with the execute function seems to work pretty good. I am having one problem with when I go to test it and upload the data. The capture turns off within 40 seconds of being connected and I only get part of my data captured. Is there an easy way to tweak my script so it will stay on until all the data is uploaded?
Here is my parent script;

proc main

string Name = "Kelso.doc" ; Name of capture file to open.

set capture file Name ; Set name of capture file.

waitfor "NORMAL^[[20;25H"
transmit "u"

execute "changingdate.was" ; executes the changingdate script start date must line up with procomm

waitfor "<<< Press ENTER to Start, A for Ascii, X/Ymodem, or ESC to Abort >>>^@^@^@"
transmit "a"

capture on ; Open up the capture file.
while $CARRIER ; Loop while connected to remote.
yield ; Yield processing time


waitfor "<<< Press ENTER to Continue >>>"
transmit "^M"

capture off ; Close the capture file.

endwhile

endproc


Here is the changingdate.was script that is being called:

proc main

transmit "d"
waitfor "08/06/2009^H^H^H^H^H^H^H^H^H^H08" ; must change to appropriate end date, the day the data will be downloaded

transmit "7/29/2009^M" ; must change to appropriate start date when you want data to be downloaded from

waitfor " ^H"

transmit "s"
endproc
 
when I try each of my dams that I have to upload and get the data from, The only one that works fully is the one that takes less than thirty seconds to upload all the data once connected? Could there been some time limit on the capture? or something? just thought I'd try to give as much info as possible, if you need any clarification just ask

cheers,

Justin
 
after reading through some later posts, I have looked at the monitor window and noticed that this script, the capture always turns off at a certain part in the uploading data so I have attached the monitor window for you to see, looks like right around the blue 0D it turns the capture off.
 
How long does the report take to come down? If it's more than 30 second, your waitfor "<<< Press ENTER to Continue >>>" command is timing out since the default timeout value for waitfor is 30 seconds and then continuing on to the next commands. You can add the FOREVER flag to the end of the command to have it pause until that string appears.

 
Hey knobs, Thanks for sticking with me with this one, I think that was just what the code needed to capture all the data I want,
Thanks again for all your help, couldn't of done it without you,

cheers,

Justin
 
Another question for ya, I have set it up that each dam has its own script and it is set to automatically use after it connects, I want to be able to schedule my 10 dams to upload on monday morning. each one has a different connection and a different script it runs. i set it up in the scheduler in procomm and seems like it would work, except that when doing more than one in the scheduler I need to exit the script of the previous dam before the scheduler goes on to the next dam...whats the best way to do this, let me know if you want me to clarify something
 
yeah i don't think my scripts are not ending for some reason, in the connection directory i have set each dam to once connected run thier approriate script, the problem is that the script doesn't end it just appears to keep running and doesn't let another one start in the scheduler, I don't think I need to close that Procomm window and open a new one for the next script. what if I put a disconnect function in will that terminate the script, also tried using exit statement haven't work for yet, how im i suppose to use these for it to actually work... and tricks

thanks again

JBRMN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top