home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxvim.zip / MSGCONT.CMD < prev    next >
OS/2 REXX Batch file  |  1994-07-07  |  7KB  |  199 lines

  1. /** Msgcont.cmd **/
  2. /*********************************************/
  3. /*                                           */
  4. /* Command line syntax:                      */
  5. /*                                           */
  6. /* msgcont 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 Container Demonstration Program'
  14. Say
  15.  
  16. /* Unload the function 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. if (rc > 0) then call vimerr
  49.  
  50. /* Open a session with the postoffice using the parameters */
  51. /* provided by the user                                    */
  52. rc = RxVIMOpenSession(db_path,user_name,user_pw,Session)
  53. if (rc > 0) then call vimerr
  54.  
  55.  
  56. /* Open the default message container -- Inbox */
  57. rc = RxVIMOpenMessageContainer(Session,'','Inbox')
  58. if (rc > 0) then call vimerr
  59.  
  60.  
  61. /* Query the message container for new mail */
  62. rc = RxVIMQueryNewMessages(Inbox,'New_Mail')
  63. if (rc > 0) then call vimerr
  64. Say '--------------------------------------------------------'
  65. Say '      New Mail Flag is' New_Mail
  66.  
  67.  
  68. /* Query the number of new messages */
  69. rc = RxVIMQueryUnreadMailCount(Inbox,'Unread_Count')
  70. if (rc > 0) then call vimerr
  71. Say '   Number of unread messages is' Unread_Count
  72. Say '--------------------------------------------------------'
  73. Say
  74.  
  75.  
  76. /* Display all messages in Inbox if new mail exists */
  77.  
  78. if New_Mail = 'True' then do
  79.  
  80.      Say 'To review all messages in Inbox,'
  81.      'pause'
  82.  
  83.      /* Enumerate messages in container -- Inbox */
  84.      pos = ''                           /* Start at the beginning of the container */
  85.      skipcnt = 1                        /* Move forward through the container one at a time */
  86.      mcount  = 1                        /* Retrieve 1 message for each call */
  87.      filter  = 'VIMSEL_NO_FILTER'       /* No filter, return all messages in inbox */
  88.      fdata   = ''                       /* No filter data */
  89.      flags   = 'VIM_NO_FLAGS'           /* No enumeration flags, return all messages in inbox */
  90.      more    = ''                       /* Set the value of more to nul */
  91.      action  = 'N'                      /* Set the value of repeat loop indicator to N */
  92.  
  93.      AttrDesc.0 = 2                          /* Retrieve 2 attributes for each message */
  94.      AttrDesc.1.Selector = 'VIMSEL_REF'      /* 1st attribute is the message reference number */
  95.      AttrDesc.1.Buffer   = 'MsgRefNo'        /* store results in this stem variable */
  96.      AttrDesc.2.Selector = 'VIMSEL_SUBJECT'  /* 2nd attribute is the message subject */
  97.      AttrDesc.2.Buffer   = 'Subject'         /* store results in this stem variable */
  98.  
  99.      do until TRANSLATE(SUBSTR(action,1,1)) = 'X'
  100.  
  101.           /* Continue retrieving message info until user enters N */
  102.  
  103.           rc = RxVIMEnumerateMessages(Inbox,'pos',skipcnt,'AttrDesc','mcount',filter,fdata,flags,'more')
  104.           if (rc > 0) then call vimerr
  105.  
  106.           /* Display results */
  107.          'cls'
  108.           Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  109.           Say
  110.           Say 'Message Container Demo'
  111.           Say
  112.           Say '--------------------------------------------------------'
  113.           Say '    Message =' MsgRefNo.1
  114.           Say '    Subject =' Subject.1
  115.           Say '--------------------------------------------------------'
  116.           Say
  117.           Say
  118.           Say 'Select an action for this message'
  119.           Say
  120.           Say '   D - Delete message'
  121.           Say '   F - File message in a folder'
  122.           Say '   N - Go to next message, leave this one in the Inbox'
  123.           Say '   X - Exit demo now'
  124.           Say
  125.           Say 'Enter your selection below:'
  126.           PULL action
  127.           if more = 'False' then do
  128.              Say 'All messages have been retrieved'
  129.              action = 'X'
  130.           end  /* Do */
  131.  
  132.           /* Process the selection entered.  X will fall through the select statement */
  133.           select
  134.              when TRANSLATE(SUBSTR(action,1,1)) = 'D' then do
  135.                 /* Delete message */
  136.                 rc = RxVIMRemoveMessage(Inbox,MsgRefNo.1)
  137.                 if (rc > 0) then call vimerr
  138.            end  /* Do */
  139.              when TRANSLATE(SUBSTR(action,1,1)) = 'F' then do
  140.                 /* File message in folder */
  141.                 Say 'Enter the name of the folder:'
  142.                 PULL category
  143.                  rc = RxVIMSetMessageCategory(Inbox,MsgRefNo.1,category)
  144.                 if (rc > 0) then call vimerr
  145.              end  /* Do */
  146.              when TRANSLATE(SUBSTR(action,1,1)) = 'N' then do
  147.                 /* Go to the next message */
  148.                 /* Nothing to do.....loop will pull next message */
  149.              end  /* Do */
  150.           otherwise
  151.           end  /* select */
  152.      end /* do */
  153. end  /* Do */
  154.  
  155.  
  156. /* Close the message container -- Inbox */
  157. rc = RxVIMCloseMessageContainer(Inbox)
  158. if (rc > 0) then call vimerr
  159.  
  160.  
  161. /* Close the session with the postoffice */
  162. rc = RxVIMCloseSession(Session)
  163. if (rc > 0) then call vimerr
  164.  
  165.  
  166. /* Terminate the active VIM subsystem connection */
  167. rc = RxVIMTerminate()
  168. if (rc > 0) then call vimerr
  169. signal done
  170.  
  171.  
  172. /***** VIMErr *******/
  173.  
  174. /* If an error occurs, this function will return the text */
  175. /* associated with the error.  Extended text may be       */
  176. /* displayed if it exists for the specified error.        */
  177.  
  178. VIMERR:
  179.  
  180. erc = RxVIMStatusText(Session,rc,'Status')
  181. Say
  182. Say '|-Error Information ------------------------------------|'
  183. Say '  Error Text -' status.1
  184. Say
  185. Say '  Ext Status -' status.2
  186. rc = RxVIMTerminate()
  187. signal done
  188.  
  189.  
  190. /* The done section will unload the RexxVIM extensions */
  191. /* and exit the program                                */
  192. DONE:
  193. /*** Drop all of the external functions ***/
  194. call RxVIMDropFuncs
  195. Say '|-------------------------------------------------------|'
  196. Say 'Demo Complete.  All functions released'
  197. 'pause'
  198. exit
  199.