;PWHostsXfer.WAS   v1.0

;*****************************************************************************
;*                                                                           *
;* PWHostsXfer.WAS                                                           *
;* Copyright (C) 1998 Symantec                                               *
;* All rights reserved.                                                      *
;*                                                                           *
;* Written by:  Symantec ASPECT Assist                                       *
;* 12/19/97                                                                  *
;*                                                                           *                                                                             
;* This script file calls multiple locations and transfers/receives files.   *
;* This script assumes that all the Hosts are running Procomm Plus Hosts and *
;* accept Remote ASPECT commands. The script also prints the Connection log. *
;*                                                                           *
;* This ASPECT script is intended only as a sample of ASPECT programming.    *
;* Symantec makes no warranty of any kind, express or implied, including     *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*                                                                           *
;* Technical Support is not provided on this script.                         *                                                                          *
;*****************************************************************************


;*****************************************************************************
;*   MACRO DEFINITIONS                                                       *
;*****************************************************************************

#DEFINE NUMBEROFCALLS 1                ;put number of places to call here
#DEFINE ENTRY1 "8,875-0503"            ;holds first number
#DEFINE ENTRY2 ""                      ;holds second number
#DEFINE ENTRY3 ""                      ;holds third number
#DEFINE TIMEINTERVAL 1                 ;can be 1 or 2 hours


;*****************************************************************************
;*   GLOBAL VARIABLES                                                        *
;*****************************************************************************

string NumberToDial                    ;holds number to dial


;*****************************************************************************
;*                                                                           *
;* MAIN                                                                      *
;* The Main procedure calls GetNumber to get the phone number to dial, calls *
;* PlaceCall to dial the number, calls PerformCmds to perform the remote     *
;* commands and to transfer files, and calls PrintLog to print the daily     *
;* data connection log.                                                      *
;*                                                                           *
;* Calls: GETNUMBER, PLACECALL, PERFORMCMDS, PRINTLOG                        *
;* Modifies globals: NONE                                                    *
;*                                                                           *
;*****************************************************************************

proc main 
integer CurCall

   for CurCall = 1 upto NumberOfCalls
      GetNumber(CurCall)               ;gets the current number to dial
      PlaceCall()                      ;calls procedure to make calls
      PerformCmds()                    ;calls procedure to perform cmds
   endfor
   PrintLog()                          ;calls procedure to print log file
   set autodnld ON                     ;this will reset setting set earlier
   
endproc


;*****************************************************************************
;*                                                                           *
;* GETNUMBER(CURCALL)                                                        *
;* The procedure GetNumber determines the phone number to call.              *
;*                                                                           *
;* NOTE:  This procedure will need to be modified to add numbers to call.    *
;*        This is done simply by adding an additional case statement.  For   *
;*        example:  case 4                                                   *
;*                     NumberToDial = Entry4                                 *
;*                  endcase                                                  *
;*        The Entry4 would need to be defined in the Macro section.          *
;*                                                                           *
;* Calls: NONE                                                               *
;* Called by: MAIN                                                           *
;* Modifies globals: NUMBERTODIAL                                            *
;*                                                                           *
;*****************************************************************************

proc GetNumber
param integer CurCall

   switch CurCall                      ;retrieves the info on number to call
      case 1                           ;first number
         NumberToDial = Entry1         ;set the number to dial
      endcase
      case 2                           ;second number
         NumberToDial = Entry2         ;set the number to dial
      endcase
      case 3                           ;third number
         NumberToDial = Entry3         ;set the number to dial
      endcase
   endswitch
      
endproc


;*****************************************************************************
;*                                                                           *
;* PLACECALL()                                                               *
;* The procedure PlaceCall dials remote system and loops while dialing.      *
;*                                                                           *
;* Calls: NONE                                                               *
;* Called by: MAIN                                                           *
;* Modifies globals: NUMBERTODIAL                                            *
;*                                                                           *
;*****************************************************************************

proc PlaceCall

   dialnumber DATA NumberToDial        ;dials the number
   while $DIALING                      ;loops while dialing
   endwhile
   
endproc


;*****************************************************************************
;*                                                                           *
;* PERFORMCMDS()                                                             *
;* The procedure PerformCmds performs remote aspect commands and transfers   *
;* files to and from the remote system.                                      *
;*                                                                           *
;* Calls: GETTIME                                                            *
;* Called by: MAIN                                                           *
;* Modifies globals: NONE                                                    *
;*                                                                           *
;*****************************************************************************

proc PerformCmds
integer XferProgress
integer StopHr, StopMin
integer Hour, Min

   if $CARRIER
   ;**This section sends files from the specified directory to remote.***

   transmit "^D COMPANY set dnldpath `"C:\Test`" ^D" ;switch directory
   pause 2                             ;wait for system to process cmd
   sendfile ZMODEM "C:\Test\TestFile.*"
   XferProgress = 1
   while XferProgress                  ;waits until transfer complete
      XferProgress = $XFERSTATUS       ;gets current xfer status
   endwhile

   ;**This section sends files from specified directory to remote.***  

   transmit "^D COMPANY set dnldpath `"C:\Test`"^D"
   pause 2                             ;wait for system to process cmd
   transmit "^D COMPANY set ZMODEM receiver crashrecover TIMESTAMP^D"
   pause 2                             ;wait for system to process cmd
   GetTime(&StopHr, &StopMin)
   sendfile ZMODEM "C:\Test\*.BMP"
   XferProgress = 1
   while XferProgress 
      ltimeints $LTIME i0 i1 i2 Hour Min i3
      if Hour == StopHr && Min == StopMin
         sendkey ALT 'C'               ;used to abort transfer.  
                                       ;PW must be active window
         pause 5                       ;wait time to cancel xfer
         exitwhile
      endif
      XferProgress = $XFERSTATUS
   endwhile
 
   ;**This section sends files from remote specified directory to local.***

   set dnldpath "C:\Test"
   transmit "^D COMPANY set upldpath `"C:\Test`"^D"
   pause 2                             ;wait time to process cmd
   transmit "^D COMPANY sendfile ZMODEM `"*.*`"^D"
   pause 2                             ;time to process cmd
   set autodnld OFF
   GetTime(&StopHr, &StopMin)
   getfile ZMODEM 
   XferProgress = 1
   while XferProgress 
      ltimeints $LTIME i0 i1 i2 Hour Min i3
      if Hour == StopHr && Min == StopMin
         sendkey ALT 'C'               ;used to abort transfer.  
                                       ;PW must be active window
         exitwhile
      endif
      XferProgress = $XFERSTATUS
   endwhile
   while 1
      winactivate "ZMODEM"
      if FAILURE
         exitwhile
      endif
   endwhile
   else
      statmsg "Unable to establish carrier.  Try again later"
   endif
   
endproc


;*****************************************************************************
;*                                                                           *
;* GETTIME(StopHr, StopMin)                                                  *
;* The procedure GetTime gets the current time and calculates the stop time  *
;* for the transfer.  Valid times are 1 or 2 hour intervals.  This is defined*
;* in the macro section.                                                     *
;*                                                                           *
;* Calls: NONE                                                               *
;* Called by: PERFORMCMDS                                                    *
;* Modifies globals: NONE                                                    *
;*                                                                           *
;*****************************************************************************

proc GetTime
param integer StopHr, StopMin

integer Hour
   
   ltimeints $LTIME i0 i1 i2 Hour StopMin i3
   if TIMEINTERVAL == 1
      StopHr = Hour + 1
      if StopHr == 24
         StopHr = 0
      endif
   endif
   if TIMEINTERVAL == 2
      StopHr = Hour + 2
      if StopHr == 24
         StopHr = 0
      else
         if StopHr == 25
            StopHr = 1
         endif
      endif
   endif
   
endproc


;*****************************************************************************
;*                                                                           *
;* PRINTLOG()                                                                *
;* The procedure PrintLog prints the data connection log.                    *
;*                                                                           *
;* Calls: NONE                                                               *
;* Called by: MAIN                                                           *
;* Modifies globals: NONE                                                    *
;*                                                                           *
;*****************************************************************************

proc PrintLog

   menuselect pwmenu 206                ;selects connection log from PWMENU
   while 1
      winactivate "Fax / Data Combined Connection Log" ;check to see if active
      if SUCCESS                        ;if it is
         exitwhile                      ;exit loop
      endif
   endwhile
   sendvkey 0x28                        ;snd down arrow key to move to data log
   while 1
      winactivate "Data Connection Log" ;check to see if box is active
      if SUCCESS                        ;if it is
         exitwhile                      ;exit loop
      endif
   endwhile
   sendkey ALT 'P'                      ;send print command to connection log
   while 1
      winactivate "Print"               ;check to see if Print window is active
      if SUCCESS                        ;if it is
         exitwhile                      ;exit loop
      endif
   endwhile
   sendvkey 0x0D                        ;send enter key to print
   while 1
      winactivate "Data Connection Log" ;check to see if box is active
      if SUCCESS                        ;if it is
         exitwhile                      ;exit loop
      endif
   endwhile
   sendkey ALT 'C'                      ;sends keys to close connection log
endproc      