paulk29
Technical User
- Jul 15, 2003
- 113
Hi all,
I've written a program using some tips and code from this forum which has been great. I'm just looking for approval and maybe tips on how to make my code more effiicent.
Basically Procomm monitors com1 and starts a capture file when Carrier is detected, reads this Data from Com1 into the Capture file until Carrier is lost. Then opens the MAIL mode and dials up My internet connection and sends the email with the attached file.
I have a few questions;
1. Is there a command to initiate my dialup networking connection, in this case "iol"?
2. Is there a way of telling if PPP authentication has passed or failed, basically I'm waiting for Carrier and then pausing 5secs til PPP authenticates?
3. Finally is there commands to create, attact file to and send an email rather than just using screen scrap/screen keystrokes?
I've included My Code below.
Thanks for all the help.
Slán
Paul
;**********************************************************
string sCapPath, sCapFile, sCapFile2, sNewFile
integer iYear, iMonth, iDay, iHour, iMin, iSec
string sCurrentDialog
string Msg = "Sending New Messages" ;Caption of sending dialog
integer iRC
;***********************************************************
; MAIN PROGRAM WITH A FOREVER LOOP
;***********************************************************
proc main
connect DATA "comms" ;Com1 at 9600, 8none1.
commandmode on ;turns on AT command mode
clear ;clears the screen
while 1
when $CARRIER call carrier_change ;when carrier change
yield
endwhile
endproc
;***********************************************************
; CHANGE IN CARRIER STATE ROUTINE
;***********************************************************
proc carrier_change
if $CARRIER == 1 ;if Carrier present
capture on
else ;if Carrier is lost turn capture off
capture off
clear
call copy_to_file
call email
endif
connect DATA "comms" ;Com1 at 9600, 8none1.
endproc
;***********************************************************
; ROUTINE TO COPY CAPTURED DATA TO FILE
;***********************************************************
proc copy_to_file
set capture file "temp.txt"
fetch capture path sCapPath
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sNewFile "02%d02%d02%d" iHour iMin iSec
strcat sNewFile ".TXT"
strfmt sCapFile "%s\temp.txt" sCapPath
strfmt sCapFile2 "%s\%s" sCapPath sNewFile
shortpath sCapFile sCapFile
rename sCapFile sCapFile2
endproc
;***********************************************************
; EMAIL ROUTINE
;***********************************************************
proc email
call dialup
connect MAIL "email" ;Create email message
pause 3
sendkeystr "The subject"
pause 3
sendkey ALT 'M' ;Open Message menu
pause 3
sendkey 'A'
pause 3
sendkeystr sCapFile2 ;Attach File
pause 3
sendkey ALT 'O'
mspause 250
sendkey 0x09
sendkeystr "Please open attached file" ;email text
sendkey ALT 'M' ;Open Message menu
mspause 250
sendkey 'M'
mspause 250
sendkey ALT 'A'
mspause 250
sendkey 'S' ;Select Send and Receive menu item
wintext $ACTIVEWIN sCurrentDialog
strcmp sCurrentDialog Msg iRC
while 1 ;Loop while sending
yield
wintext $ACTIVEWIN sCurrentDialog
strcmp sCurrentDialog Msg iRC
if (iRC != 0)
exitwhile ;exit loop when sending complete
endif
endwhile
pause 10
if winactivate "Error Window" ;If mail error window is detected
sendkey 0x20
endif
hangup ;hang up call
pause 5
endproc
;***********************************************************
; DIALUP ROUTINE
;***********************************************************
proc dialup
connect DATA "email" ;pointing procomm to modem.
pause 3
pwmode 3 ;changes mode to MAIL
sendkey ALT 'M' ;Do a send and recieve
mspause 250 ;to activate
sendkey 'M' ;dial up networking
mspause 250 ;connection
sendkey ALT 'A' ;to the internet
mspause 250 ;...............
sendkey 'S' ;...............
waitfor "$CARRIER" ;waits for modem to connect to ISP
pause 5 ;gives PPP 5secs to authenticate
endproc ;return to proc email
;***********************************************************
I've written a program using some tips and code from this forum which has been great. I'm just looking for approval and maybe tips on how to make my code more effiicent.
Basically Procomm monitors com1 and starts a capture file when Carrier is detected, reads this Data from Com1 into the Capture file until Carrier is lost. Then opens the MAIL mode and dials up My internet connection and sends the email with the attached file.
I have a few questions;
1. Is there a command to initiate my dialup networking connection, in this case "iol"?
2. Is there a way of telling if PPP authentication has passed or failed, basically I'm waiting for Carrier and then pausing 5secs til PPP authenticates?
3. Finally is there commands to create, attact file to and send an email rather than just using screen scrap/screen keystrokes?
I've included My Code below.
Thanks for all the help.
Slán
Paul
;**********************************************************
string sCapPath, sCapFile, sCapFile2, sNewFile
integer iYear, iMonth, iDay, iHour, iMin, iSec
string sCurrentDialog
string Msg = "Sending New Messages" ;Caption of sending dialog
integer iRC
;***********************************************************
; MAIN PROGRAM WITH A FOREVER LOOP
;***********************************************************
proc main
connect DATA "comms" ;Com1 at 9600, 8none1.
commandmode on ;turns on AT command mode
clear ;clears the screen
while 1
when $CARRIER call carrier_change ;when carrier change
yield
endwhile
endproc
;***********************************************************
; CHANGE IN CARRIER STATE ROUTINE
;***********************************************************
proc carrier_change
if $CARRIER == 1 ;if Carrier present
capture on
else ;if Carrier is lost turn capture off
capture off
clear
call copy_to_file
call email
endif
connect DATA "comms" ;Com1 at 9600, 8none1.
endproc
;***********************************************************
; ROUTINE TO COPY CAPTURED DATA TO FILE
;***********************************************************
proc copy_to_file
set capture file "temp.txt"
fetch capture path sCapPath
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sNewFile "02%d02%d02%d" iHour iMin iSec
strcat sNewFile ".TXT"
strfmt sCapFile "%s\temp.txt" sCapPath
strfmt sCapFile2 "%s\%s" sCapPath sNewFile
shortpath sCapFile sCapFile
rename sCapFile sCapFile2
endproc
;***********************************************************
; EMAIL ROUTINE
;***********************************************************
proc email
call dialup
connect MAIL "email" ;Create email message
pause 3
sendkeystr "The subject"
pause 3
sendkey ALT 'M' ;Open Message menu
pause 3
sendkey 'A'
pause 3
sendkeystr sCapFile2 ;Attach File
pause 3
sendkey ALT 'O'
mspause 250
sendkey 0x09
sendkeystr "Please open attached file" ;email text
sendkey ALT 'M' ;Open Message menu
mspause 250
sendkey 'M'
mspause 250
sendkey ALT 'A'
mspause 250
sendkey 'S' ;Select Send and Receive menu item
wintext $ACTIVEWIN sCurrentDialog
strcmp sCurrentDialog Msg iRC
while 1 ;Loop while sending
yield
wintext $ACTIVEWIN sCurrentDialog
strcmp sCurrentDialog Msg iRC
if (iRC != 0)
exitwhile ;exit loop when sending complete
endif
endwhile
pause 10
if winactivate "Error Window" ;If mail error window is detected
sendkey 0x20
endif
hangup ;hang up call
pause 5
endproc
;***********************************************************
; DIALUP ROUTINE
;***********************************************************
proc dialup
connect DATA "email" ;pointing procomm to modem.
pause 3
pwmode 3 ;changes mode to MAIL
sendkey ALT 'M' ;Do a send and recieve
mspause 250 ;to activate
sendkey 'M' ;dial up networking
mspause 250 ;connection
sendkey ALT 'A' ;to the internet
mspause 250 ;...............
sendkey 'S' ;...............
waitfor "$CARRIER" ;waits for modem to connect to ISP
pause 5 ;gives PPP 5secs to authenticate
endproc ;return to proc email
;***********************************************************