home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxvim.zip / MESSAGE.CMD < prev    next >
OS/2 REXX Batch file  |  1994-08-18  |  4KB  |  158 lines

  1. /** Message.cmd **/
  2. /******************************************/
  3. /*                                        */
  4. /* Command line syntax:                   */
  5. /*                                        */
  6. /* demo db_path user_password user_name   */
  7. /*                                        */
  8. /*                                        */
  9. /******************************************/
  10. ARG db_path user_pw user_name
  11. '@echo off'
  12. '@cls'
  13. Say 'RexxVIM Message Demonstration Program'
  14. Say
  15.  
  16. /* Unload functions upon error */
  17. SIGNAL ON ERROR NAME done
  18.  
  19. /* Prompt for the parameters if not passed on the */
  20. /* command line                                   */
  21. if LENGTH(STRIP(db_path)) = 0 then do
  22.    Say 'Enter Postoffice Directory,'
  23.    Say 'or press enter if using Lotus Notes -'
  24.    PARSE PULL db_path .
  25.    Say
  26.    Say 'Enter User Name -'
  27.    PARSE PULL user_name
  28.    Say 'Enter Password -'
  29.    PARSE PULL user_pw
  30. end  /* Do */
  31.  
  32.  
  33. /* Load the RexxVIM extensions to Rexx */
  34. rc = RxFuncAdd('RxVIMLoadFuncs', 'REXXVIM', 'RxVIMLoadFuncs')
  35. if rc <> 0 then do
  36.    Say
  37.    Say 'RexxVIM failed to load, return code' rc
  38.    Say
  39.    Say 'Functions have been released.  Retry program.'
  40.    signal done
  41. end  /* Do */
  42. call RxVIMLoadFuncs
  43. Say 'Functions are now loaded'
  44. Say
  45.  
  46.  
  47. /* Initialize the VIM subsystem */
  48. Session = ''
  49. rc = RxVIMInitialize()
  50. Say
  51. Say '|-Call To Routine ---------------RC--|'
  52. Say '  RxVIMInitialize -              ' rc
  53. if (rc > 0) then call vimerr
  54.  
  55.  
  56. /* Open a session with the postoffice using the parameters */
  57. /* provided by the user                                    */
  58. Session = ''
  59. rc = RxVIMOpenSession(db_path,user_name,user_pw,'Session')
  60. Say '  RxVIMOpenSession -             ' rc
  61. if (rc > 0) then call vimerr
  62.  
  63.  
  64. /* Create a new message of type VIM_MAIL */
  65. rc = RxVIMCreateMessage(Session,'VIM_MAIL','Message')
  66. Say '  RxVIMCreateMessage -           ' rc
  67. if (rc > 0) then call vimerr
  68.  
  69.  
  70. /* Set the header text */
  71. hdrtext = user_name"'s config.sys file"
  72. rc = RxVIMSetMessageHeader(Message,'VIMSEL_SUBJECT', hdrtext)
  73. Say '  RxVIMSetMessageHeader -        ' rc
  74. if (rc > 0) then call vimerr
  75.  
  76.  
  77. /* Set the priority to high */
  78. rc = RxVIMSetMessageHeader(Message,'VIMSEL_PRIORITY', 'VIM_HIGH_PRIORITY')
  79. Say '  RxVIMSetMessageHeader -        ' rc
  80. if (rc > 0) then call vimerr
  81.  
  82.  
  83. /* Set the recipient to the user that is logged on */
  84. /* This will send the message back to ourselves    */
  85. rc = RxVIMSetMessageRecipient(Message,'VIMSEL_TO','VIMSEL_ENTITY','','',,
  86.                 user_name,'','')
  87. Say '  RxVIMSetMessageRecipient -     ' rc
  88. if (rc > 0) then call vimerr
  89.  
  90.  
  91. /* Add some text to the message */
  92. itemtxt = 'This message was created using the VIM Toolkit for Rexx!!'
  93. rc = RxVIMSetMessageItem(Message,'VIMSEL_NOTE_PART','VIM_TEXT','VIMSEL_NATIVE',,
  94.          'Message Demo',itemtxt,'')
  95. Say '  RxVIMSetMessageItem -          ' rc
  96. if (rc > 0) then call vimerr
  97.  
  98.  
  99. /* Add the config.sys as a file attachment in the message */
  100. rc = RxVIMSetMessageItem(Message,'VIMSEL_ATTACH','VIM_TEXT','VIMSEL_NATIVE',,
  101.          'config.sys','','c:\config.sys')
  102. Say '  RxVIMSetMessageItem -          ' rc
  103. if (rc > 0) then call vimerr
  104.  
  105.  
  106. /* Send the message */
  107. rc = RxVIMSendMessage(Message)
  108. Say '  RxVIMSendMessage -             ' rc
  109. if (rc > 0) then call vimerr
  110.  
  111.  
  112. /* Close the session with the postoffice */
  113. rc = RxVIMCloseSession(Session)
  114. Say '  RxVIMCloseSession -            ' rc
  115. if (rc > 0) then call vimerr
  116.  
  117.  
  118. /* Terminate the active VIM subsystem connection */
  119. rc = RxVIMTerminate()
  120. Say '  RxVIMTerminate -               ' rc
  121. if (rc > 0) then call vimerr
  122. signal done
  123.  
  124.  
  125. /***** VIMErr *******/
  126.  
  127. /* If an error occurs, this function will return the text */
  128. /* associated with the error.  Extended text may be       */
  129. /* displayed if it exists for the specified error.        */
  130.  
  131. VIMERR:
  132.  
  133. rc = RxVIMStatusText(Session,rc,'Status')
  134. Say
  135. Say '|-Error Information -----------------|'
  136.  
  137. if Status.1 = 'STATUS.1' then
  138.   Say 'Cannot obtain error status information'
  139. else do
  140.   Say '  Error Text -' Status.1
  141.   Say
  142.   Say '  Ext Status -' Status.2
  143. end
  144.  
  145. rc = RxVIMTerminate()
  146. signal done
  147.  
  148.  
  149. /* The done section will unload the RexxVIM extensions */
  150. /* and exit the program                                */
  151. DONE:
  152. /*** Drop all of the external functions ***/
  153. call RxVIMDropFuncs
  154. Say '|------------------------------------|'
  155. Say 'Demo Complete.  All functions released'
  156. 'pause'
  157. exit
  158.