home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / HAPI.ZIP / HAPI / HAPI_REX / QTIME.CMD < prev   
OS/2 REXX Batch file  |  1991-09-05  |  4KB  |  72 lines

  1. /****************************************************************
  2. * Module Name:  QTIME.CMD                                       *
  3. *                                                               *
  4. * Descriptive Name: Rexx EHLLAPI Sample Program                 *
  5. *                                                               *
  6. * Copyright:    (C) Copyright IBM Corp. 1988, 1991              *
  7. *               Licensed Material - Program Property of IBM     *
  8. *               All Rights Reserved                             *
  9. *                                                               *
  10. * Status:       Release 1.0 Modification 0                      *
  11. *                                                               *
  12. * Function:     Set PC system time using the VM host time.      *
  13. *                                                               *
  14. *               This sample program queries the 3270 VM host    *
  15. *               time using the CP Query Time command. It then   *
  16. *               uses that time to set the PC time-of-day using  *
  17. *               the OS/2 TIME command.                          *
  18. *                                                               *
  19. * Restrictions: This sample program is provided solely as       *
  20. *               an example of how Rexx may be used to invoke    *
  21. *               Communications Manager EHLLAPI functions.       *
  22. *                                                               *
  23. * Module Type:  IBM Rexx Procedures Language                    *
  24. ****************************************************************/
  25. trace value all
  26. signal on halt   name quit              /* Handle error conditions so ... */
  27. signal on error  name quit              /* ... are sure to diconnect      */
  28. signal on syntax name quit
  29.  
  30. session='A'                             /* Use 3270 session A */
  31.  
  32. if Rxfuncquery('hllapi') Then           /* Is Rexx EHLLAPI support loaded?*/
  33.   call Rxfuncadd 'HLLAPI','SAAHLAPI','HLLAPISRV' /* If not, load it..   . */
  34.  
  35. rc=hllapi('Connect',session)            /* Connect to host session A      */
  36. if rc<>0 then do                        /* If did not work, message & exit*/
  37.   say 'Did not connect to host. RC='rc
  38.   signal quit
  39.   end
  40.  
  41. rc=hllapi('Wait')                       /* is host ready for keystrokes?  */
  42. if rc<>0 then do                        /* if not, give a message & exit  */
  43.   say 'Host keyboard locked.'
  44.   signal quit
  45.   end
  46.  
  47. rc=hllapi('Sendkey', '@C')              /* Send a clear key */
  48. rc=hllapi('Wait')                       /* Wait for clear key to complete */
  49. rc=hllapi('Sendkey', '@C')              /* Send a clear key */
  50. rc=hllapi('Wait')                       /* Wait for clear key to complete */
  51.  
  52. rc=hllapi('Sendkey', 'CP Query Time @E')/* Send CP Query Time and Enter   */
  53. rc=hllapi('Wait')                       /* Wait for query time to complete*/
  54.  
  55. pos=hllapi('Search_ps','TIME IS ',1)    /* Look for TIME IS phrase on host*/
  56. if pos=0 then do                        /* If not found, message and exit */
  57.   say 'Host could not process QUERY TIME command.'
  58.   signal quit
  59.   end
  60.                                         /* Copy time XX:XX:XX from host   */
  61. time=hllapi('Copy_ps_to_str', pos + Length('TIME IS '), 8)
  62.  
  63. '@time' time                            /* Set PC time using host time    */
  64.  
  65. rc=hllapi('Sendkey', '@C')              /* Reset host screen by clearing  */
  66. rc=hllapi('Wait')
  67.  
  68. quit:
  69. call hllapi 'disconnect'                /* End the rexx-hllapi connection */
  70. call hllapi 'reset_system'
  71. exit
  72.