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

Last Transmit Sent

Status
Not open for further replies.

hankm3

Programmer
Jan 27, 2002
284
US
Hello,

I am Transmitting a List of Numbers to a remote Database and collecting the Data in a Capture File. If I lose Carrier to the Database, is it possible to store the Last Number sent, so when I re-connect to the Database again, I can start the Transmit at the Point of Carrier Lost.

Example:

555-1212
555-1213
555-1214 # Carrier Lost
555-1215
555-1216

Reconnect: and Transmit

555-1214
555-1215
555-1216

Thanks as Always

 
Seems to me the easiest thing to do is keep track of the last number that was sent successfully. I'm not sure how your script is set up, but here's some pseudocode on one way to do this:

string sNum
string sLastNumSent

transmit sNum
do necessary processing...
if number sent successfully
sLastNumSent = sNum
endif

If your connection dropped (you could test for this by looping while $CARRIER == 1 or use a when target $CARRIER command that calls a resume procedure when the connection is dropped), you could then again call the procedure that is processing the different numbers. This procedure could then pick up where it left off by using the number *after* the value of sLastNumSent.

Now that I think about, an even better way to do this would be to do away with the sLastNumSent variable and just use sNum to keep track of what number you were working withng with when the connection was dropped. You could then call the procedure that handles transmitting the information and resume where you left off, since the value of sNum should not have changed.

A lot of this depends on how you have your script architected, but hopefully this gives you a couple ideas to work with. Let me know if you have any more questions.
 
Knob,

This is what the script consists of.

proc main
string sLine
string szName="566_INQ.cap" ; Create a Name for the Capture File
;clear
set capture overwrite on
set capture query off
set capture file szName
Capture on
fopen 1 "C:\TEXT FILES\566_FOMS.txt" READ
while not feof 1
fgets 1 sLine
Transmit "^M"
Waitfor "[HF]FCR%"
clear
Transmit "INQ^M"
Waitfor "_"
Transmit "H TN "
Transmit sLine
Transmit "^M"
Waitfor "_"
Transmit ".^M"
Pause 10
endwhile
fclose 1
capture off
Transmit "^M"
Waitfor "[HF]FCR%"
usermsg "Done with INQ"
endproc

Thanks

Hank
 
I would leave the list fiel open and add a carrier status check and a redialing subroutine to start the connrction up again:


proc main
string sLine
string szName="566_INQ.cap" ; Create a Name for the Capture File

SubConnect() ; Calls the connect and login routine.

;clear
set capture overwrite on
set capture query off
set capture file szName
Capture on
fopen 1 "C:\TEXT FILES\566_FOMS.txt" READ
while not feof 1
fgets 1 sLine
If $Carrier = 0
SubConnect() ; This will reconnect and login whenever you are disconnected.
Endif
Transmit "^M"
Waitfor "[HF]FCR%"
clear
Transmit "INQ^M"
Waitfor "_"
Transmit "H TN "
Transmit sLine
Transmit "^M"
Waitfor "_"
Transmit ".^M"
Pause 10
endwhile
fclose 1
capture off
Transmit "^M"
Waitfor "[HF]FCR%"
usermsg "Done with INQ"
endproc

Proc SubConnect
;Connection and Login commands go here
EndProc


Thanks

Hank Robert Harris
Communications Advantage
 
Thanks for the Suggestions. But I must also state that if the connection is Broken, Lose of Carrier, I must Log Back in and Start the Script again.You have to use a Secure ID Card to gain Access to the Database and then Start the Script.. I played with storing a Number in the S0 System Parmeter. That saves the Number even if Procomm is exited and restarted.

Any additional items are welcome...

Hank
 
If you will run the entire script again in the event of a failure, you could save the current number to a file on disk and have your script check for existence of that file when it starts. Your script then reads through the orginal data file until it finds the number specified in your saved state file, and then resumes from there. This method would require that your script remove the file it creates so future runs of your script do not access it.

Another possibility is that your script could use the fdelblock command to delete the string from the text file after it has been processed completely. In the event that the connection is dropped, you would just save your data file and pick up from the beginning of the file when your script runs again. Since you have deleted the processed data from the file, you will be picking up where the interruption occurred. This would require that you open the file as READWRITE.
 
Thanks Knob / Robert..

Had to overcome a few issues; but this seems to work. I tried both the $Carrier and $Connectopen Functions to see if either are faster. Negative on that. I still lose about 2 Records before the Exitwhile Kicks in; but that is an acceptable number. 2 out of 750 is not too bad. Took Knob's approach about deleting the Lines as I worked thru the File. Had to add a Safeguard in case of Double Line Feeds at EOF.

This was the result:

#define _RECSIZE 10 ; IE: 565-1234(CR)(LF)

proc main
string sLine
string szName = "xxx_INQ.cap"
clear
set capture overwrite on
set capture query off
set capture file szName
Capture on
fopen 1 "C:\TEXT FILES\xxx_FOMS.txt" READWRITE TEXT
while not feof 1
if $Connectopen == 0 ; If Modem Connection is Lost
usermsg "Connection Lost !"
exitwhile
else
fgets 1 sLine
Transmit "^M"
Waitfor "[HF]FCR%"
clear
Transmit "INQ^M"
Waitfor "_"
Transmit "H TN "
Transmit sLine
Transmit "^M"
Waitfor "_"
Transmit ".^M"
Pause 5
fseek 1 0 0 ; Start of List File
fdelblock 1 _RECSIZE ; Delete Line string (sLine)
if NULLSTR sLine
exitwhile ; Prevents Endless Loop
endif
endif
endwhile
fclose 1
capture off
if $Connectopen == 1
Transmit "Q^M"
Waitfor "[HF]FCR%"
endif
usermsg "Done with INQ"

Once I reestablish the Connection, I start the Script again at the Last TN Sent.

Thanks Again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top