home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexvim.zip / MESSAGE.CMD < prev    next >
OS/2 REXX Batch file  |  1994-07-10  |  4KB  |  149 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.    PARSE PULL db_path .
  24.    Say
  25.    Say 'Enter User Name -'
  26.    PARSE PULL user_name
  27.    Say 'Enter Password -'
  28.    PARSE PULL user_pw
  29. end  /* Do */
  30.  
  31.  
  32. /* Load the RexxVIM extensions to Rexx */
  33. rc = RxFuncAdd('RxVIMLoadFuncs', 'REXXVIM', 'RxVIMLoadFuncs')
  34. if rc <> 0 then do
  35.    Say
  36.    Say 'RexxVIM failed to load, return code' rc
  37.    Say
  38.    Say 'Functions have been released.  Retry program.'
  39.    signal done
  40. end  /* Do */
  41. call RxVIMLoadFuncs
  42. Say 'Functions are now loaded'
  43. Say
  44.  
  45.  
  46. /* Initialize the VIM subsystem */
  47. rc = RxVIMInitialize()
  48. Say
  49. Say '|-Call To Routine ---------------RC--|'
  50. Say '  RxVIMInitialize -              ' rc
  51. if (rc > 0) then call vimerr
  52.  
  53.  
  54. /* Open a session with the postoffice using the parameters */
  55. /* provided by the user                                    */
  56. rc = RxVIMOpenSession(db_path,user_name,user_pw,Session)
  57. Say '  RxVIMOpenSession -             ' rc
  58. if (rc > 0) then call vimerr
  59.  
  60.  
  61. /* Create a new message of type VIM_MAIL */
  62. rc = RxVIMCreateMessage(Session,'VIM_MAIL','Message')
  63. Say '  RxVIMCreateMessage -           ' rc
  64. if (rc > 0) then call vimerr
  65.  
  66.  
  67. /* Set the header text */
  68. hdrtext = user_name"'s config.sys file"
  69. rc = RxVIMSetMessageHeader(Message,'VIMSEL_SUBJECT', hdrtext)
  70. Say '  RxVIMSetMessageHeader -        ' rc
  71. if (rc > 0) then call vimerr
  72.  
  73.  
  74. /* Set the priority to high */
  75. rc = RxVIMSetMessageHeader(Message,'VIMSEL_PRIORITY', 'VIM_HIGH_PRIORITY')
  76. Say '  RxVIMSetMessageHeader -        ' rc
  77. if (rc > 0) then call vimerr
  78.  
  79.  
  80. /* Set the recipient to the user that is logged on */
  81. /* This will send the message back to ourselves    */
  82. rc = RxVIMSetMessageRecipient(Message,'VIMSEL_TO','VIMSEL_ENTITY','','',,
  83.                 user_name,'','')
  84. Say '  RxVIMSetMessageRecipient -     ' rc
  85. if (rc > 0) then call vimerr
  86.  
  87.  
  88. /* Add some text to the message */
  89. itemtxt = 'This message was created using the VIM Toolkit for Rexx!!'
  90. rc = RxVIMSetMessageItem(Message,'VIMSEL_NOTE_PART','VIM_TEXT','VIMSEL_NATIVE',,
  91.          'Message Demo',itemtxt,'')
  92. Say '  RxVIMSetMessageItem -          ' rc
  93. if (rc > 0) then call vimerr
  94.  
  95.  
  96. /* Add the config.sys as a file attachment in the message */
  97. rc = RxVIMSetMessageItem(Message,'VIMSEL_ATTACH','VIM_TEXT','VIMSEL_NATIVE',,
  98.          'config.sys','','c:\config.sys')
  99. Say '  RxVIMSetMessageItem -          ' rc
  100. if (rc > 0) then call vimerr
  101.  
  102.  
  103. /* Send the message */
  104. rc = RxVIMSendMessage(Message)
  105. Say '  RxVIMSendMessage -             ' rc
  106. if (rc > 0) then call vimerr
  107.  
  108.  
  109. /* Close the session with the postoffice */
  110. rc = RxVIMCloseSession(Session)
  111. Say '  RxVIMCloseSession -            ' rc
  112. if (rc > 0) then call vimerr
  113.  
  114.  
  115. /* Terminate the active VIM subsystem connection */
  116. rc = RxVIMTerminate()
  117. Say '  RxVIMTerminate -               ' rc
  118. if (rc > 0) then call vimerr
  119. signal done
  120.  
  121.  
  122. /***** VIMErr *******/
  123.  
  124. /* If an error occurs, this function will return the text */
  125. /* associated with the error.  Extended text may be       */
  126. /* displayed if it exists for the specified error.        */
  127.  
  128. VIMERR:
  129.  
  130. rc = RxVIMStatusText(Session,rc,'Status')
  131. Say
  132. Say '|-Error Information -----------------|'
  133. Say '  Error Text -' status.1
  134. Say
  135. Say '  Ext Status -' status.2
  136. rc = RxVIMTerminate()
  137. signal done
  138.  
  139.  
  140. /* The done section will unload the RexxVIM extensions */
  141. /* and exit the program                                */
  142. DONE:
  143. /*** Drop all of the external functions ***/
  144. call RxVIMDropFuncs
  145. Say '|------------------------------------|'
  146. Say 'Demo Complete.  All functions released'
  147. 'pause'
  148. exit
  149.